Skip to content

Commit 8cccf30

Browse files
authored
Revert "Resolves $resources as regular variables if set by user (#3370)" (#3421)
This reverts commit 9681b7f. This breaks deployments due to swapping the order of resolution and preset application.
1 parent 3d367b1 commit 8cccf30

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

NEXT_CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# NEXT CHANGELOG
22

3-
## Release v0.265.0
3+
## Release v0.264.2
44

55
### Notable Changes
6+
* Revert ([#3370](https://github.com/databricks/cli/pull/3370)) "Resolve $resources as regular variables if set by user". This breaks deployments due to swapping the order of resolution and preset application.
67

78
### Dependency updates
89

acceptance/bundle/variables/resolve-resources-fields/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
"schemas": {
2020
"bar": {
2121
"catalog_name": "main",
22-
"comment": "var.b=this is var.b unresolved? apps.baz.id=\"${resources.apps.baz.id}\" apps.baz.url=\"${resources.apps.baz.url}\" schemas.bar.name=unresolved? apps.baz.id=\"${resources.apps.baz.id}\" apps.baz.url=\"${resources.apps.baz.url}\" schemas.foo.name=unresolved? apps.baz.id=\"${resources.apps.baz.id}\" apps.baz.url=\"${resources.apps.baz.url}\"",
22+
"comment": "var.b=this is var.b ${resources.schemas.foo.name} schemas.bar.name=${resources.schemas.bar.name} schemas.foo.name=${resources.schemas.foo.name}",
2323
"name": "unresolved? apps.baz.id=\"${resources.apps.baz.id}\" apps.baz.url=\"${resources.apps.baz.url}\""
2424
},
2525
"foo": {
2626
"catalog_name": "main",
2727
"comment": "unresolved? schemas.bar.non_existing:\"${resources.schemas.bar.non_existing}\" schemas.bar.id:\"${resources.schemas.bar.id}\"",
28-
"name": "unresolved? apps.baz.id=\"${resources.apps.baz.id}\" apps.baz.url=\"${resources.apps.baz.url}\""
28+
"name": "${resources.schemas.bar.name}"
2929
}
3030
}
3131
}

bundle/config/mutator/resolve_variable_references.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ var defaultPrefixes = []string{
4141
"bundle",
4242
"workspace",
4343
"variables",
44-
"resources",
45-
}
46-
47-
var optionalResolution = map[string]bool{
48-
// Enables different mode for resolution:
49-
// - normalization is not done, if field is not set by user it's missing
50-
// - if field is missing (either it's a valid field but not set or invalid field), it remains unresolved, no error
51-
"resources": true,
5244
}
5345

5446
var artifactPath = dyn.MustPathFromString("artifacts")
@@ -237,24 +229,8 @@ func (m *resolveVariableReferences) resolveOnce(b *bundle.Bundle, prefixes []dyn
237229
// Perform resolution only if the path starts with one of the specified prefixes.
238230
for _, prefix := range prefixes {
239231
if path.HasPrefix(prefix) {
240-
isOpt := optionalResolution[prefix[0].Key()]
241-
var value dyn.Value
242-
var err error
243-
if isOpt {
244-
// We don't want injected zero value when resolving $resources.
245-
// We only want entries that are explicitly provided by users, so we're using root not normalized here.
246-
value, err = m.lookupFn(root, path, b)
247-
if !value.IsValid() {
248-
// Not having a value is not an error in this case, it might be resolved at deploy time.
249-
// TODO: we still could check whether it's part of the schema or not. If latter, we can reject it right away.
250-
// TODO: This might be better done after we got rid of TF.
251-
return dyn.InvalidValue, dynvar.ErrSkipResolution
252-
}
253-
} else {
254-
value, err = m.lookupFn(normalized, path, b)
255-
}
256-
hasUpdates = hasUpdates || (err == nil && value.IsValid())
257-
return value, err
232+
hasUpdates = true
233+
return m.lookupFn(normalized, path, b)
258234
}
259235
}
260236

0 commit comments

Comments
 (0)