Skip to content

Commit

Permalink
fix: add cluster name validation in create-cluster action; add to act…
Browse files Browse the repository at this point in the history
…ion+workflow descriptions (#33)
  • Loading branch information
tommartensen authored Oct 9, 2023
1 parent 4318014 commit 5771f9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/create-demo-clusters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ on:
description: The repository where the kube-burner config files can be found
type: string
cluster-with-fake-load-name:
description: The name of the long running cluster where the central deployment is run with a sensor that creates its own fake workload
description: "The name of the long running cluster where the central deployment is run with a sensor that creates its own fake workload. Must comply to the regex: [a-z][a-z0-9-]{1,26}[a-z0-9]"
type: string
cluster-with-real-load-name:
description: The name of the long running cluster where collector is run with real workload
description: "The name of the long running cluster where collector is run with real workload. Must comply to the regex: [a-z][a-z0-9-]{1,26}[a-z0-9]"
type: string

env:
Expand Down
2 changes: 2 additions & 0 deletions infra/create-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Default value: unset

Default value: unset

Must comply to the regex: `[a-z][a-z0-9-]{1,26}[a-z0-9]`.

#### lifespan

Default value: `48h`
Expand Down
2 changes: 1 addition & 1 deletion infra/create-cluster/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
description: Flavor (`qa-demo`, `gke-default`, `openshift-4-demo`...)
required: true
name:
description: Cluster name ([a-z][-a-z0-9]{1,26}[a-z0-9])
description: Cluster name ([a-z][a-z0-9-]{1,26}[a-z0-9])
required: true
lifespan:
description: Cluster lifespan
Expand Down
7 changes: 6 additions & 1 deletion infra/create-cluster/create-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ check_not_empty \
FLAVOR NAME LIFESPAN WAIT \
INFRA_TOKEN

ALLOWED_NAMES="^[a-z][a-z0-9-]{1,26}[a-z0-9]$"
CNAME="${NAME//./-}"
CNAME="${CNAME:0:28}"

if ! [[ "${CNAME}" =~ ${ALLOWED_NAMES} ]]; then
gh_log error "The cluster name must comply to the regular expression: \"${ALLOWED_NAMES}"\"
exit 1
fi

function cluster_info() {
infractl 2>/dev/null get "$1" --json
Expand Down

0 comments on commit 5771f9f

Please sign in to comment.