Skip to content

feat(container-registry): onboard tf driver for container registry - #1870

Open
martinezmo wants to merge 6 commits into
stackitcloud:mainfrom
martinezmo:feat/container-registry
Open

martinezmo wants to merge 6 commits into
stackitcloud:mainfrom
martinezmo:feat/container-registry

Conversation

@martinezmo

Copy link
Copy Markdown

Description

relates to STACKITCRE-383

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)

@martinezmo
martinezmo requested a review from a team as a code owner November 6, 2026 21:43

@Fyusel Fyusel left a comment

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.

Thank you for your contribution.
Only some small things at the start, will continue with a detailed review

service_account_email = "abc@abc.de"
cdn_custom_endpoint = "https://cdn.api.eu01.stackit.cloud"
dns_custom_endpoint = "https://dns.api.stackit.cloud"
containerregistry_custom_endpoint = "https://registry.api.stackit.cloud"

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.

mismatch: container_registry_custom_endpoint

"region": schema.StringAttribute{
Description: descriptions["region"],
Optional: true,
Computed: true,

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.

Suggested change
Computed: true,

Description: descriptions["artifactory_id"],
Required: true,
Validators: []validator.String{
validate.NoSeparator(),

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.

validate.UUID(), missing

fmt.Sprintf("Calling API: %v", err),
map[int]string{
http.StatusNotFound: fmt.Sprintf("Artifactory %q not found", artifactoryId),
},

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.

resp.State.RemoveResource(ctx) missing

Description: descriptions["artifactory_id"],
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),

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.

Validators: []validator.String{
validate.UUID(),
validate.NoSeparator(),
},

Description: descriptions["create_time"],
Computed: true,
},
"state": 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.

remove state please


payload := registry.NewPatchArtifactoryPayload()

if !model.Proxy.IsNull() && !model.Proxy.IsUnknown() {

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.

e.g. here

}
}

secret := getAccessSecret(&creds, nil, configCreds, false)

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.

regarding credentials and the write only attribute: please have a look at e.g. the VPN resource and use the same implementation like it is there

if !resp.Diagnostics.HasError() {
t.Error("expected diagnostics on delete error")
}
})

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.

TestSavesIDsOnError is missing (see CONTRIBUTION for more details)

"registry_type": types.StringType,
}

var descriptions = map[string]string{ //nolint:gosec // linter false positive

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: more details why false positive

"region": schema.StringAttribute{
Description: descriptions["region"],
Optional: true,
Computed: true,

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.

Suggested change
Computed: true,

Description: descriptions["create_time"],
Computed: true,
},
"state": 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.

remove state

Optional: true,
Computed: true,
},
"artifactories": schema.ListNestedAttribute{

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.

Optional: true,
Computed: true,
},
"replication_adapters": schema.ListNestedAttribute{

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.

see artifactories -> needs to be called results


data "stackit_containerregistry_artifactories" "this" {
project_id = local.project_id
}

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.

Regarding the ADR: filter examples should be added here as well


data "stackit_containerregistry_replication_adapters" "this" {
project_id = local.project_id
}

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.

Regarding the ADR: filter examples should be added here as well


"create_time": types.StringType,

"state": types.StringType,

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.

of course all other occurrences of state needs to be removed as well

ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "region", region)

listResp, err := d.client.ListReplicationAdapters(ctx, projectId, region).Execute()

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 API offers a next_page_token as well here, this is missing


allArtifactories = append(allArtifactories, listResp.Artifactories...)

if listResp.NextPageToken == nil || *listResp.NextPageToken == "" {

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.

regarding the pagination please use the paginate.All() functionality. There are also examples in the SDK (experimental/paginate). Same for replicationadapters

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants