-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 support for accelerators to google_datafusion_instance #6851
Merged
NickElliot
merged 13 commits into
GoogleCloudPlatform:main
from
NickElliot:accelerator-bug
Mar 8, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
785b704
Added accelerators field to Data Fusion
NickElliot 22e84e5
adding test update
NickElliot 2a46afb
Updates made to accelerators tests
NickElliot 230a824
updating declared accelerator state in example test
NickElliot 8ce0cc2
Updating test to refer to proper values
NickElliot e93f4ae
Updated field attributes
NickElliot 2663402
Added in-place update handwritten test
NickElliot ff94f23
Removed unneeded value, updated test for better documentation
NickElliot a9b94db
Fixing conflict error
NickElliot 56edbba
Fixing conflict error 2
NickElliot b216d4e
Updated to add diffsuppressfunc
NickElliot 3d6e880
added custom code field to terraform.yaml
NickElliot a97b326
Updated to move changes to Instance.yaml over api.yaml
NickElliot 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
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
21 changes: 21 additions & 0 deletions
21
mmv1/templates/terraform/constants/data_fusion_instance_option.go.erb
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var instanceAcceleratorOptions = []string{ | ||
"delta.default.checkpoint.directory", | ||
"ui.feature.cdc", | ||
} | ||
|
||
func instanceOptionsDiffSuppress(k, old, new string, d *schema.ResourceData) bool { | ||
// Suppress diffs for the options generated by adding an accelerator to a data fusion instance | ||
for _, option := range instanceAcceleratorOptions { | ||
if strings.Contains(k, option) && new == "" { | ||
return true | ||
} | ||
} | ||
|
||
// Let diff be determined by options (above) | ||
if strings.Contains(k, "options.%") { | ||
return true | ||
} | ||
|
||
// For other keys, don't suppress diff. | ||
return false | ||
} |
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
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.
drive-by post review comment: We could consider marking this as
required: true
as well, or mark a clientside "ENABLED" default. We need more complete guidance on this, but we want to avoiddefault_from_api
wherever possible- it creates worse Terraform plans, and can have surprising behaviour when performing complex updates. We still need to use it a lot of the time, though, particularly on already-released fields.Particularly, there are often cases where making a field (in a new resource) or a subfield (of a new field) required is preferable to mapping to the minimum possible message the API allows. It creates a very clear schema, and makes the user's configuration+plan very explicit about what's happening. Plus, it's possible to change the schema in a minor version- including adding a clientside default. That's not an option for new top-level fields in existing resources or subfields in existing fields, since that'd be a breaking change.
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.
Is there a general rule for when to approach something with "this supports the main use cases better" as opposed to just matching the API functionality? Or is it just the kind of thing that will make more sense with further experience working with the provider and adding more resources and functionality?
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.
Right now just further experience- we need to create guidance/define a general approach, but the rules will always be pretty subjective.
My thinking here is: consider the potential for confusion here if a user has a DISABLED accelerator and the state field is not in config Terraform won't see a diff, and recreating will create a resource in a different state- vs the annoyance of typing (and realistically, copy-pasting) "ENABLED" into configs.