Skip to content

Commit e8bd12f

Browse files
vkumbhar94mxcl
authored andcommitted
fix(skaffold.yaml): read multi-doc skaffold.yaml and push all resolve all pkgs
1 parent a589d3e commit e8bd12f

File tree

5 files changed

+130
-42
lines changed

5 files changed

+130
-42
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"include": ["src/"]
1212
},
1313
"imports": {
14-
"libpkgx": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.20.1/mod.ts",
14+
"libpkgx": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.21.0/mod.ts",
1515
"libpkgx/": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.20.1/src/",
1616
"is-what": "https://deno.land/x/[email protected]/src/index.ts",
1717
"outdent": "https://deno.land/x/[email protected]/mod.ts"

deno.lock

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apiVersion: v4beta7
2+
kind: Config
3+
metadata:
4+
name: skaffold-fixture
5+
build:
6+
local:
7+
useDockerCLI: true
8+
deploy:
9+
kubeContext: minikube
10+
docker:
11+
images: []
12+
manifests:
13+
kpt: []
14+
kustomize: {}
15+
helm:
16+
releases: []
17+
18+
profiles:
19+
- name: skaffold-fixture
20+
---
21+
apiVersion: v4beta7
22+
kind: Config
23+
metadata:
24+
name: skaffold-fixture
25+
deploy:
26+
kubectl: {}
27+
helm: {}
28+
manifests:
29+
kustomize: {}
30+
31+
profiles:
32+
- name: skaffold-fixture

src/sniff.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,16 @@ Deno.test("devenv.ts", async (runner) => {
221221
"kpt.dev",
222222
"kubernetes.io/kustomize",
223223
],
224+
[
225+
"skaffold.yaml/multidoc/skaffold.yaml",
226+
"skaffold.dev",
227+
"kubernetes.io/kubectl",
228+
"helm.sh",
229+
"kpt.dev",
230+
"kubernetes.io/minikube",
231+
"docker.com/cli",
232+
"kubernetes.io/kustomize",
233+
],
224234
];
225235

226236
for (const [keyfile, ...deps] of keyfiles) {

src/sniff.ts

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -260,47 +260,57 @@ export default async function (dir: Path) {
260260
}
261261

262262
async function skaffold_yaml(path: Path) {
263-
const yaml = await path.readYAML();
264-
if (!isPlainObject(yaml)) return;
265-
if (
266-
yaml.build?.local?.useDockerCLI?.toString() === true ||
267-
yaml.deploy?.docker
268-
) {
269-
pkgs.push({
270-
project: "docker.com/cli",
271-
constraint: new semver.Range(`*`),
272-
});
273-
}
274-
if (yaml.deploy?.kubectl) {
275-
pkgs.push({
276-
project: "kubernetes.io/kubectl",
277-
constraint: new semver.Range(`*`),
278-
});
279-
}
280-
if (yaml.deploy?.kubeContext?.match("minikube")) {
281-
pkgs.push({
282-
project: "kubernetes.io/minikube",
283-
constraint: new semver.Range(`*`),
284-
});
285-
}
286-
if (yaml.deploy?.helm || yaml.manifests?.helm) {
287-
pkgs.push({
288-
project: "helm.sh",
289-
constraint: new semver.Range(`*`),
290-
});
291-
}
292-
if (yaml.deploy?.kpt || yaml.manifests?.kpt) {
293-
pkgs.push({
294-
project: "kpt.dev",
295-
constraint: new semver.Range(`*`),
296-
});
297-
}
298-
if (yaml.manifests?.kustomize) {
299-
pkgs.push({
300-
project: "kubernetes.io/kustomize",
301-
constraint: new semver.Range(`*`),
302-
});
263+
const yamls = await path.readYAMLAll() as unknown as any[];
264+
const lpkgs: PackageRequirement[] = [];
265+
266+
for (const yaml of yamls) {
267+
if (!isPlainObject(yaml)) continue;
268+
269+
if (
270+
yaml.build?.local?.useDockerCLI?.toString() === "true" ||
271+
yaml.deploy?.docker
272+
) {
273+
lpkgs.push({
274+
project: "docker.com/cli",
275+
constraint: new semver.Range(`*`),
276+
});
277+
}
278+
if (yaml.deploy?.kubectl) {
279+
lpkgs.push({
280+
project: "kubernetes.io/kubectl",
281+
constraint: new semver.Range(`*`),
282+
});
283+
}
284+
if (yaml.deploy?.kubeContext?.match("minikube")) {
285+
lpkgs.push({
286+
project: "kubernetes.io/minikube",
287+
constraint: new semver.Range(`*`),
288+
});
289+
}
290+
if (yaml.deploy?.helm || yaml.manifests?.helm) {
291+
lpkgs.push({
292+
project: "helm.sh",
293+
constraint: new semver.Range(`*`),
294+
});
295+
}
296+
if (yaml.deploy?.kpt || yaml.manifests?.kpt) {
297+
lpkgs.push({
298+
project: "kpt.dev",
299+
constraint: new semver.Range(`*`),
300+
});
301+
}
302+
if (yaml.manifests?.kustomize) {
303+
lpkgs.push({
304+
project: "kubernetes.io/kustomize",
305+
constraint: new semver.Range(`*`),
306+
});
307+
}
303308
}
309+
310+
const deduped = Array.from(
311+
new Map(lpkgs.map(pkg => [pkg.project, pkg])).values()
312+
);
313+
pkgs.push(...deduped)
304314
}
305315

306316
async function github_actions(path: Path) {

0 commit comments

Comments
 (0)