Skip to content

Commit

Permalink
markups done
Browse files Browse the repository at this point in the history
  • Loading branch information
ebeaty-cisco committed May 22, 2024
1 parent b099e5f commit 69e12a3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
9 changes: 8 additions & 1 deletion charts/host-check/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}

{{/*
Runtime arguments. If both xrd-control-plane and xrd-vrouter are specified,
no arguments are set.
no arguments are set (since host-check defaults to checks for both
platforms).
*/}}
{{- define "hostCheck.args" -}}
{{- $allowedPlatforms := list "xrd-control-plane" "xrd-vrouter" }}
{{- range $platform := .Values.targetPlatforms }}
{{- if not (has $platform $allowedPlatforms) }}
{{- fail "targetPlatforms must be xrd-control-plane and/or xrd-vrouter" }}
{{- end }}
{{- end }}
{{- $args := "" }}
{{- if and (has "xrd-control-plane" .Values.targetPlatforms) (has "xrd-vrouter" .Values.targetPlatforms) }}
{{- $args = "" }}
Expand Down
6 changes: 1 addition & 5 deletions charts/host-check/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
"description": "List of platforms to run the host-check application on",
"type": "array",
"items": {
"type": "string",
"enum": [
"xrd-control-plane",
"xrd-vrouter"
]
"type": "string"
}
},
"nodeSelector": {
Expand Down
2 changes: 1 addition & 1 deletion charts/host-check/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# There are required fields which must be specified for all installations:
# - image.repository
# - image.tag
# - platforms
# - targetPlatforms

# Image configuration
image:
Expand Down
8 changes: 7 additions & 1 deletion tests/ut/host-check/job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ setup_file () {
assert_error_message_contains "targetPlatforms is required"
}

@test "host-check: platforms must be xrd-vrouter or xrd-control-plane" {
template_failure_no_set --set 'image.repository=local' \
--set 'image.tag=latest' --set 'targetPlatforms[0]=foo'
assert_error_message_contains "targetPlatforms must be xrd-control-plane and/or xrd-vrouter"
}

@test "host-check Job: container image is set" {
template_hc
assert_query_equal '.spec.template.spec.containers[0].image' "local:latest"
Expand All @@ -88,7 +94,7 @@ setup_file () {
}

@test "host-check Job: illegal container imagePullPolicy are rejected" {
template_failure --set 'image.pullPolicy=foo' --set 'targetPlatforms[0]=xrd-vrouter'
template_failure_hc --set 'image.pullPolicy=foo'
assert_error_message_contains \
"image.pullPolicy must be one of the following: \"Always\", \"IfNotPresent\", \"Never\""
}
Expand Down
6 changes: 6 additions & 0 deletions tests/ut/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ template_failure () {
"$@"
}

template_failure_hc () {
template_failure \
--set 'targetPlatforms[0]=xrd-vrouter' \
"$@"
}

template_failure_no_set () {
echo -n "# Run 'helm template'"
[ "$#" -eq 0 ] && echo "" || echo " with arguments: $*"
Expand Down

0 comments on commit 69e12a3

Please sign in to comment.