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

fix: res def secret refs with null values #94

Merged
merged 3 commits into from
Jun 14, 2024
Merged

Conversation

johanneswuerbach
Copy link
Contributor

@johanneswuerbach johanneswuerbach commented Jun 13, 2024

When using an explicit type like:

object({
    ref     = optional(string)
    store   = optional(string)
    value   = optional(string)
    version = optional(string)
})

to pass around secret references, terraform will serialise optional values to null.

This null values causes the provider to break:

│ Error: Provider produced inconsistent result after apply
│
│ When applying changes to module.base.module.config_imagepullsecret.humanitec_resource_definition.main, provider "provider[\"registry.terraform.io/humanitec/humanitec\"]" produced an unexpected new value: .driver_inputs.secret_refs: was
│ cty.StringVal("{\"AWS_ACCESS_KEY_ID\":{\"ref\":\"XYZ\",\"store\":\"XYZ\",\"value\":null,\"version\":\"terraform-20240607165723165200000005\"}}"),
│ but now
│ cty.StringVal("{\"AWS_ACCESS_KEY_ID\":{\"ref\":\"XYZ\",\"store\":\"XYZ\",\"version\":\"terraform-20240607165723165200000005\"}}").

Instead of generally taking the API response, change the logic to merge the API response and the local state.

@johanneswuerbach johanneswuerbach requested review from delca85 and mateuszjenek and removed request for delca85 June 13, 2024 08:56
@johanneswuerbach johanneswuerbach marked this pull request as ready for review June 13, 2024 08:56
Copy link
Contributor

@delca85 delca85 left a comment

Choose a reason for hiding this comment

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

LGTM (and thanks).
I could not find any test with nested secret references (I saw TestMergeResourceDefinitionSecretRefResponse but I mean e2e tests) and it might make sense to have one.

Copy link
Contributor

@mateuszjenek mateuszjenek left a comment

Choose a reason for hiding this comment

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

👍

@johanneswuerbach johanneswuerbach merged commit 03a4a11 into main Jun 14, 2024
2 checks passed
@johanneswuerbach johanneswuerbach deleted the resdef-secret-refs branch June 14, 2024 07:26
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