Skip to content

Consolidate the OidcAuthentication properties on FeedResource into a single property#341

Merged
IsaacCalligeros95 merged 7 commits into
mainfrom
isaac/feed-oidc-auth-consolidation
Jul 17, 2025
Merged

Consolidate the OidcAuthentication properties on FeedResource into a single property#341
IsaacCalligeros95 merged 7 commits into
mainfrom
isaac/feed-oidc-auth-consolidation

Conversation

@IsaacCalligeros95

@IsaacCalligeros95 IsaacCalligeros95 commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

When updating ACR, GCR and ECS feeds the OidcAuthentication property is not being bound on the server side modify calls. This happens because the FeedResource properties AzureContainerRegistryOidcAuthentication, ElasticContainerRegistryOidcAuthentication and GoogleContainerRegistryOidcAuthentication do not match the server side values. This change consolidates these into a single property OidcAuthentication which has a type property to discriminate on. The JSON unmarshalling here isn't pretty but works, it determines the OidcAuthentication type based on the available properties, in this case the properties are always available, and we're just checking it's there the value itself is not required.

Related to - https://github.com/OctopusDeploy/terraform-provider-octopusdeploy/pull/40/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6

@IsaacCalligeros95 IsaacCalligeros95 changed the title Consolidates the OidcAuthentication properties on FeedResource into a single property Consolidate the OidcAuthentication properties on FeedResource into a single property Jul 15, 2025

@domenicsim1 domenicsim1 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.

Nice

@wlthomson wlthomson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not an expert in this area, but this looks OK to me.

I'm not sure about the unmarshelling without some sort of "type" property as pointed out, but without that I can't see a better alternative.

Couple of minors, but otherwise good to go ahead.

Comment thread pkg/feeds/oidc_authentication.go

// Discriminate based on properties. This is hacky, but we would have to add a "Type" property to the API
// To handle this properly
if _, hasClientId := raw["ClientId"]; hasClientId {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you also need to check that the value isn't empty?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the ClientId can be empty, but the field is still returned on the OidcAuthentication object and used as the discriminator to get the type

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh, didn't realise ClientId was optional. In either case, just flagging this up as a small regression risk as we need to be careful that other shapes aren't changed at any point to include null/undefined/empty properties which could trigger the wrong conditional (seems unlikely, but possible). I'm not sure what to suggest for optional fields, though.

@IsaacCalligeros95
IsaacCalligeros95 merged commit f6d31d7 into main Jul 17, 2025
6 checks passed
@IsaacCalligeros95
IsaacCalligeros95 deleted the isaac/feed-oidc-auth-consolidation branch July 17, 2025 01:42
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.

3 participants