Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:(cockpit): add push urls to cockpit datasources #2700

Merged
merged 4 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/cockpit_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ In addition to all arguments above, the following attributes are exported:
~> **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

- `url` - The URL of the cockpit data source.
- `push_url` - The URL endpoint used for pushing data to the cockpit data source.
- `origin` - The origin of the cockpit data source.
- `synchronized_with_grafana` - Indicates whether the data source is synchronized with Grafana.
- `created_at` - Date and time of the cockpit data source's creation (RFC 3339 format).
Expand Down
2 changes: 1 addition & 1 deletion internal/services/cockpit/cockpit.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func ResourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interfac
endpoints := flattenCockpitEndpoints(dataSourcesRes.DataSources, grafana.GrafanaURL, alertManagerURL)

_ = d.Set("endpoints", endpoints)
_ = d.Set("push_url", createCockpitPushURL(endpoints))
_ = d.Set("push_url", createCockpitPushURLList(endpoints))

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/services/cockpit/cockpit_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func dataSourceCockpitRead(ctx context.Context, d *schema.ResourceData, m interf
endpoints := flattenCockpitEndpoints(dataSourcesRes.DataSources, grafana.GrafanaURL, alertManagerURL)

_ = d.Set("endpoints", endpoints)
_ = d.Set("push_url", createCockpitPushURL(endpoints))
_ = d.Set("push_url", createCockpitPushURLList(endpoints))
d.SetId(projectID)
return nil
}
6 changes: 6 additions & 0 deletions internal/services/cockpit/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ func ResourceCockpitSource() *schema.Resource {
Computed: true,
Description: "The date and time of the last update of the cockpit datasource",
},
"push_url": {
Type: schema.TypeString,
Computed: true,
Description: "The URL endpoint used for pushing data to the cockpit data source.",
},
"project_id": account.ProjectIDSchema(),
"region": regional.Schema(),
},
Expand Down Expand Up @@ -121,6 +126,7 @@ func ResourceCockpitSourceRead(ctx context.Context, d *schema.ResourceData, meta
_ = d.Set("created_at", types.FlattenTime(res.CreatedAt))
_ = d.Set("updated_at", types.FlattenTime(res.UpdatedAt))
_ = d.Set("project_id", res.ProjectID)
_ = d.Set("push_url", createCockpitPushURL(res.Type, res.URL))

return nil
}
Expand Down
1 change: 1 addition & 0 deletions internal/services/cockpit/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func TestAccCockpitSource_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "type", "metrics"),
resource.TestCheckResourceAttr("scaleway_cockpit_source.main", "region", "fr-par"),
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "url"),
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "push_url"),
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "origin"),
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "created_at"),
resource.TestCheckResourceAttrSet("scaleway_cockpit_source.main", "updated_at"),
Expand Down
Loading
Loading