-
Notifications
You must be signed in to change notification settings - Fork 639
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
Add path to invoke update without determining changed CRN data, add validator for name of secrets #4859
Merged
hkantare
merged 12 commits into
IBM-Cloud:master
from
jared-hayes-dev:terraform-ingress-update-secret-validate-name
Oct 25, 2023
Merged
Add path to invoke update without determining changed CRN data, add validator for name of secrets #4859
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
59ca57e
update + validate
bd91c17
Merge branch 'IBM-Cloud:master' into terraform-ingress-update-secret-…
jared-hayes-dev 13cba28
invalid name tests
49702b6
updated to add new tf only flag for update + tests
58180d6
update false positives
28ddaa2
update secret int
cdbd195
update docs
e24be7d
fetch upstream
3b0bce8
secrets audit
3a75909
pr comments
45555b7
updated tests
d815ea8
Merge branch 'master' into terraform-ingress-update-secret-validate-name
hkantare File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,10 @@ func ResourceIBMContainerIngressSecretTLS() *schema.Resource { | |
Required: true, | ||
Description: "Secret name", | ||
ForceNew: true, | ||
ValidateFunc: validate.InvokeValidator( | ||
"ibm_container_ingress_secret_tls", | ||
"secret_name", | ||
), | ||
}, | ||
"secret_namespace": { | ||
Type: schema.TypeString, | ||
|
@@ -91,6 +95,12 @@ func ResourceIBMContainerIngressSecretTLS() *schema.Resource { | |
Computed: true, | ||
Description: "Timestamp secret was last updated", | ||
}, | ||
"update_secret": { | ||
Type: schema.TypeBool, | ||
Optional: true, | ||
Default: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default can't be false for int type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed - field now has exact same structure as others that fulfill same purpose |
||
Description: "Updates secret from secrets manager if true", | ||
}, | ||
}, | ||
} | ||
} | ||
|
@@ -106,6 +116,15 @@ func ResourceIBMContainerIngressSecretTLSValidator() *validate.ResourceValidator | |
CloudDataType: "cluster", | ||
CloudDataRange: []string{"resolved_to:id"}}) | ||
|
||
validateSchema = append(validateSchema, validate.ValidateSchema{ | ||
Identifier: "secret_name", | ||
ValidateFunctionIdentifier: validate.ValidateRegexpLen, | ||
Type: validate.TypeString, | ||
Required: true, | ||
Regexp: `^([a-z0-9]([-a-z0-9]*[a-z0-9])?(.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)$`, | ||
MinValueLength: 1, | ||
MaxValueLength: 63, | ||
}) | ||
iBMContainerIngressInstanceValidator := validate.ResourceValidator{ResourceName: "ibm_container_ingress_secret_tls", Schema: validateSchema} | ||
return &iBMContainerIngressInstanceValidator | ||
} | ||
|
@@ -228,14 +247,20 @@ func resourceIBMContainerIngressSecretTLSUpdate(d *schema.ResourceData, meta int | |
Namespace: secretNamespace, | ||
} | ||
|
||
ingressAPI := ingressClient.Ingresses() | ||
if d.HasChange("cert_crn") { | ||
params.CRN = d.Get("cert_crn").(string) | ||
|
||
ingressAPI := ingressClient.Ingresses() | ||
_, err := ingressAPI.UpdateIngressSecret(params) | ||
if err != nil { | ||
return err | ||
} | ||
} else if d.HasChange("update_secret") { | ||
// user wants to force an upstream secret update from secrets manager onto kube cluster w/out changing crn | ||
_, err = ingressAPI.UpdateIngressSecret(params) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return resourceIBMContainerIngressSecretTLSRead(d, meta) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will have issue if you want to update_secret multiple times .
If user add this field for first time and mark update_secret = true it goes a head and update secret but next time when he wants to update again it will not show any diff to apply since update_secret = true already exists in state file.
Generally for this kind of scenario we define "update_secret" as int when user want to change it he will just increment the value
similar to https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/container_vpc_cluster#retry_patch_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed