Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"include": ["src/"]
},
"imports": {
"libpkgx": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.20.1/mod.ts",
"libpkgx": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.21.0/mod.ts",
"libpkgx/": "https://raw.githubusercontent.com/pkgxdev/libpkgx/refs/tags/v0.20.1/src/",
"is-what": "https://deno.land/x/is_what@v4.1.15/src/index.ts",
"outdent": "https://deno.land/x/outdent@v0.8.0/mod.ts"
Expand Down
38 changes: 37 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions fixtures/skaffold.yaml/multidoc/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v4beta7
kind: Config
metadata:
name: skaffold-fixture
build:
local:
useDockerCLI: true
deploy:
kubeContext: minikube
docker:
images: []
manifests:
kpt: []
kustomize: {}
helm:
releases: []

profiles:
- name: skaffold-fixture
---
apiVersion: v4beta7
kind: Config
metadata:
name: skaffold-fixture
deploy:
kubectl: {}
helm: {}
manifests:
kustomize: {}

profiles:
- name: skaffold-fixture
10 changes: 10 additions & 0 deletions src/sniff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ Deno.test("devenv.ts", async (runner) => {
"kpt.dev",
"kubernetes.io/kustomize",
],
[
"skaffold.yaml/multidoc/skaffold.yaml",
"skaffold.dev",
"kubernetes.io/kubectl",
"helm.sh",
"kpt.dev",
"kubernetes.io/minikube",
"docker.com/cli",
"kubernetes.io/kustomize",
],
];

for (const [keyfile, ...deps] of keyfiles) {
Expand Down
90 changes: 50 additions & 40 deletions src/sniff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,47 +260,57 @@ export default async function (dir: Path) {
}

async function skaffold_yaml(path: Path) {
const yaml = await path.readYAML();
if (!isPlainObject(yaml)) return;
if (
yaml.build?.local?.useDockerCLI?.toString() === true ||
yaml.deploy?.docker
) {
pkgs.push({
project: "docker.com/cli",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kubectl) {
pkgs.push({
project: "kubernetes.io/kubectl",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kubeContext?.match("minikube")) {
pkgs.push({
project: "kubernetes.io/minikube",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.helm || yaml.manifests?.helm) {
pkgs.push({
project: "helm.sh",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kpt || yaml.manifests?.kpt) {
pkgs.push({
project: "kpt.dev",
constraint: new semver.Range(`*`),
});
}
if (yaml.manifests?.kustomize) {
pkgs.push({
project: "kubernetes.io/kustomize",
constraint: new semver.Range(`*`),
});
const yamls = await path.readYAMLAll() as unknown as any[];
const lpkgs: PackageRequirement[] = [];

for (const yaml of yamls) {
if (!isPlainObject(yaml)) continue;

if (
yaml.build?.local?.useDockerCLI?.toString() === "true" ||
yaml.deploy?.docker
) {
lpkgs.push({
project: "docker.com/cli",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kubectl) {
lpkgs.push({
project: "kubernetes.io/kubectl",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kubeContext?.match("minikube")) {
lpkgs.push({
project: "kubernetes.io/minikube",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.helm || yaml.manifests?.helm) {
lpkgs.push({
project: "helm.sh",
constraint: new semver.Range(`*`),
});
}
if (yaml.deploy?.kpt || yaml.manifests?.kpt) {
lpkgs.push({
project: "kpt.dev",
constraint: new semver.Range(`*`),
});
}
if (yaml.manifests?.kustomize) {
lpkgs.push({
project: "kubernetes.io/kustomize",
constraint: new semver.Range(`*`),
});
}
}

const deduped = Array.from(
new Map(lpkgs.map(pkg => [pkg.project, pkg])).values()
);
pkgs.push(...deduped)
}

async function github_actions(path: Path) {
Expand Down
Loading