Skip to content

Commit 6225e6b

Browse files
authored
Merge pull request #2 from nutanix-cloud-native/jimmi/devbox-helm-plugins
build: Use nix based build for helm plugins
2 parents 8f831fb + cfe95a7 commit 6225e6b

File tree

4 files changed

+43
-66
lines changed

4 files changed

+43
-66
lines changed

devbox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"ko@latest",
2323
"kubebuilder@latest",
2424
"kubectl@latest",
25-
"kubernetes-helm@latest",
2625
"kustomize@latest",
2726
"pre-commit@latest",
2827
"rsync@latest",
@@ -35,6 +34,7 @@
3534
"path:./hack/flakes#go-mod-upgrade",
3635
"path:./hack/flakes#golangci-lint",
3736
"path:./hack/flakes#goprintconst",
37+
"path:./hack/flakes#helm-with-plugins",
3838
"path:./hack/flakes#release-please",
3939
"path:./hack/flakes#setup-envtest"
4040
],

devbox.lock

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,54 +1233,6 @@
12331233
}
12341234
}
12351235
},
1236-
"kubernetes-helm@latest": {
1237-
"last_modified": "2024-05-29T10:04:41Z",
1238-
"resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#kubernetes-helm",
1239-
"source": "devbox-search",
1240-
"version": "3.15.1",
1241-
"systems": {
1242-
"aarch64-darwin": {
1243-
"outputs": [
1244-
{
1245-
"name": "out",
1246-
"path": "/nix/store/nipci6fqwxvyz3bcq63mz4svi5bvcpb6-kubernetes-helm-3.15.1",
1247-
"default": true
1248-
}
1249-
],
1250-
"store_path": "/nix/store/nipci6fqwxvyz3bcq63mz4svi5bvcpb6-kubernetes-helm-3.15.1"
1251-
},
1252-
"aarch64-linux": {
1253-
"outputs": [
1254-
{
1255-
"name": "out",
1256-
"path": "/nix/store/axp4ixbbbxhg8f630cj6rvxjdjbx99pw-kubernetes-helm-3.15.1",
1257-
"default": true
1258-
}
1259-
],
1260-
"store_path": "/nix/store/axp4ixbbbxhg8f630cj6rvxjdjbx99pw-kubernetes-helm-3.15.1"
1261-
},
1262-
"x86_64-darwin": {
1263-
"outputs": [
1264-
{
1265-
"name": "out",
1266-
"path": "/nix/store/rvdcn0nsid05i4ardmvgn38bd1fkk9rw-kubernetes-helm-3.15.1",
1267-
"default": true
1268-
}
1269-
],
1270-
"store_path": "/nix/store/rvdcn0nsid05i4ardmvgn38bd1fkk9rw-kubernetes-helm-3.15.1"
1271-
},
1272-
"x86_64-linux": {
1273-
"outputs": [
1274-
{
1275-
"name": "out",
1276-
"path": "/nix/store/i24nairmnj41aq4w6x7fp8wjrcd15i13-kubernetes-helm-3.15.1",
1277-
"default": true
1278-
}
1279-
],
1280-
"store_path": "/nix/store/i24nairmnj41aq4w6x7fp8wjrcd15i13-kubernetes-helm-3.15.1"
1281-
}
1282-
}
1283-
},
12841236
"kustomize@latest": {
12851237
"last_modified": "2024-06-08T17:34:36Z",
12861238
"resolved": "github:NixOS/nixpkgs/cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9#kustomize",

hack/flakes/flake.nix

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,44 @@
129129
"-X ${t}.gitVersion=v${version}"
130130
];
131131
};
132+
133+
helm-schema = buildGo122Module rec {
134+
pname = "helm-schema";
135+
version = "1.4.1";
136+
137+
src = fetchFromGitHub {
138+
owner = "losisin";
139+
repo = "helm-values-schema-json";
140+
rev = "v${version}";
141+
hash = "sha256-pi/Xp4t8UFgdFvU2De2Uo/gVsVltan4iSw2XGEtynuw=";
142+
};
143+
doCheck = false;
144+
vendorHash = "sha256-F2mT36aYkLjUZbV5GQH8mNMZjGi/70dTENU2rRhAJq4=";
145+
ldflags = let t = "main"; in [
146+
"-s"
147+
"-w"
148+
"-X ${t}.BuildDate=19700101-00:00:00"
149+
"-X ${t}.GitCommit=v${version}"
150+
"-X ${t}.Version=v${version}"
151+
];
152+
153+
postPatch = ''
154+
sed -i '/^hooks:/,+2 d' plugin.yaml
155+
sed -i 's#command: "$HELM_PLUGIN_DIR/schema"#command: "$HELM_PLUGIN_DIR/helm-values-schema-json"#' plugin.yaml
156+
'';
157+
158+
postInstall = ''
159+
install -dm755 $out/${pname}
160+
mv $out/bin/* $out/${pname}/
161+
install -m644 -Dt $out/${pname} plugin.yaml
162+
'';
163+
};
164+
165+
helm-with-plugins = wrapHelm kubernetes-helm {
166+
plugins = [
167+
helm-schema
168+
];
169+
};
132170
};
133171

134172
formatter = alejandra;

make/helm.mk

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Copyright 2023 Nutanix. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
HELM_PLUGINS=$(REPO_ROOT)/.local/helm/plugins
5-
64
.PHONY: lint-chart
75
lint-chart: ## Lints helm chart
86
lint-chart:
@@ -16,18 +14,7 @@ lint-and-install-chart:
1614

1715
.PHONY: schema-chart
1816
schema-chart: ## Updates helm values JSON schema
19-
schema-chart: helm-values-schema-plugin
20-
HELM_PLUGINS=$(HELM_PLUGINS) helm schema \
21-
--input charts/cluster-api-runtime-extensions-nutanix/values.yaml \
22-
--output charts/cluster-api-runtime-extensions-nutanix/values.schema.json
23-
24-
.PHONY: helm-values-schema-plugin
25-
helm-values-schema-plugin: ## Installs helm-values-schema plugin
26-
helm-values-schema-plugin:
27-
# Only install if plugin not yet installed
28-
HELM_PLUGINS=$(HELM_PLUGINS) \
29-
helm plugin list | grep --silent "^schema\s" \
30-
|| \
31-
HELM_PLUGINS=$(HELM_PLUGINS) \
32-
helm plugin install \
33-
https://github.com/losisin/helm-values-schema-json.git
17+
schema-chart:
18+
helm schema \
19+
--input charts/cluster-api-runtime-extensions-nutanix/values.yaml \
20+
--output charts/cluster-api-runtime-extensions-nutanix/values.schema.json

0 commit comments

Comments
 (0)