-
Notifications
You must be signed in to change notification settings - Fork 118
direct: Limit server_side_default to regular fields #4038
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
Conversation
Otherwise it is also applied to key-value pairs which is not intended. Regression acceptance test that shows how old behaviour resulted in ignoring extra permissions in remote state on direct.
|
Commit: 3d18057
15 failing tests:
Top 50 slowest tests (at least 2 minutes):
|
pietern
left a comment
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.
The PR summary says:
Otherwise it is also applied to key-value pairs which is not intended.
But with this change it is specifically applied only to key/value pairs?
|
|
||
| for _, ch := range diff { | ||
| if ch.Old == nil { | ||
| if ch.Old == nil && ch.Path.IsStringKey() { |
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.
Can you include a comment that explains the reasoning?
This check enforces that server side defaults are only allowed for paths that end with a struct/map key. Is that correct?
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.
added 3d18057
No, it's not applied to key/value pairs (which refers to [task_key="mytask"] syntax). It's applied to regular keys (structs fields + maps). See https://github.com/databricks/cli/blob/main/libs/structs/structpath/path.go#L24 tagKeyValue is key-value pair and tagString is regular key. |
| // The field was not set by us, but comes from the remote state. | ||
| // This could either be server-side default or a policy. | ||
| // In any case, this is not a change we should react to. | ||
| // Note, we only consider StringKeys here, because indexes and key-value pairs refer to slices and we want to react to new element in slices. |
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.
Why do key-value pairs refer to slices? Can you extend the comment to explain?
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.
Key value pairs in paths were added to index slices by key in #4014
| // This could either be server-side default or a policy. | ||
| // In any case, this is not a change we should react to. | ||
| // Note, we only consider StringKeys here, because indexes and key-value pairs refer to slices and we want to react to new element in slices. | ||
| // Note, IsStringKey is also too broad - it currently covers struct fields and map keys, we don't want to include map keys here. |
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 might also want to include map keys here. For example tags can have a server side default. See warehouse tags for example:
"tags": {
"custom_tags": [
{
"key":"Owner",
"value":"eng-dev-ecosystem-team_at_databricks.com"
}
]
Eventually we might need to push for proto level annotations for these.
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.
For now focus is on matching Terraform which AFAIK does not have server side default concept for tags.
| @@ -0,0 +1,5 @@ | |||
| Local = true | |||
| Cloud = false | |||
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.
Can you run this on cloud as well?
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.
I'm interested in terraform & direct behavior when a permission is added remotely, testserver covers this.
pietern
left a comment
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.
I was thinking of regular struct fields as key-value pairs, not the structpath kind.
It now makes sense.
|
Commit: 789bb75
22 failing tests:
Top 50 slowest tests (at least 2 minutes):
|
…ys (#4041) ## Changes - Update structpath to distinguish between fields (.field) and map keys (["field"]). Note, when it comes to references, we still accept any syntax. However, structdiff and structwalk accurately represent map keys now. - Update server_side_default logic to ignore map keys. ## Why It was never the intention for map entries to have "server_side_default" feature. (Similar to slice indices in #4038). Issue appeared when we stopped distinguishing between fields and map keys in struct path #3640 Note, originally the difference between fields and map keys was removed so that a) users can use either syntax without worrying about matching the type. This is still the case, structaccess still treats those two the same way. b) "resources.jobs.foo" is printed with dots and not like 'resources.jobs["foo"]'. This is still the case, we don't use structpath's String() for this. ## Tests New regression test.
Why
Otherwise it is also applied to key-value pairs which is not intended.
This is related and fixes bug introduced in #4014
Tests
Regression acceptance test that shows how old behaviour resulted in ignoring extra permissions in remote state on direct.