Add validation for catalogues

This change ensures that catalogue CRs (i.e. networking,
versions) are validated when running validate_docs script.

Also fixes:
* problem encountered with the creation of the ironic-vars
ConfigMap when a non-string data type was used as the
replacement target value.
* amends VersionsCatalogue schema to allow an optional
'ipam-manager' object in capi_images, necessitated by
a change to the capm3 function[0].

[0] https://review.opendev.org/c/airship/airshipctl/+/780297

Closes: #476
Change-Id: Idd05eb046e411b757b7d4f7b21a9b89b6cc51bb6
This commit is contained in:
Matthew Fuller 2021-03-01 21:27:27 +00:00 committed by Kostyantyn Kalynovskyi
parent bba25054b0
commit 7222467df3
3 changed files with 31 additions and 4 deletions

View File

@ -120,12 +120,11 @@ spec:
# TODO(mfuller): should this be enforced with a pattern?
type: string
ironicAutomatedClean:
type: boolean
type: string
httpPort:
type: integer
maximum: 65535
type: string
ironicFastTrack:
type: boolean
type: string
deployKernelUrl:
type: string
deployRamdiskUrl:

View File

@ -51,6 +51,7 @@ spec:
type: object
additionalProperties:
type: object
required: [manager, auth_proxy]
properties:
manager:
type: object
@ -66,6 +67,13 @@ spec:
type: string
tag:
type: string
ipam-manager:
type: object
properties:
repository:
type: string
tag:
type: string
images:
type: object
additionalProperties: # image groups

View File

@ -20,6 +20,7 @@ set -xe
# The location of sites whose manifests should be validated.
# This are relative to MANIFEST_ROOT above
: ${SITE_ROOT:="$(basename "${PWD}")/manifests/site"}
: ${SCHEMAS_ROOT:="${PWD}/manifests/function/airshipctl-schemas"}
: ${MANIFEST_REPO_URL:="https://review.opendev.org/airship/airshipctl"}
: ${SITE:="test-workload"}
: ${CONTEXT:="kind-airship"}
@ -99,6 +100,8 @@ fi
generate_airshipconf "default"
catalogues=("versions" "networking")
phase_plans=$(airshipctl --airshipconf ${AIRSHIPCONFIG} plan list | grep "PhasePlan" | awk -F '/' '{print $2}' | awk '{print $1}')
for plan in $phase_plans; do
@ -120,6 +123,9 @@ for plan in $phase_plans; do
# In the meantime, as new phases are added, please add them here as well.
phases=$(airshipctl --airshipconf ${AIRSHIPCONFIG} phase list --plan $plan -c $cluster | grep Phase | awk -F '/' '{print $2}' | awk '{print $1}' || true)
# apply catalogue CRDs
${KUBECTL} --context ${CLUSTER} --kubeconfig ${KUBECONFIG} apply -k ${SCHEMAS_ROOT}
for phase in $phases; do
# Guard against bootstrap or initinfra being missing, which could be the case for some configs
echo -e "\n*** Rendering ${cluster}/${phase}"
@ -128,12 +134,26 @@ for plan in $phase_plans; do
# TODO: will need to loop through phases in order, eventually
# e.g., load CRDs from initinfra first, so they're present when validating later phases
${AIRSHIPCTL} --airshipconf ${AIRSHIPCONFIG} phase render ${phase} -s executor -k CustomResourceDefinition >${TMP}/${phase}-crds.yaml
# extract rendered catalogue CRs
${AIRSHIPCTL} --airshipconf ${AIRSHIPCONFIG} phase render ${phase} -s executor -k NetworkCatalogue >${TMP}/${phase}-networking.yaml
${AIRSHIPCTL} --airshipconf ${AIRSHIPCONFIG} phase render ${phase} -s executor -k VersionsCatalogue >${TMP}/${phase}-versions.yaml
if [ -s ${TMP}/${phase}-crds.yaml ]; then
${KUBECTL} --context ${CLUSTER} apply -f ${TMP}/${phase}-crds.yaml
fi
# step 2: dry-run the entire phase
${ACTL} phase run --dry-run ${phase}
# catalogues have the label deploy-k8s: false, so they won't get applied during the dry-run
# and will have to be applied manually here
for catalogue in "${catalogues[@]}"
do
if [ -s ${TMP}/${phase}-${catalogue}.yaml ]; then
${KUBECTL} --context ${CLUSTER} --kubeconfig ${KUBECONFIG} apply -f ${TMP}/$phase-${catalogue}.yaml --dry-run=client
fi
done
done
# Delete cluster kubeconfig
rm ${KUBECONFIG}