Skip to content

Commit cd46b48

Browse files
committed
t add push url in ressource source
1 parent 20c2f9b commit cd46b48

File tree

7 files changed

+79
-60
lines changed

7 files changed

+79
-60
lines changed

docs/resources/cockpit_source.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ In addition to all arguments above, the following attributes are exported:
3939
~> **Important:** cockpit data sources' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111
4040

4141
- `url` - The URL of the cockpit data source.
42+
- `push_url` - The URL endpoint used for pushing data to the cockpit data source.
4243
- `origin` - The origin of the cockpit data source.
4344
- `synchronized_with_grafana` - Indicates whether the data source is synchronized with Grafana.
4445
- `created_at` - Date and time of the cockpit data source's creation (RFC 3339 format).

internal/services/cockpit/cockpit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func ResourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interfac
182182
endpoints := flattenCockpitEndpoints(dataSourcesRes.DataSources, grafana.GrafanaURL, alertManagerURL)
183183

184184
_ = d.Set("endpoints", endpoints)
185-
_ = d.Set("push_url", createCockpitPushURL(endpoints))
185+
_ = d.Set("push_url", createCockpitPushURLList(endpoints))
186186

187187
return nil
188188
}

internal/services/cockpit/cockpit_data_source.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func dataSourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interf
9191
endpoints := flattenCockpitEndpoints(dataSourcesRes.DataSources, grafana.GrafanaURL, alertManagerURL)
9292

9393
_ = d.Set("endpoints", endpoints)
94-
_ = d.Set("push_url", createCockpitPushURL(endpoints))
94+
_ = d.Set("push_url", createCockpitPushURLList(endpoints))
9595
d.SetId(projectID)
9696
return nil
9797
}

internal/services/cockpit/source.go

+6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func ResourceCockpitSource() *schema.Resource {
6868
Computed: true,
6969
Description: "The date and time of the last update of the cockpit datasource",
7070
},
71+
"push_url": {
72+
Type: schema.TypeString,
73+
Computed: true,
74+
Description: "The URL endpoint used for pushing data to the cockpit data source.",
75+
},
7176
"project_id": account.ProjectIDSchema(),
7277
"region": regional.Schema(),
7378
},
@@ -121,6 +126,7 @@ func ResourceCockpitSourceRead(ctx context.Context, d *schema.ResourceData, meta
121126
_ = d.Set("created_at", types.FlattenTime(res.CreatedAt))
122127
_ = d.Set("updated_at", types.FlattenTime(res.UpdatedAt))
123128
_ = d.Set("project_id", res.ProjectID)
129+
_ = d.Set("push_url", createCockpitPushURL(res.Type, res.URL))
124130

125131
return nil
126132
}

internal/services/cockpit/source_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestAccCockpitSource_Basic(t *testing.T) {
3939
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "type", "metrics"),
4040
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "region", "fr-par"),
4141
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "url"),
42+
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "push_url"),
4243
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "origin"),
4344
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "created_at"),
4445
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "updated_at"),

0 commit comments

Comments
 (0)