@otwld/nx-argo 0.0.9 → 0.0.11
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/CHANGELOG.md +7 -0
- package/README.md +4 -3
- package/package.json +1 -1
- package/src/executors/validate-application-set/validate-application-set.js +8 -7
- package/src/generators/stack-project/schema.d.ts +0 -2
- package/src/generators/stack-project/schema.json +1 -2
- package/src/generators/stack-project/stack-project.js +3 -7
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -46,7 +46,6 @@ The canonical metadata shape is:
|
|
|
46
46
|
"staging": "values-staging.yaml",
|
|
47
47
|
"production": "values-production.yaml",
|
|
48
48
|
"preview": "values-preview.yaml",
|
|
49
|
-
"pullRequest": "values-pr.yaml",
|
|
50
49
|
},
|
|
51
50
|
"applications": { "services.api": "api" },
|
|
52
51
|
},
|
|
@@ -59,13 +58,15 @@ The canonical metadata shape is:
|
|
|
59
58
|
the generated values files. `chartPath`, repository identity, namespace prefix,
|
|
60
59
|
and all file paths are explicit; the generator does not assume a frontend,
|
|
61
60
|
backend, web, or repository name. The pull-request policy requires repository
|
|
62
|
-
owner/name and
|
|
61
|
+
owner/name and uses `values-preview.yaml` as its final Helm value file. Its
|
|
62
|
+
ApplicationSet resolves the chart and values sources from the same `preview/pr-N`
|
|
63
|
+
snapshot revision.
|
|
63
64
|
|
|
64
65
|
## Contracts
|
|
65
66
|
|
|
66
67
|
`validate-application` validates Application kind and spec. Its optional `finalValueFile` requires that basename to end each declared Helm `valueFiles` list; image locks are never implied.
|
|
67
68
|
|
|
68
|
-
`validate-application-set` validates ApplicationSet kind, spec, template, and template spec. By default it imposes no provider rules. With `policy: github-pr-preview`, it also requires a pull request generator, literal template project, automated `enabled`, `prune`, and `selfHeal`, no `preserveResourcesOnDeletion`, and
|
|
69
|
+
`validate-application-set` validates ApplicationSet kind, spec, template, and template spec. By default it imposes no provider rules. With `policy: github-pr-preview`, it also requires a pull request generator, literal template project, automated `enabled`, `prune`, and `selfHeal`, no `preserveResourcesOnDeletion`, and `values-preview.yaml` as the final Helm values file.
|
|
69
70
|
|
|
70
71
|
`validate-image-lock` uses canonical `image.repository`, `image.digest`, `artifact.service`, and `artifact.sourceRevision` paths unless mappings are supplied. `write-image-lock` requires explicit mapping paths. A pending lock contains exactly empty values; a completed lock has a nonempty repository, service, source revision, and SHA-256 digest. Writes require an existing project-local file, complete valid pending locks, and are idempotent for identical source-revision values.
|
|
71
72
|
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ function validateGithubPrPreview(spec, templateSpec, filePath) {
|
|
|
34
34
|
automated['prune'] !== true ||
|
|
35
35
|
automated['selfHeal'] !== true ||
|
|
36
36
|
(0, shared_1.getPath)(spec, ['syncPolicy', 'preserveResourcesOnDeletion']) === true ||
|
|
37
|
-
!
|
|
37
|
+
!hasPreviewValuesAsFinalValue(templateSpec)) {
|
|
38
38
|
throw new Error(`[nx-argo] Invalid github-pr-preview ApplicationSet policy: ${filePath}`);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -47,8 +47,8 @@ function containsPullRequestGenerator(value) {
|
|
|
47
47
|
((0, shared_1.isMap)(value['pullRequest']) ||
|
|
48
48
|
Object.values(value).some(containsPullRequestGenerator)));
|
|
49
49
|
}
|
|
50
|
-
/** Requires
|
|
51
|
-
function
|
|
50
|
+
/** Requires the canonical preview values file as the final Helm values file. */
|
|
51
|
+
function hasPreviewValuesAsFinalValue(templateSpec) {
|
|
52
52
|
const sources = [
|
|
53
53
|
...((0, shared_1.isMap)(templateSpec['source']) ? [templateSpec['source']] : []),
|
|
54
54
|
...(Array.isArray(templateSpec['sources'])
|
|
@@ -59,11 +59,12 @@ function hasPrLockAsFinalValue(templateSpec) {
|
|
|
59
59
|
const valueFiles = (0, shared_1.getPath)(source, ['helm', 'valueFiles']);
|
|
60
60
|
return (Array.isArray(valueFiles) &&
|
|
61
61
|
typeof valueFiles.at(-1) === 'string' &&
|
|
62
|
-
|
|
62
|
+
isPreviewValuesFile(valueFiles.at(-1)));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
/** Accepts
|
|
66
|
-
function
|
|
67
|
-
return valueFile
|
|
65
|
+
/** Accepts only the canonical flat preview values contract. */
|
|
66
|
+
function isPreviewValuesFile(valueFile) {
|
|
67
|
+
return (valueFile === 'values-preview.yaml' ||
|
|
68
|
+
valueFile.endsWith('/values-preview.yaml'));
|
|
68
69
|
}
|
|
69
70
|
exports.default = runExecutor;
|
|
@@ -18,8 +18,6 @@ export interface StackValueFiles {
|
|
|
18
18
|
production?: string;
|
|
19
19
|
/** Preview base value file relative to the GitOps project. */
|
|
20
20
|
preview?: string;
|
|
21
|
-
/** Pull-request value-file pattern relative to the GitOps project. */
|
|
22
|
-
pullRequest?: string;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
/** Options accepted by the generic GitOps stack project generator. */
|
|
@@ -57,8 +57,7 @@
|
|
|
57
57
|
"properties": {
|
|
58
58
|
"staging": { "type": "string", "minLength": 1 },
|
|
59
59
|
"production": { "type": "string", "minLength": 1 },
|
|
60
|
-
"preview": { "type": "string", "minLength": 1 }
|
|
61
|
-
"pullRequest": { "type": "string", "minLength": 1 }
|
|
60
|
+
"preview": { "type": "string", "minLength": 1 }
|
|
62
61
|
},
|
|
63
62
|
"additionalProperties": false
|
|
64
63
|
},
|
|
@@ -7,7 +7,6 @@ const defaultValues = {
|
|
|
7
7
|
staging: 'values-staging.yaml',
|
|
8
8
|
production: 'values-production.yaml',
|
|
9
9
|
preview: 'values-preview.yaml',
|
|
10
|
-
pullRequest: 'values-pr.yaml',
|
|
11
10
|
};
|
|
12
11
|
/** Creates one generic GitOps project boundary for a complete Helm stack. */
|
|
13
12
|
async function stackProjectGenerator(tree, options) {
|
|
@@ -118,13 +117,10 @@ function getGeneratedFiles(directory, stack, chartPath, namespacePrefix, reposit
|
|
|
118
117
|
for (const environment of ['staging', 'production', 'preview']) {
|
|
119
118
|
files[(0, devkit_1.joinPathFragments)(directory, values[environment])] = (0, yaml_1.stringify)(createValues(applications, environment), { lineWidth: 0 });
|
|
120
119
|
}
|
|
121
|
-
if (!values.pullRequest.includes('{{')) {
|
|
122
|
-
files[(0, devkit_1.joinPathFragments)(directory, values.pullRequest)] = (0, yaml_1.stringify)(createValues(applications, 'preview'), { lineWidth: 0 });
|
|
123
|
-
}
|
|
124
120
|
let applicationSetFile;
|
|
125
121
|
if (options.policy === 'github-pr-preview') {
|
|
126
122
|
applicationSetFile = (0, devkit_1.joinPathFragments)(directory, 'application-set.yaml');
|
|
127
|
-
files[applicationSetFile] = (0, yaml_1.stringify)(createApplicationSet(stack, chartPath, namespacePrefix, repository, values.
|
|
123
|
+
files[applicationSetFile] = (0, yaml_1.stringify)(createApplicationSet(stack, chartPath, namespacePrefix, repository, values.preview, directory, options), { lineWidth: 0 });
|
|
128
124
|
}
|
|
129
125
|
return { applicationFiles, applicationSetFile, files };
|
|
130
126
|
}
|
|
@@ -169,7 +165,7 @@ function createApplication(stack, environment, chartPath, namespacePrefix, repos
|
|
|
169
165
|
},
|
|
170
166
|
};
|
|
171
167
|
}
|
|
172
|
-
/** Creates the optional
|
|
168
|
+
/** Creates the optional GitHub pull-request ApplicationSet using preview values. */
|
|
173
169
|
function createApplicationSet(stack, chartPath, namespacePrefix, repository, valuesFile, directory, options) {
|
|
174
170
|
const repositoryUrl = repository.url;
|
|
175
171
|
const secretName = options.githubTokenSecretName?.trim() || `argocd-github-${stack}`;
|
|
@@ -225,7 +221,7 @@ function createApplicationSet(stack, chartPath, namespacePrefix, repository, val
|
|
|
225
221
|
sources: [
|
|
226
222
|
{
|
|
227
223
|
repoURL: repositoryUrl,
|
|
228
|
-
targetRevision: '{{ .
|
|
224
|
+
targetRevision: 'preview/pr-{{ .number }}',
|
|
229
225
|
path: chartPath,
|
|
230
226
|
helm: {
|
|
231
227
|
valueFiles: [`$values/${gitopsValuesPath}`],
|