@intentius/chant 0.124.97 → 0.124.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit/core.d.ts +29 -0
- package/dist/audit/core.d.ts.map +1 -1
- package/dist/audit/core.js +48 -11
- package/dist/audit/identity.d.ts +27 -0
- package/dist/audit/identity.d.ts.map +1 -0
- package/dist/audit/identity.js +36 -0
- package/dist/audit/report-html.d.ts +3 -1
- package/dist/audit/report-html.d.ts.map +1 -1
- package/dist/audit/report-html.js +1 -1
- package/dist/audit/report-model.d.ts +16 -0
- package/dist/audit/report-model.d.ts.map +1 -1
- package/dist/audit/report-model.js +5 -1
- package/dist/ci-agent.d.ts +17 -0
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +32 -0
- package/dist/ci-comment-allow.d.ts +88 -0
- package/dist/ci-comment-allow.d.ts.map +1 -0
- package/dist/ci-comment-allow.js +178 -0
- package/dist/ci-comment-commands.d.ts +12 -0
- package/dist/ci-comment-commands.d.ts.map +1 -1
- package/dist/ci-comment-commands.js +22 -0
- package/dist/ci-control.d.ts +6 -1
- package/dist/ci-control.d.ts.map +1 -1
- package/dist/ci-control.js +6 -1
- package/dist/ci-product.d.ts +3 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +3 -0
- package/dist/cli/commands/audit.d.ts +3 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +23 -6
- package/dist/cli/commands/import.d.ts +8 -1
- package/dist/cli/commands/import.d.ts.map +1 -1
- package/dist/cli/commands/import.js +31 -6
- package/dist/cli/handlers/agent.d.ts.map +1 -1
- package/dist/cli/handlers/agent.js +12 -2
- package/dist/cli/handlers/pr-comment.d.ts +6 -0
- package/dist/cli/handlers/pr-comment.d.ts.map +1 -1
- package/dist/cli/handlers/pr-comment.js +12 -0
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +53 -6
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +29 -6
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +23 -0
- package/dist/cli/registry.d.ts +8 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/cloud-lister/mask.d.ts +30 -1
- package/dist/cloud-lister/mask.d.ts.map +1 -1
- package/dist/cloud-lister/mask.js +66 -3
- package/dist/components/driver.d.ts +8 -1
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +1 -0
- package/dist/components/product-pipeline.d.ts +23 -1
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +40 -7
- package/dist/components/product-plan.d.ts +20 -0
- package/dist/components/product-plan.d.ts.map +1 -1
- package/dist/components/product-plan.js +11 -1
- package/dist/control/applied.d.ts +8 -1
- package/dist/control/applied.d.ts.map +1 -1
- package/dist/control/applied.js +18 -2
- package/dist/control/dispatch.d.ts +52 -0
- package/dist/control/dispatch.d.ts.map +1 -1
- package/dist/control/dispatch.js +140 -4
- package/dist/control/train.d.ts +198 -0
- package/dist/control/train.d.ts.map +1 -0
- package/dist/control/train.js +294 -0
- package/dist/deep-observation.js +2 -2
- package/dist/floor-table.data.d.ts.map +1 -1
- package/dist/floor-table.data.js +11 -0
- package/dist/graph-detail.d.ts +9 -0
- package/dist/graph-detail.d.ts.map +1 -1
- package/dist/graph-detail.js +38 -13
- package/dist/graph-refs.d.ts +233 -3
- package/dist/graph-refs.d.ts.map +1 -1
- package/dist/graph-refs.js +106 -15
- package/dist/lint/post-synth.d.ts +22 -0
- package/dist/lint/post-synth.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.d.ts +12 -0
- package/dist/lint/rules/declarable-naming-convention.d.ts.map +1 -1
- package/dist/lint/rules/declarable-naming-convention.js +38 -8
- package/dist/lint/rules/imported-source.d.ts +20 -0
- package/dist/lint/rules/imported-source.d.ts.map +1 -0
- package/dist/lint/rules/imported-source.js +27 -0
- package/dist/lint/rules/no-unused-declarable.d.ts.map +1 -1
- package/dist/lint/rules/no-unused-declarable.js +3 -0
- package/dist/op/gate.d.ts +2 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +8 -1
- package/dist/pr-forge-reads.d.ts +17 -0
- package/dist/pr-forge-reads.d.ts.map +1 -1
- package/dist/pr-forge-reads.js +55 -0
- package/dist/release-floors.d.ts +9 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +9 -1
- package/dist/repo-path.d.ts +29 -0
- package/dist/repo-path.d.ts.map +1 -0
- package/dist/repo-path.js +81 -0
- package/dist/sensitive-key.d.ts +23 -0
- package/dist/sensitive-key.d.ts.map +1 -1
- package/dist/sensitive-key.js +37 -0
- package/dist/terraform/hcl2json.d.ts +7 -0
- package/dist/terraform/hcl2json.d.ts.map +1 -1
- package/dist/terraform/hcl2json.js +7 -0
- package/dist/wave-runtime.mjs +352 -345
- package/dist/workspace/catalog-edges.d.ts +147 -0
- package/dist/workspace/catalog-edges.d.ts.map +1 -0
- package/dist/workspace/catalog-edges.js +461 -0
- package/dist/workspace/compose-graph.d.ts +73 -3
- package/dist/workspace/compose-graph.d.ts.map +1 -1
- package/dist/workspace/declaration.d.ts +2 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +1 -0
- package/dist/workspace/declaration.schema.json +6 -0
- package/dist/workspace/discover.d.ts +134 -0
- package/dist/workspace/discover.d.ts.map +1 -0
- package/dist/workspace/discover.js +372 -0
- package/dist/workspace/graph-cli.d.ts +20 -0
- package/dist/workspace/graph-cli.d.ts.map +1 -1
- package/dist/workspace/graph-cli.js +178 -20
- package/dist/workspace/graph.schema.json +195 -2
- package/dist/workspace/release-train.d.ts +214 -3
- package/dist/workspace/release-train.d.ts.map +1 -1
- package/dist/workspace/release-train.js +552 -16
- package/dist/workspace/repo-ref.d.ts +14 -0
- package/dist/workspace/repo-ref.d.ts.map +1 -1
- package/dist/workspace/repo-ref.js +26 -1
- package/dist/workspace/workspace-gates.d.ts +24 -0
- package/dist/workspace/workspace-gates.d.ts.map +1 -1
- package/dist/workspace/workspace-gates.js +29 -5
- package/dist/workspace/workspace-ledger.d.ts +31 -5
- package/dist/workspace/workspace-ledger.d.ts.map +1 -1
- package/dist/workspace/workspace-ledger.js +2 -1
- package/dist/workspace/workspace-run.d.ts +14 -0
- package/dist/workspace/workspace-run.d.ts.map +1 -1
- package/dist/workspace/workspace-run.js +2 -2
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +33 -8
- package/package.json +1 -1
- package/src/audit/core.test.ts +64 -1
- package/src/audit/core.ts +75 -10
- package/src/audit/identity.test.ts +31 -0
- package/src/audit/identity.ts +43 -0
- package/src/audit/report-html.ts +4 -2
- package/src/audit/report-model.ts +21 -1
- package/src/ci-agent.test.ts +32 -0
- package/src/ci-agent.ts +42 -0
- package/src/ci-comment-allow.test.ts +380 -0
- package/src/ci-comment-allow.ts +184 -0
- package/src/ci-comment-commands.ts +25 -0
- package/src/ci-control.ts +42 -0
- package/src/ci-product.ts +3 -0
- package/src/cli/commands/audit-parser-notice.test.ts +74 -0
- package/src/cli/commands/audit.test.ts +12 -0
- package/src/cli/commands/audit.ts +25 -7
- package/src/cli/commands/import-layout.test.ts +2 -1
- package/src/cli/commands/import.ts +29 -6
- package/src/cli/handlers/agent.ts +13 -2
- package/src/cli/handlers/pr-comment.ts +12 -0
- package/src/cli/handlers/promote.test.ts +68 -0
- package/src/cli/handlers/promote.ts +52 -6
- package/src/cli/main.test.ts +5 -0
- package/src/cli/main.ts +29 -6
- package/src/cli/parse-args.ts +18 -0
- package/src/cli/registry.ts +8 -0
- package/src/cloud-lister/kubernetes.k3d.e2e.test.ts +104 -0
- package/src/cloud-lister/mask-references.test.ts +132 -0
- package/src/cloud-lister/mask.ts +68 -3
- package/src/components/driver.ts +9 -1
- package/src/components/product-pipeline.ts +57 -7
- package/src/components/product-plan.ts +27 -2
- package/src/control/applied.ts +33 -3
- package/src/control/dispatch.ts +156 -5
- package/src/control/train.test.ts +215 -0
- package/src/control/train.ts +413 -0
- package/src/deep-observation.ts +2 -2
- package/src/floor-table.data.ts +6 -0
- package/src/graph-detail.ts +37 -12
- package/src/graph-refs.test.ts +45 -1
- package/src/graph-refs.ts +321 -14
- package/src/lint/post-synth.ts +20 -0
- package/src/lint/rules/declarable-naming-convention.test.ts +35 -1
- package/src/lint/rules/declarable-naming-convention.ts +35 -8
- package/src/lint/rules/imported-source.test.ts +22 -0
- package/src/lint/rules/imported-source.ts +31 -0
- package/src/lint/rules/no-unused-declarable.test.ts +16 -0
- package/src/lint/rules/no-unused-declarable.ts +7 -0
- package/src/op/gate.ts +10 -2
- package/src/pr-forge-reads.ts +62 -0
- package/src/release-floors.ts +13 -1
- package/src/repo-path.test.ts +72 -0
- package/src/repo-path.ts +103 -0
- package/src/sensitive-key.ts +38 -0
- package/src/terraform/hcl2json.ts +8 -0
- package/src/workspace/application-set.e2e.test.ts +405 -0
- package/src/workspace/catalog-edges.ts +507 -0
- package/src/workspace/ci-green-workflow.test.ts +2 -2
- package/src/workspace/cluster-join.e2e.test.ts +150 -0
- package/src/workspace/compose-graph.ts +74 -5
- package/src/workspace/declaration.schema.json +6 -0
- package/src/workspace/declaration.ts +3 -0
- package/src/workspace/discover.e2e.test.ts +122 -0
- package/src/workspace/discover.test.ts +225 -0
- package/src/workspace/discover.ts +406 -0
- package/src/workspace/external-secret-catalog.e2e.test.ts +98 -0
- package/src/workspace/external-secret-catalog.test.ts +142 -0
- package/src/workspace/graph-cli.ts +207 -21
- package/src/workspace/graph-contract.test.ts +92 -0
- package/src/workspace/graph.schema.json +195 -2
- package/src/workspace/helm-references.e2e.test.ts +135 -0
- package/src/workspace/identity-annotation-catalog.e2e.test.ts +91 -0
- package/src/workspace/identity-annotation-catalog.test.ts +139 -0
- package/src/workspace/release-train-repos.test.ts +304 -0
- package/src/workspace/release-train.test.ts +296 -0
- package/src/workspace/release-train.ts +631 -16
- package/src/workspace/repo-ref.ts +26 -1
- package/src/workspace/runs-on.test.ts +45 -0
- package/src/workspace/workspace-gates.ts +48 -5
- package/src/workspace/workspace-ledger.ts +28 -5
- package/src/workspace/workspace-run.test.ts +1 -1
- package/src/workspace/workspace-run.ts +2 -2
- package/src/yaml.test.ts +96 -8
- package/src/yaml.ts +36 -8
|
@@ -19,6 +19,14 @@ export interface Hcl2Json {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export class Hcl2JsonNotInstalled extends Error {
|
|
22
|
+
/**
|
|
23
|
+
* The npm package that is missing. `chant audit` reads this property on any
|
|
24
|
+
* error an entities parser throws (see `parserPackageOf` in `audit/core`),
|
|
25
|
+
* so a lexicon reports a missing optional parser by setting it, with no
|
|
26
|
+
* import of this class.
|
|
27
|
+
*/
|
|
28
|
+
readonly parserPackage = "@cdktn/hcl2json";
|
|
29
|
+
|
|
22
30
|
constructor(cause: unknown) {
|
|
23
31
|
super(
|
|
24
32
|
"Terraform carve-out needs the HCL parser, which is not installed.\n" +
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApplicationSet expansion end to end (#5102): `chant workspace graph
|
|
3
|
+
* --discover` over a scratch git repository with Argo CD manifests, read
|
|
4
|
+
* through the k8s lexicon installed in this checkout. Each fixture is its own
|
|
5
|
+
* `git init` in a scratch location with an origin the Applications name, so
|
|
6
|
+
* nothing writes into this repository's git directory. Nothing is removed.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { afterAll, beforeAll, describe, expect, test } from "vitest";
|
|
10
|
+
import { contract, git, scratchDir, writeFiles } from "./__fixtures__/contract-repo";
|
|
11
|
+
import { CACHE_DIR_ENV } from "./graph-cache";
|
|
12
|
+
import { workspaceGraph, type GraphDocument } from "./graph-cli";
|
|
13
|
+
import schema from "./graph.schema.json";
|
|
14
|
+
|
|
15
|
+
const TIMEOUT = 240_000;
|
|
16
|
+
const { expectValid } = contract(schema);
|
|
17
|
+
|
|
18
|
+
let cacheBefore: string | undefined;
|
|
19
|
+
beforeAll(() => {
|
|
20
|
+
cacheBefore = process.env[CACHE_DIR_ENV];
|
|
21
|
+
process.env[CACHE_DIR_ENV] = scratchDir("chant-appset-cache-");
|
|
22
|
+
});
|
|
23
|
+
afterAll(() => {
|
|
24
|
+
if (cacheBefore === undefined) delete process.env[CACHE_DIR_ENV];
|
|
25
|
+
else process.env[CACHE_DIR_ENV] = cacheBefore;
|
|
26
|
+
// The scratch directories are left in place for the run's cleanup.
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const ORIGIN = "https://example.com/estate.git";
|
|
30
|
+
|
|
31
|
+
const secret = (name: string, cloud: string) => `---
|
|
32
|
+
apiVersion: v1
|
|
33
|
+
kind: Secret
|
|
34
|
+
metadata:
|
|
35
|
+
name: ${name}
|
|
36
|
+
namespace: argocd
|
|
37
|
+
labels:
|
|
38
|
+
argocd.argoproj.io/secret-type: cluster
|
|
39
|
+
cloud: ${cloud}
|
|
40
|
+
stringData:
|
|
41
|
+
name: ${name}
|
|
42
|
+
server: https://${name}.example.com
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
const CLUSTERS_SET = `apiVersion: argoproj.io/v1alpha1
|
|
46
|
+
kind: ApplicationSet
|
|
47
|
+
metadata:
|
|
48
|
+
name: app
|
|
49
|
+
namespace: argocd
|
|
50
|
+
spec:
|
|
51
|
+
goTemplate: true
|
|
52
|
+
generators:
|
|
53
|
+
- clusters:
|
|
54
|
+
selector:
|
|
55
|
+
matchLabels:
|
|
56
|
+
cloud: gke
|
|
57
|
+
template:
|
|
58
|
+
metadata:
|
|
59
|
+
name: "app-{{ .name }}"
|
|
60
|
+
spec:
|
|
61
|
+
project: default
|
|
62
|
+
source:
|
|
63
|
+
repoURL: ${ORIGIN}
|
|
64
|
+
path: clusters/{{ .name }}/app
|
|
65
|
+
destination:
|
|
66
|
+
server: "{{ .server }}"
|
|
67
|
+
namespace: app
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
const LIST_SET = `apiVersion: argoproj.io/v1alpha1
|
|
71
|
+
kind: ApplicationSet
|
|
72
|
+
metadata:
|
|
73
|
+
name: tools
|
|
74
|
+
namespace: argocd
|
|
75
|
+
spec:
|
|
76
|
+
generators:
|
|
77
|
+
- list:
|
|
78
|
+
elements:
|
|
79
|
+
- tool: lint
|
|
80
|
+
cluster: a
|
|
81
|
+
- tool: docs
|
|
82
|
+
cluster: b
|
|
83
|
+
template:
|
|
84
|
+
metadata:
|
|
85
|
+
name: "tools-{{tool}}"
|
|
86
|
+
spec:
|
|
87
|
+
project: default
|
|
88
|
+
source:
|
|
89
|
+
repoURL: ${ORIGIN}
|
|
90
|
+
path: tools/{{tool}}
|
|
91
|
+
destination:
|
|
92
|
+
name: "{{cluster}}"
|
|
93
|
+
namespace: tools
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
const GIT_SET = `apiVersion: argoproj.io/v1alpha1
|
|
97
|
+
kind: ApplicationSet
|
|
98
|
+
metadata:
|
|
99
|
+
name: dirs
|
|
100
|
+
namespace: argocd
|
|
101
|
+
spec:
|
|
102
|
+
generators:
|
|
103
|
+
- git:
|
|
104
|
+
repoURL: ${ORIGIN}
|
|
105
|
+
revision: HEAD
|
|
106
|
+
directories:
|
|
107
|
+
- path: apps/*
|
|
108
|
+
template:
|
|
109
|
+
metadata:
|
|
110
|
+
name: "{{path.basename}}"
|
|
111
|
+
spec:
|
|
112
|
+
project: default
|
|
113
|
+
source:
|
|
114
|
+
repoURL: ${ORIGIN}
|
|
115
|
+
path: "{{path}}"
|
|
116
|
+
destination:
|
|
117
|
+
name: a
|
|
118
|
+
namespace: default
|
|
119
|
+
`;
|
|
120
|
+
|
|
121
|
+
const SET = "argo/argo/applicationSetApp";
|
|
122
|
+
const GENERATES = "k8s:K8s::Argo::ApplicationSet:spec.generators";
|
|
123
|
+
const PATH_RULE = "k8s:K8s::Argo::Application:spec.source.path";
|
|
124
|
+
const SELECTED = "k8s:K8s::Argo::ApplicationSet:generators[].clusters";
|
|
125
|
+
const secretId = (name: string) => `argo/argo/secret${name.toUpperCase()}`;
|
|
126
|
+
|
|
127
|
+
function result(doc: GraphDocument): Extract<GraphDocument, { nodes: unknown }> {
|
|
128
|
+
if ("error" in doc) throw new Error(`${doc.error.code}: ${doc.error.message}`);
|
|
129
|
+
return doc;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function read(files: Record<string, string>) {
|
|
133
|
+
const root = scratchDir("chant-appset-fx-");
|
|
134
|
+
writeFiles(root, files);
|
|
135
|
+
git(root, "init", "-q");
|
|
136
|
+
git(root, "remote", "add", "origin", ORIGIN);
|
|
137
|
+
const g = result((await workspaceGraph({ cwd: root, discover: true, noCache: false, catalog: true, args: { detail: 3 } as never })).doc);
|
|
138
|
+
expectValid(g);
|
|
139
|
+
return g;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
describe("ApplicationSet expansion (#5102)", () => {
|
|
143
|
+
test(
|
|
144
|
+
"a clusters generator makes one Application per selected Secret, with its path and an edge to the Secret",
|
|
145
|
+
async () => {
|
|
146
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke") + secret("b", "eks"), "argo/appset.yaml": CLUSTERS_SET, "clusters/a/app/kustomization.yaml": "resources: []\n" });
|
|
147
|
+
const generated = g.nodes.filter((n) => n.generatedBy);
|
|
148
|
+
expect(generated.map((n) => n.id)).toEqual([`${SET}/app-a`]);
|
|
149
|
+
const app = generated[0];
|
|
150
|
+
expect(app.kind).toBe("K8s::Argo::Application");
|
|
151
|
+
expect((app.attrs.spec as { source: { path: string } }).source.path).toBe("clusters/a/app");
|
|
152
|
+
expect(app.generatedBy).toMatchObject({ node: SET, rule: GENERATES, generator: "clusters", cluster: secretId("a") });
|
|
153
|
+
expect(app.generatedBy!.params).toMatchObject({ name: "a", server: "https://a.example.com", "metadata.labels.cloud": "gke" });
|
|
154
|
+
const edges = g.edges.map((e) => `${e.from} > ${e.to} ${e.rule ?? ""}`);
|
|
155
|
+
expect(edges).toContain(`${SET} > ${SET}/app-a ${GENERATES}`);
|
|
156
|
+
// The generator selected Secret a, so the edge is under its own rule, and the destination rule draws no second one.
|
|
157
|
+
expect(edges.filter((e) => e.startsWith(`${SET}/app-a > `))).toEqual([`${SET}/app-a > ${secretId("a")} ${SELECTED}`]);
|
|
158
|
+
expect(g.catalog?.rules[SELECTED]).toMatchObject({ lexicon: "k8s", from: "K8s::Argo::ApplicationSet", targetKinds: ["K8s::Core::Secret"], label: "deploys to" });
|
|
159
|
+
expect(g.nodes.find((n) => n.id === SET)?.expansion).toEqual({ rule: GENERATES, generated: 1, notExpanded: [] });
|
|
160
|
+
expect((g.dangling ?? []).filter((d) => d.rule === PATH_RULE)).toEqual([]);
|
|
161
|
+
},
|
|
162
|
+
TIMEOUT,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
test(
|
|
166
|
+
"a generated Application joins the Secret it was selected for across members and namespaces; a hand-written one with no namespace does not",
|
|
167
|
+
async () => {
|
|
168
|
+
const unplaced = CLUSTERS_SET.replace(" namespace: argocd\n", "");
|
|
169
|
+
const hand = `apiVersion: argoproj.io/v1alpha1
|
|
170
|
+
kind: Application
|
|
171
|
+
metadata:
|
|
172
|
+
name: web
|
|
173
|
+
spec:
|
|
174
|
+
project: default
|
|
175
|
+
source:
|
|
176
|
+
repoURL: ${ORIGIN}
|
|
177
|
+
path: clusters/a/app
|
|
178
|
+
destination:
|
|
179
|
+
name: a
|
|
180
|
+
namespace: web
|
|
181
|
+
`;
|
|
182
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke"), "apps/appset.yaml": unplaced, "apps/web.yaml": hand, "clusters/a/app/x.yaml": "" });
|
|
183
|
+
const edges = g.edges.map((e) => `${e.from} > ${e.to} ${e.rule ?? ""}`);
|
|
184
|
+
expect(edges).toContain(`apps/apps/applicationSetApp/app-a > ${secretId("a")} ${SELECTED}`);
|
|
185
|
+
expect(edges.filter((e) => e.startsWith("apps/apps/applicationWeb > "))).toEqual([]);
|
|
186
|
+
},
|
|
187
|
+
TIMEOUT,
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
test(
|
|
191
|
+
"a missing $values file is dangling once, under the helm rule, on a hand-written Application and on a generated one (#5094)",
|
|
192
|
+
async () => {
|
|
193
|
+
const sources = (name: string) => ` - chart: c
|
|
194
|
+
repoURL: https://charts.example.com
|
|
195
|
+
targetRevision: 1.0.0
|
|
196
|
+
helm:
|
|
197
|
+
valueFiles:
|
|
198
|
+
- $values/helm/${name}.yaml
|
|
199
|
+
- repoURL: ${ORIGIN}
|
|
200
|
+
targetRevision: main
|
|
201
|
+
ref: values
|
|
202
|
+
`;
|
|
203
|
+
const hand = `apiVersion: argoproj.io/v1alpha1
|
|
204
|
+
kind: Application
|
|
205
|
+
metadata:
|
|
206
|
+
name: web
|
|
207
|
+
namespace: argocd
|
|
208
|
+
spec:
|
|
209
|
+
project: default
|
|
210
|
+
sources:
|
|
211
|
+
${sources("x")} destination:
|
|
212
|
+
name: a
|
|
213
|
+
namespace: web
|
|
214
|
+
`;
|
|
215
|
+
const set = `apiVersion: argoproj.io/v1alpha1
|
|
216
|
+
kind: ApplicationSet
|
|
217
|
+
metadata:
|
|
218
|
+
name: vals
|
|
219
|
+
namespace: argocd
|
|
220
|
+
spec:
|
|
221
|
+
goTemplate: true
|
|
222
|
+
generators:
|
|
223
|
+
- clusters:
|
|
224
|
+
selector:
|
|
225
|
+
matchLabels:
|
|
226
|
+
cloud: gke
|
|
227
|
+
template:
|
|
228
|
+
metadata:
|
|
229
|
+
name: "vals-{{ .name }}"
|
|
230
|
+
spec:
|
|
231
|
+
project: default
|
|
232
|
+
sources:
|
|
233
|
+
${sources("{{ .name }}").replace(/^(?=.)/gm, " ")} destination:
|
|
234
|
+
server: "{{ .server }}"
|
|
235
|
+
namespace: vals
|
|
236
|
+
`;
|
|
237
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke"), "argo/web.yaml": hand, "argo/vals.yaml": set });
|
|
238
|
+
const values = (g.dangling ?? []).filter((d) => d.value.includes("helm/")).map((d) => `${d.from} ${d.rule} ${d.value}`);
|
|
239
|
+
expect(values).toEqual([
|
|
240
|
+
"argo/argo/applicationSetVals/vals-a k8s:K8s::Argo::Application:helmReferences.valuesFiles[] helm/a.yaml",
|
|
241
|
+
"argo/argo/applicationWeb k8s:K8s::Argo::Application:helmReferences.valuesFiles[] helm/x.yaml",
|
|
242
|
+
]);
|
|
243
|
+
},
|
|
244
|
+
TIMEOUT,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
test(
|
|
248
|
+
"a generated Application's chart and values file join the Helm graph, and the file's extraObjects are nodes other objects join (#5094)",
|
|
249
|
+
async () => {
|
|
250
|
+
const set = `apiVersion: argoproj.io/v1alpha1
|
|
251
|
+
kind: ApplicationSet
|
|
252
|
+
metadata:
|
|
253
|
+
name: eso
|
|
254
|
+
namespace: argocd
|
|
255
|
+
spec:
|
|
256
|
+
goTemplate: true
|
|
257
|
+
generators:
|
|
258
|
+
- clusters:
|
|
259
|
+
selector:
|
|
260
|
+
matchLabels:
|
|
261
|
+
cloud: gke
|
|
262
|
+
template:
|
|
263
|
+
metadata:
|
|
264
|
+
name: "eso-{{ .name }}"
|
|
265
|
+
spec:
|
|
266
|
+
project: default
|
|
267
|
+
sources:
|
|
268
|
+
- chart: external-secrets
|
|
269
|
+
repoURL: https://charts.example.com
|
|
270
|
+
targetRevision: 2.0.0
|
|
271
|
+
helm:
|
|
272
|
+
valueFiles:
|
|
273
|
+
- $values/clusters/{{ .name }}/helm/eso.yaml
|
|
274
|
+
- repoURL: ${ORIGIN}
|
|
275
|
+
targetRevision: main
|
|
276
|
+
ref: values
|
|
277
|
+
destination:
|
|
278
|
+
server: "{{ .server }}"
|
|
279
|
+
namespace: external-secrets
|
|
280
|
+
`;
|
|
281
|
+
const values = `extraObjects:
|
|
282
|
+
- apiVersion: external-secrets.io/v1
|
|
283
|
+
kind: ClusterSecretStore
|
|
284
|
+
metadata:
|
|
285
|
+
name: store-a
|
|
286
|
+
spec:
|
|
287
|
+
provider:
|
|
288
|
+
gcpsm:
|
|
289
|
+
projectID: project-a
|
|
290
|
+
`;
|
|
291
|
+
const externalSecret = `apiVersion: external-secrets.io/v1
|
|
292
|
+
kind: ExternalSecret
|
|
293
|
+
metadata:
|
|
294
|
+
name: token
|
|
295
|
+
namespace: web
|
|
296
|
+
spec:
|
|
297
|
+
secretStoreRef:
|
|
298
|
+
kind: ClusterSecretStore
|
|
299
|
+
name: store-a
|
|
300
|
+
data:
|
|
301
|
+
- secretKey: token
|
|
302
|
+
remoteRef:
|
|
303
|
+
key: token
|
|
304
|
+
`;
|
|
305
|
+
// A hand-written Application with a values file puts a helm node in the graph, so the helm lexicon's catalog, which makes chart nodes, is loaded.
|
|
306
|
+
const hand = `apiVersion: argoproj.io/v1alpha1
|
|
307
|
+
kind: Application
|
|
308
|
+
metadata:
|
|
309
|
+
name: web
|
|
310
|
+
namespace: argocd
|
|
311
|
+
spec:
|
|
312
|
+
project: default
|
|
313
|
+
sources:
|
|
314
|
+
- chart: web
|
|
315
|
+
repoURL: https://charts.example.com
|
|
316
|
+
targetRevision: 1.0.0
|
|
317
|
+
helm:
|
|
318
|
+
valueFiles:
|
|
319
|
+
- $values/helm/web.yaml
|
|
320
|
+
- repoURL: ${ORIGIN}
|
|
321
|
+
targetRevision: main
|
|
322
|
+
ref: values
|
|
323
|
+
destination:
|
|
324
|
+
name: a
|
|
325
|
+
namespace: web
|
|
326
|
+
`;
|
|
327
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke"), "argo/eso.yaml": set, "argo/web.yaml": hand, "helm/web.yaml": "replicas: 1\n", "clusters/a/helm/eso.yaml": values, "web/es.yaml": externalSecret });
|
|
328
|
+
const app = "argo/argo/applicationSetEso/eso-a";
|
|
329
|
+
const valuesNode = `argo/argo/applicationSetEso/values/clusters/a/helm/eso.yaml`;
|
|
330
|
+
const store = `${valuesNode}/clusterSecretStoreStoreA`;
|
|
331
|
+
expect((g.nodes.find((n) => n.id === app)?.attrs as { helmReferences?: unknown }).helmReferences).toEqual({
|
|
332
|
+
charts: [{ repo: "https://charts.example.com", chart: "external-secrets", version: "2.0.0", valuesFiles: ["clusters/a/helm/eso.yaml"] }],
|
|
333
|
+
valuesFiles: ["clusters/a/helm/eso.yaml"],
|
|
334
|
+
});
|
|
335
|
+
const values_ = g.nodes.find((n) => n.id === valuesNode);
|
|
336
|
+
expect(values_).toMatchObject({ kind: "Helm::Values", lexicon: "helm", member: "argo", generatedBy: { node: app, generator: "file" } });
|
|
337
|
+
expect(values_?.attrs).toMatchObject({ path: "clusters/a/helm/eso.yaml", charts: [{ repo: "https://charts.example.com", chart: "external-secrets", version: "2.0.0" }] });
|
|
338
|
+
expect(g.nodes.find((n) => n.id === store)).toMatchObject({ kind: "K8s::ExternalSecrets::ClusterSecretStore", lexicon: "k8s", member: "argo" });
|
|
339
|
+
const edges = g.edges.map((e) => `${e.from} > ${e.to} ${e.rule ?? ""}`);
|
|
340
|
+
expect(edges).toContain(`${app} > ${valuesNode} k8s:K8s::Argo::Application:helmReferences.valuesFiles[]`);
|
|
341
|
+
expect(edges.some((e) => e.startsWith(`${app} > `) && e.includes("chart:charts.example.com/external-secrets@2.0.0"))).toBe(true);
|
|
342
|
+
expect(edges.some((e) => e.startsWith(`${valuesNode} > `) && e.endsWith("helm:Helm::Values:charts"))).toBe(true);
|
|
343
|
+
expect(edges.filter((e) => e.startsWith("web/web/externalSecretToken > ") && e.includes(store))).toHaveLength(1);
|
|
344
|
+
expect((g.dangling ?? []).filter((d) => d.value.includes("eso.yaml"))).toEqual([]);
|
|
345
|
+
expectValid(g);
|
|
346
|
+
},
|
|
347
|
+
TIMEOUT,
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
test(
|
|
351
|
+
"a two-element list generator makes two Applications",
|
|
352
|
+
async () => {
|
|
353
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke") + secret("b", "eks"), "argo/tools.yaml": LIST_SET, "tools/lint/x.yaml": "", "tools/docs/x.yaml": "" });
|
|
354
|
+
const generated = g.nodes.filter((n) => n.generatedBy).map((n) => `${n.id} ${n.generatedBy!.params.tool}`);
|
|
355
|
+
expect(generated).toEqual(["argo/argo/applicationSetTools/tools-docs docs", "argo/argo/applicationSetTools/tools-lint lint"]);
|
|
356
|
+
const toSecrets = g.edges.filter((e) => e.rule === "k8s:K8s::Argo::Application:spec.destination.name").map((e) => `${e.from} > ${e.to}`);
|
|
357
|
+
expect(toSecrets).toEqual([`argo/argo/applicationSetTools/tools-docs > ${secretId("b")}`, `argo/argo/applicationSetTools/tools-lint > ${secretId("a")}`]);
|
|
358
|
+
},
|
|
359
|
+
TIMEOUT,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
test(
|
|
363
|
+
"a selected cluster whose path is missing puts the path in dangling, naming the ApplicationSet and the cluster",
|
|
364
|
+
async () => {
|
|
365
|
+
const g = await read({
|
|
366
|
+
"argo/clusters.yaml": secret("a", "gke") + secret("b", "eks") + secret("c", "gke"),
|
|
367
|
+
"argo/appset.yaml": CLUSTERS_SET,
|
|
368
|
+
"clusters/a/app/kustomization.yaml": "resources: []\n",
|
|
369
|
+
});
|
|
370
|
+
expect(g.nodes.filter((n) => n.generatedBy).map((n) => n.id)).toEqual([`${SET}/app-a`, `${SET}/app-c`]);
|
|
371
|
+
expect((g.dangling ?? []).filter((d) => d.rule === PATH_RULE)).toEqual([
|
|
372
|
+
{ from: `${SET}/app-c`, kind: "ref", path: "spec.source.path", value: "clusters/c/app", member: "argo", rule: PATH_RULE, through: SET, cluster: secretId("c") },
|
|
373
|
+
]);
|
|
374
|
+
},
|
|
375
|
+
TIMEOUT,
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
test(
|
|
379
|
+
"a git generator keeps the ApplicationSet node and notes that it is not expanded",
|
|
380
|
+
async () => {
|
|
381
|
+
const g = await read({ "argo/clusters.yaml": secret("a", "gke"), "argo/dirs.yaml": GIT_SET });
|
|
382
|
+
expect(g.nodes.filter((n) => n.generatedBy)).toEqual([]);
|
|
383
|
+
const set = g.nodes.find((n) => n.id === "argo/argo/applicationSetDirs");
|
|
384
|
+
expect(set?.kind).toBe("K8s::Argo::ApplicationSet");
|
|
385
|
+
expect(set?.expansion).toEqual({ rule: GENERATES, generated: 0, notExpanded: ["generators[0]: the git generator is not expanded"] });
|
|
386
|
+
},
|
|
387
|
+
TIMEOUT,
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
test(
|
|
391
|
+
"at --detail 0 a generated Application is drawn as its ApplicationSet's stack",
|
|
392
|
+
async () => {
|
|
393
|
+
const root = scratchDir("chant-appset-fx-");
|
|
394
|
+
writeFiles(root, { "argo/clusters.yaml": secret("a", "gke"), "argo/appset.yaml": CLUSTERS_SET, "clusters/a/app/x.yaml": "" });
|
|
395
|
+
git(root, "init", "-q");
|
|
396
|
+
git(root, "remote", "add", "origin", ORIGIN);
|
|
397
|
+
const g = result((await workspaceGraph({ cwd: root, discover: true, noCache: false, catalog: true, args: { detail: 0 } as never })).doc);
|
|
398
|
+
expectValid(g);
|
|
399
|
+
expect(g.nodes.some((n) => n.generatedBy)).toBe(false);
|
|
400
|
+
expect(g.nodes.some((n) => n.id.includes("app-a"))).toBe(false);
|
|
401
|
+
expect(g.edges.some((e) => e.rule === GENERATES)).toBe(false);
|
|
402
|
+
},
|
|
403
|
+
TIMEOUT,
|
|
404
|
+
);
|
|
405
|
+
});
|