-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: support for nested write-only arguments + write-only arguments for google_monitoring_notification_channel
#15538
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
Open
ramonvermeulen
wants to merge
18
commits into
GoogleCloudPlatform:main
Choose a base branch
from
ramonvermeulen:f/24327-write-only-pointer-constraint-groups
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+285
−64
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
342bf27
feat: initial implementation of the constraint group registry
ramonvermeulen 7177185
fix: also enable `write_only` for the `service_key`
ramonvermeulen 61aa6ea
refactor: slightly simplify implementation
ramonvermeulen 3d9bf59
fix: this branching seems redundant
ramonvermeulen 6cd97e8
fix: format
ramonvermeulen c93f109
test: added tests for write-only labels (encountered some issues due …
ramonvermeulen 8a48fca
fix: apply write-only templating logic for nested fields
ramonvermeulen ac2487d
fix: use write-only generation instead of the custom implementation
ramonvermeulen 0b3e95a
Merge branch 'main' into f/24327-write-only-pointer-constraint-groups
ramonvermeulen 25a9534
feat: implementation of nested write only documentation generation
ramonvermeulen a6f3f56
fix: remove sorting (changes too much generated markdowns, harder to …
ramonvermeulen e8d2222
Merge branch 'main' into f/24327-write-only-pointer-constraint-groups
ramonvermeulen 0700799
fix: apply changes after `Lineage` refactor
ramonvermeulen 7784bfd
Merge branch 'main' into f/24327-write-only-pointer-constraint-groups
ramonvermeulen bc7d6ff
fix: solved the markdown rendering
ramonvermeulen a779460
fix: apply quick suggestions from code review @melinath
ramonvermeulen dde31a9
feat: additional changes to clean-up the decoder
ramonvermeulen 5d25a49
fix: make sensitiveLabels `ignore_read` and make encoder more specific
ramonvermeulen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
21 changes: 12 additions & 9 deletions
21
mmv1/templates/terraform/constants/monitoring_notification_channel.go.tmpl
This file contains hidden or 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 |
|---|---|---|
| @@ -1,13 +1,16 @@ | ||
|
|
||
| var sensitiveLabels = []string{"auth_token", "service_key", "password"} | ||
| var writeOnlySensitiveLabels = []string{"auth_token_wo_version", "service_key_wo_version", "password_wo_version"} | ||
|
|
||
| func sensitiveLabelCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v interface{}) error { | ||
| for _, sl := range sensitiveLabels { | ||
| mapLabel := diff.Get("labels." + sl).(string) | ||
| authLabel := diff.Get("sensitive_labels.0." + sl).(string) | ||
| if mapLabel != "" && authLabel != "" { | ||
| return fmt.Errorf("Sensitive label [%s] cannot be set in both `labels` and the `sensitive_labels` block.", sl) | ||
| } | ||
| } | ||
| return nil | ||
| } | ||
| for _, sl := range sensitiveLabels { | ||
| l := strings.TrimSuffix(sl, "_wo") | ||
| l = strings.TrimSuffix(l, "_wo_version") | ||
| val := diff.Get("labels." + l).(string) | ||
| sensitiveVal := diff.Get("sensitive_labels.0." + sl).(string) | ||
| if val != "" && sensitiveVal != "" { | ||
| return fmt.Errorf("Sensitive label %q cannot be set at the same time as label %q.", sl, l) | ||
| } | ||
| } | ||
| return nil | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
18 changes: 8 additions & 10 deletions
18
mmv1/templates/terraform/nested_property_documentation.html.markdown.tmpl
This file contains hidden or 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 |
|---|---|---|
| @@ -1,34 +1,32 @@ | ||
| {{ "" }} | ||
| {{- if and $.FlattenObject (not $.WriteOnlyProperties) }} | ||
| {{- range $np := $.NestedProperties }} | ||
| {{- $nested := or $.NestedProperties $.WriteOnlyProperties }} | ||
| {{- if and $.FlattenObject $nested }} | ||
| {{- range $np := $.AllUniqueNestedProperties }} | ||
| {{- trimTemplate "nested_property_documentation.html.markdown.tmpl" $np -}} | ||
| {{- end -}} | ||
| {{- else if and $.NestedProperties (not $.WriteOnlyProperties) }} | ||
| {{- else if $nested }} | ||
| <a name="nested_{{ join $.Lineage "_" }}"></a>The `{{ underscore $.Name }}` block {{ if $.Output }}contains{{ else }}supports{{ end }}: | ||
| {{ "" }} | ||
| {{- if $.IsA "Map" }} | ||
| * `{{ underscore $.KeyName }}` - (Required) The identifier for this object. Format specified above. | ||
| {{ "" }} | ||
| {{- end -}} | ||
| {{- if $.NestedProperties }} | ||
| {{- range $np := $.NestedProperties }} | ||
| {{- range $np := $.AllUniqueNestedProperties -}} | ||
| {{- trimTemplate "property_documentation.html.markdown.tmpl" $np -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{ "" }} | ||
| {{- $innerNested := false }} | ||
| {{- range $np := $.NestedProperties }} | ||
| {{- range $np := $.AllUniqueNestedProperties }} | ||
| {{- if $np.NestedProperties }} | ||
| {{- $innerNested = true }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if $innerNested}} | ||
| {{ "" }} | ||
| {{- end }} | ||
| {{- range $np := $.NestedProperties }} | ||
| {{- range $np := $.AllUniqueNestedProperties }} | ||
| {{- if $np.NestedProperties }} | ||
| {{- trimTemplate "nested_property_documentation.html.markdown.tmpl" $np -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{ "" }} |
27 changes: 0 additions & 27 deletions
27
mmv1/templates/terraform/nested_property_write_only_documentation.html.markdown.tmpl
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.