@otwld/nx-argo 0.0.6 → 0.0.7
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 -1
- package/package.json +1 -1
- package/src/executors/validate/validate.js +18 -2
- package/src/executors/write-artifact-lock/schema.json +11 -1
- package/src/executors/write-artifact-lock/write-artifact-lock.js +2 -1
- package/src/generators/environment-project/environment-project.js +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -45,7 +45,9 @@ function readMapping(filePath, label) {
|
|
|
45
45
|
throw new Error(`[nx-argo] Required ${label} is missing: ${filePath}`);
|
|
46
46
|
}
|
|
47
47
|
const document = (0, yaml_1.parseDocument)((0, node_fs_1.readFileSync)(filePath, 'utf8'));
|
|
48
|
-
if (document.errors.length ||
|
|
48
|
+
if (document.errors.length ||
|
|
49
|
+
!document.contents ||
|
|
50
|
+
!(0, yaml_1.isMap)(document.contents)) {
|
|
49
51
|
throw new Error(`[nx-argo] Invalid ${label}: ${filePath}`);
|
|
50
52
|
}
|
|
51
53
|
return document.toJS();
|
|
@@ -100,10 +102,24 @@ function validateApplicationSet(filePath) {
|
|
|
100
102
|
automated?.['enabled'] !== true ||
|
|
101
103
|
automated['prune'] !== true ||
|
|
102
104
|
automated['selfHeal'] !== true ||
|
|
103
|
-
getMapping(spec, 'syncPolicy')?.['preserveResourcesOnDeletion'] === true
|
|
105
|
+
getMapping(spec, 'syncPolicy')?.['preserveResourcesOnDeletion'] === true ||
|
|
106
|
+
!hasArtifactLockLast(templateSpec)) {
|
|
104
107
|
throw new Error(`[nx-argo] Invalid preview ApplicationSet contract: ${filePath}`);
|
|
105
108
|
}
|
|
106
109
|
}
|
|
110
|
+
/** Requires the PR-specific immutable lock to be the final Helm values file. */
|
|
111
|
+
function hasArtifactLockLast(templateSpec) {
|
|
112
|
+
const sources = templateSpec?.['sources'];
|
|
113
|
+
if (!Array.isArray(sources)) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return sources.some((source) => {
|
|
117
|
+
const valueFiles = getMapping(source, 'helm')?.['valueFiles'];
|
|
118
|
+
return (Array.isArray(valueFiles) &&
|
|
119
|
+
typeof valueFiles.at(-1) === 'string' &&
|
|
120
|
+
valueFiles.at(-1)?.includes('/locks/pr-'));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
107
123
|
/** Recursively finds a non-null ApplicationSet pull request generator. */
|
|
108
124
|
function containsPullRequestGenerator(value) {
|
|
109
125
|
if (Array.isArray(value)) {
|
|
@@ -45,6 +45,16 @@
|
|
|
45
45
|
"pattern": "^sha256:[a-f0-9]{64}$"
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
|
-
"required": [
|
|
48
|
+
"required": [
|
|
49
|
+
"file",
|
|
50
|
+
"repositoryPath",
|
|
51
|
+
"digestPath",
|
|
52
|
+
"servicePath",
|
|
53
|
+
"sourceRevisionPath",
|
|
54
|
+
"service",
|
|
55
|
+
"sourceRevision",
|
|
56
|
+
"repository",
|
|
57
|
+
"digest"
|
|
58
|
+
],
|
|
49
59
|
"additionalProperties": false
|
|
50
60
|
}
|
|
@@ -15,7 +15,8 @@ const runExecutor = async (options, context) => {
|
|
|
15
15
|
if (!/^sha256:[a-f0-9]{64}$/.test(options.digest)) {
|
|
16
16
|
throw new Error('[nx-argo] An immutable sha256 image digest is required.');
|
|
17
17
|
}
|
|
18
|
-
if (!isNonEmptyString(options.service) ||
|
|
18
|
+
if (!isNonEmptyString(options.service) ||
|
|
19
|
+
!isNonEmptyString(options.sourceRevision)) {
|
|
19
20
|
throw new Error('[nx-argo] A service and source revision are required.');
|
|
20
21
|
}
|
|
21
22
|
const root = (0, node_path_1.resolve)(context.root, projectRoot);
|
|
@@ -53,7 +53,7 @@ async function environmentProjectGenerator(tree, options) {
|
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
tree.write((0, devkit_1.joinPathFragments)(directory, 'values.yaml'), '# Environment configuration owned by humans.\n{}\n');
|
|
56
|
-
tree.write((0, devkit_1.joinPathFragments)(directory, 'artifacts.yaml'),
|
|
56
|
+
tree.write((0, devkit_1.joinPathFragments)(directory, 'artifacts.yaml'), "# Immutable artifacts written by automation.\nartifact:\n pending: true\n service: ''\n sourceRevision: ''\nimage:\n repository: ''\n digest: ''\n");
|
|
57
57
|
if (!options.skipFormat) {
|
|
58
58
|
await (0, devkit_1.formatFiles)(tree);
|
|
59
59
|
}
|