-
Notifications
You must be signed in to change notification settings - Fork 352
Open
Labels
NeedsInvestigationdisjunctionsorderingBugs where the evaluator behaves differently depending on the order of fields, files, etc.Bugs where the evaluator behaves differently depending on the order of fields, files, etc.
Description
What version of CUE are you using (cue version)?
cue version 0.5.0
go version go1.20.3
-buildmode exe
-compiler gc
-trimpath true
CGO_ENABLED 1
GOARCH arm64
GOOS darwin
Does this issue reproduce with the latest stable release?
Yes
What did you do?
Given the below input, I would like to conditionally add the source.path field only if the source type _type is helm. However as you can see in the cue playground, even though X._type resolves to the right string inside the object the condition is incorrectly always matching helm.
I've also noticed that if you change the order of #ApplicationSourceType then it switches to match what's the first element, it’s like the order of this decides what the X._type is during the condition evaluation.
Application: X={
spec: #ArgoApplicationSpec
argoApplication: _Application & {_X: {
spec: X.spec
}}
}
#ArgoApplicationSpec: source: X={
#ApplicationSourceType
repoURL: string | *"https://github.com/foo/bar.git"
targetRevision: string | *"main"
// This has no meaning for Helm charts pulled directly from a Helm repo instead of git.
if X._type != "helm" {
path: *X._type | string
}
}
#ApplicationSourceType:
#SourceHelm |
*#SourcePlugin
#SourceHelm: {
_type: "helm"
// helm specific config
chart?: string
helm: {
// Values file as block file
values?: string
}
}
#SourcePlugin: {
_type: "plugin"
plugin: name?: string
}
_Application: {
_X: _
apiVersion: "argoproj.io/v1alpha1"
kind: "Application"
metadata: namespace: "argocd"
spec: source: _X.spec.source
}What did you expect to see?
// if _type == "plugin"
// snip ...
source: {
repoURL: "https://github.com/foo/bar.git"
targetRevision: "main"
path: "plugin"
plugin: {}
}
// snip ...
// if _type == "helm"
source: {
repoURL: "https://github.com/foo/bar.git"
targetRevision: "main"
helm: {}
}What did you see instead?
// if _type == "plugin"
// snip ...
source: {
repoURL: "https://github.com/foo/bar.git"
targetRevision: "main"
path: "plugin"
plugin: {}
}
// snip ...
// if _type == "helm"
source: {
repoURL: "https://github.com/foo/bar.git"
targetRevision: "main"
path: "helm" // this shouldn't exist.
helm: {}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
NeedsInvestigationdisjunctionsorderingBugs where the evaluator behaves differently depending on the order of fields, files, etc.Bugs where the evaluator behaves differently depending on the order of fields, files, etc.