Skip to content

feat(telemetry link): Onboarding TelemetryLink#1456

Open
ozanichkovsky wants to merge 2 commits into
stackitcloud:mainfrom
ozanichkovsky:feature/telemetrylink
Open

feat(telemetry link): Onboarding TelemetryLink#1456
ozanichkovsky wants to merge 2 commits into
stackitcloud:mainfrom
ozanichkovsky:feature/telemetrylink

Conversation

@ozanichkovsky
Copy link
Copy Markdown

Description

TelemetryLink service resources and datasources.

Checklist

  • Issue was linked above
  • Code format was applied: make fmt
  • Examples were added / adjusted (see examples/ directory)
  • Docs are up-to-date: make generate-docs (will be checked by CI)
  • Unit tests got implemented or updated
  • Acceptance tests got implemented or updated (see e.g. here)
  • Unit tests are passing: make test (will be checked by CI)
  • No linter issues: make lint (will be checked by CI)

@ozanichkovsky ozanichkovsky requested a review from a team as a code owner May 11, 2026 20:00
@ozanichkovsky ozanichkovsky changed the title feat: TelemetryLink resources and datasources feat(telemetry link): Onboarding TelemetryLink May 11, 2026
Copy link
Copy Markdown
Contributor

@Fyusel Fyusel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some first review comments, need to have a deeper look

@@ -0,0 +1,5 @@
data "stackit_telemetrylink_link" "link" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name here is doubled "link"

@@ -0,0 +1,24 @@
resource "stackit_telemetrylink_link" "link" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: "link" is doubled


func (d *telemetryLinkLinkDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: fmt.Sprintf("TelemetryLink Link data source schema. %s", core.DatasourceRegionFallbackDocstring),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doubled name "link"

validate.NoSeparator(),
},
},
"resource_id": schema.StringAttribute{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Can you please put the required fields on top after the id (so that it is sorted - required, optional)

resp.State.RemoveResource(ctx)
return
}
core.LogAndAddError(ctx, &resp.Diagnostics, "Error reading TelemetryLink link", fmt.Sprintf("Calling API: %v", err))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doubled "link" (check everywhere please) won't comment every occurrence

return
}

regionId := r.providerData.GetRegionWithOverride(model.Region)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two lines are present in every case. Please put this before the switch:

region := r.providerData.GetRegionWithOverride(model.Region)
ctx = tflog.SetField(ctx, "region", region)

switch resourceType {
case resourceTypeOrganization:
response, err = r.client.DefaultAPI.GetOrganizationTelemetryLink(ctx, resourceID, region).Execute()
if err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error block is the same for all cases, please move it out of the switch case

return
}

regionId := r.providerData.GetRegionWithOverride(model.Region)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

ctx = tflog.SetField(ctx, "region", regionId)
_, err = r.client.DefaultAPI.CreateOrUpdateOrganizationTelemetryLink(ctx, resourceID, regionId).CreateOrUpdateOrganizationTelemetryLinkPayload(*payload).Execute()
if err != nil {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error creating TelemetryLink Link", fmt.Sprintf("Calling API: %v", err))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those messages contain "creating" but it is "updating" (same for the following)

})
}

func (r *telemetryLinkInstanceResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { // nolint:gocritic // function signature required by Terraform
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as far as I can see: create and update are the same.
Shouldn't be partial update possible?

"display_name": config.StringVariable("tf-acc-test-link-max"),
"description": config.StringVariable("tf-acc-test-link-description"),
"access_token": config.StringVariable("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.KMUFsIDTnFmyG3nMiGM6H9FNFUROf3wh7SmqJp-QV30"),
"telemetry_router_id": config.StringVariable("97272f10-87ec-4715-b280-195a4ab1856c"),
Copy link
Copy Markdown
Contributor

@Fyusel Fyusel May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work here. Where does this ID come from? Manually created telemetry router?
Those acc tests should work without manual steps so if there are additional resources required you need to add those to the resource-min.tf and resource-max.tf. Same for access_token

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do this until #1425 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants