Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require version for helm chart #183

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
51 changes: 51 additions & 0 deletions pkg/kots/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,57 @@ spec:
},
},
},
{
name: "missing required version for Helm extension in embedded cluster config",
specFiles: domain.SpecFiles{
validPreflightSpec,
validConfigSpec,
validSupportBundleSpec,
validKotsAppSpec,
{
Name: "ec-config.yaml",
Path: "ec-config.yaml",
Content: `apiVersion: embeddedcluster.replicated.com/v1beta1
kind: Config
spec:
version: "v1.2.2+k8s-1.29"
roles:
controller:
name: management
labels:
management: "true"
custom:
- name: app
labels:
app: "true"
extensions:
helm:
repositories:
- name: ingress-nginx
url: https://kubernetes.github.io/ingress-nginx
charts:
- name: ingress-nginx
chartname: ingress-nginx/ingress-nginx
namespace: ingress-nginx
`,
},
},
expect: []domain.LintExpression{
{
Rule: "ec-helm-extension-version-required",
Path: "ec-config.yaml",
Type: "error",
Message: "Missing version for Helm Chart extension",
Positions: []domain.LintExpressionItemPosition{
{
Start: domain.LintExpressionItemLinePosition{
Line: 20,
},
},
},
},
},
},
{
name: "duplicate kots kinds in release",
specFiles: domain.SpecFiles{
Expand Down
19 changes: 19 additions & 0 deletions pkg/kots/rego/kots-spec-opa-nonrendered.rego
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,25 @@ lint[output] {
}
}

# Check if helm charts in the embedded cluster config contain a version
lint[output] {
rule_name := "ec-helm-extension-version-required"
rule_config := lint_rule_config(rule_name, "error")
not rule_config.off
spec := specs[_]
chart := spec.spec.extensions.helm.charts[index]
not chart.version
field := concat(".", [spec.field, "extensions.helm.charts", string(index)])
output := {
"rule": rule_name,
"type": rule_config.level,
"message": "Missing version for Helm Chart extension",
"path": spec.path,
"field": field,
"docIndex": spec.docIndex
}
}

# Check if the kubernetes installer addons versions are valid
is_kubernetes_installer(file) {
is_kubernetes_installer_api_version(file.content.apiVersion)
Expand Down
Loading