-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extraOpts option to helm releases
Closes #19
- Loading branch information
Showing
7 changed files
with
310 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: job-hook | ||
annotations: | ||
helm.sh/hook: post-install,post-upgrade | ||
labels: | ||
{{- include "chart.labels" . | nindent 4 }} | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "chart.labels" . | nindent 8 }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }}-job-hook | ||
image: busybox | ||
command: | ||
- 'sh' | ||
- '-c' | ||
- 'echo The hook Job is running' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
{ | ||
lib, | ||
config, | ||
... | ||
}: let | ||
apps = config.applications; | ||
in { | ||
# Create an application with a helm chart | ||
# with `extraOpts` set | ||
applications.test1.helm.releases.test1 = { | ||
chart = ./chart; | ||
extraOpts = ["--no-hooks"]; | ||
}; | ||
|
||
test = with lib; { | ||
name = "helm chart with extra opts"; | ||
description = "Create an application with Helm chart and adding extra opts."; | ||
assertions = [ | ||
{ | ||
description = "Deployment should be rendered correctly."; | ||
|
||
expression = | ||
findFirst | ||
(x: x.kind == "Deployment" && x.metadata.name == "test1-chart") | ||
null | ||
apps.test1.objects; | ||
|
||
expected = { | ||
apiVersion = "apps/v1"; | ||
kind = "Deployment"; | ||
metadata = { | ||
name = "test1-chart"; | ||
namespace = "test1"; | ||
labels = { | ||
"app.kubernetes.io/instance" = "test1"; | ||
"app.kubernetes.io/managed-by" = "Helm"; | ||
"app.kubernetes.io/name" = "chart"; | ||
"app.kubernetes.io/version" = "1.16.0"; | ||
"helm.sh/chart" = "chart-0.1.0"; | ||
}; | ||
}; | ||
spec = { | ||
replicas = 1; | ||
selector.matchLabels = { | ||
"app.kubernetes.io/instance" = "test1"; | ||
"app.kubernetes.io/name" = "chart"; | ||
}; | ||
template = { | ||
metadata.labels = { | ||
"app.kubernetes.io/instance" = "test1"; | ||
"app.kubernetes.io/managed-by" = "Helm"; | ||
"app.kubernetes.io/name" = "chart"; | ||
"app.kubernetes.io/version" = "1.16.0"; | ||
"helm.sh/chart" = "chart-0.1.0"; | ||
}; | ||
spec.containers = [ | ||
{ | ||
name = "chart"; | ||
image = "nginx:latest"; | ||
ports = [ | ||
{ | ||
name = "http"; | ||
containerPort = 80; | ||
protocol = "TCP"; | ||
} | ||
]; | ||
} | ||
]; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
{ | ||
description = "Service should be rendered correctly."; | ||
|
||
expression = | ||
findFirst | ||
(x: x.kind == "Service" && x.metadata.name == "test1-chart") | ||
null | ||
apps.test1.objects; | ||
|
||
expected = { | ||
apiVersion = "v1"; | ||
kind = "Service"; | ||
metadata = { | ||
name = "test1-chart"; | ||
namespace = "test1"; | ||
labels = { | ||
"app.kubernetes.io/instance" = "test1"; | ||
"app.kubernetes.io/managed-by" = "Helm"; | ||
"app.kubernetes.io/name" = "chart"; | ||
"app.kubernetes.io/version" = "1.16.0"; | ||
"helm.sh/chart" = "chart-0.1.0"; | ||
}; | ||
}; | ||
spec = { | ||
type = "ClusterIP"; | ||
ports = [ | ||
{ | ||
port = 80; | ||
targetPort = "http"; | ||
protocol = "TCP"; | ||
name = "http"; | ||
} | ||
]; | ||
selector = { | ||
"app.kubernetes.io/instance" = "test1"; | ||
"app.kubernetes.io/name" = "chart"; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
{ | ||
description = "Job hook should not be rendered at all."; | ||
|
||
expression = | ||
findFirst | ||
(x: x.kind == "Job" && x.metadata.name == "job-hook") | ||
null | ||
apps.test1.objects; | ||
|
||
expected = null; | ||
} | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters