Open SomniVertix opened 3 months ago
@SomniVertix - thanks for raising this. This is an issue related to CUE calculating the dependencies between parts of the configuration. In the first example it is able to detect a relationship between the basic-print
and read
tasks. In the second, it can't see the dependency because it is happening "at the same level" as the read
field. The solution (until we come up with a better way of discovering such dependencies is to wrap the loop version in a field (name does not matter):
exec cue cmd gen-argocd-cluster-specs
stdout 'basic: internal-shared-dev-east'
stdout 'loop: internal-shared-qa-east'
-- x_tool.cue --
package kubernetesbase
import (
"encoding/yaml"
"tool/file"
"tool/cli"
)
command: "gen-argocd-cluster-specs": {
read: file.Read & {
filename: "./dist/low-clusters.gen.yml"
contents: string
}
// wrap the tasks in an outer field
something: {
v: yaml.Unmarshal(read.contents)
"basic-print": cli.Print & {
text: "basic: \(v[0].metadata.name)"
}
for i, spec in yaml.Unmarshal(read.contents) {
"print-\(i)": cli.Print & {
text: "loop: \(spec.metadata.name)"
}
}
}
}
-- dist/low-clusters.gen.yml --
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: int
name: internal-shared-dev-east
stringData:
config: |2-
some multiline string here
name: internal-shared-dev-east
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: west
infrastructure_environment: low
infrastructure_location: int
name: internal-shared-dev-west
stringData:
config: |2-
some multiline string here
name: internal-shared-dev-west
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: int
name: internal-shared-qa-east
stringData:
config: |2-
some multiline string here
name: internal-shared-qa-east
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: west
infrastructure_environment: low
infrastructure_location: int
name: internal-shared-qa-west
stringData:
config: |2-
some multiline string here
name: internal-shared-qa-west
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: int
name: internal-pega-dev-east
stringData:
config: |2-
some multiline string here
name: internal-pega-dev-east
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: west
infrastructure_environment: low
infrastructure_location: int
name: internal-pega-dev-west
stringData:
config: |2-
some multiline string here
name: internal-pega-dev-west
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: int
name: internal-pega-qa-east
stringData:
config: |2-
some multiline string here
name: internal-pega-qa-east
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: west
infrastructure_environment: low
infrastructure_location: int
name: internal-pega-qa-west
stringData:
config: |2-
some multiline string here
name: internal-pega-qa-west
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: oci
name: oci-low-ash-eck
stringData:
config: |2-
some multiline string here
name: oci-low-ash-eck
server: some string here
type: Opaque
- ApiVersion: v1
kind: Secret
metadata:
labels:
argocd.argoproj.io/secret-type: cluster
region: east
infrastructure_environment: low
infrastructure_location: oci
name: oci-low-ash-infra
stringData:
config: |2-
some multiline string here
name: oci-low-ash-infra
server: some string here
type: Opaque
Re-opening, because as @mvdan points out I haven't linked to a specific issue whether the dependency "problem" outlined above is going to be fixed. We should have such an issue.
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes - this was tested on v0.8.0 as well. However, in v0.8.0 it COMPLETELY breaks, not just in the ways that I mentioned before. This was also discussed on slack.
What did you do?
When running the following:
low-clusters.gen.yml type.cue
I am able to get the output:
internal-shared-dev-east
as expected. However, when running in the loop:I get the following error:
Note: When I try this on v0.8.0, it errors out with the same error even in the non-loop example. I tried on master as well, and that produced the same results at v0.7.1.
Reference slack discussion