debug
Some checks failed
Schemas / Schemas (push) Failing after 35s

This commit is contained in:
Joseph Hanson 2024-05-29 13:55:28 -05:00
parent 516a81df5e
commit bd66f818a4
Signed by: jahanson
SSH key fingerprint: SHA256:vy6dKBECV522aPAwklFM3ReKAVB086rT3oWwiuiFG7o

View file

@ -56,7 +56,7 @@ jobs:
fileName: config.json fileName: config.json
fileDir: $GITHUB_WORKSPACE fileDir: $GITHUB_WORKSPACE
- name: Extracting CRDs to yaml - name: Extracting CRDs to yaml and converting to JSON schema
env: env:
KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}" KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}"
run: | run: |
@ -67,7 +67,15 @@ jobs:
# Create final schemas directory # Create final schemas directory
SCHEMAS_DIR=$GITHUB_WORKSPACE/crdSchemas SCHEMAS_DIR=$GITHUB_WORKSPACE/crdSchemas
mkdir -p $SCHEMAS_DIR mkdir -p $SCHEMAS_DIR
echo "Schemas directory: $SCHEMAS_DIR"
# Create array to store CRD kinds and groups
ORGANIZE_BY_GROUP=true
declare -A CRD_GROUPS 2>/dev/null
if [ $? -ne 0 ]; then
# Array creation failed, signal to skip organization by group
ORGANIZE_BY_GROUP=false
fi
# Extract CRDs from cluster # Extract CRDs from cluster
NUM_OF_CRDS=0 NUM_OF_CRDS=0
while read -r crd while read -r crd
@ -85,16 +93,45 @@ jobs:
let ++NUM_OF_CRDS let ++NUM_OF_CRDS
done < <(kubectl get crds 2>&1 | sed -n '/NAME/,$p' | tail -n +2) done < <(kubectl get crds 2>&1 | sed -n '/NAME/,$p' | tail -n +2)
echo numCRDs: $NUM_OF_CRDS echo numCRDs: $NUM_OF_CRDS
# Download converter script
curl https://raw.githubusercontent.com/yannh/kubeconform/master/scripts/openapi2jsonschema.py --output $TMP_CRD_DIR/openapi2jsonschema.py 2>/dev/null
- name: Download and run crd-extractor # Convert crds to jsonSchema
env: python3 $TMP_CRD_DIR/openapi2jsonschema.py $TMP_CRD_DIR/*.yaml
KUBECONFIG: "${{ steps.kubeconfig.outputs.filePath }}" conversionResult=$?
shell: bash
run: | # Copy and rename files to support kubeval
curl -fsSL -o $GITHUB_WORKSPACE/crd-extractor.sh \ rm -rf $SCHEMAS_DIR/master-standalone
https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/Utilities/crd-extractor.sh mkdir -p $SCHEMAS_DIR/master-standalone
chmod +x $GITHUB_WORKSPACE/crd-extractor.sh cp $SCHEMAS_DIR/*.json $SCHEMAS_DIR/master-standalone
bash $GITHUB_WORKSPACE/crd-extractor.sh find $SCHEMAS_DIR/master-standalone -name '*json' -exec bash -c ' mv -f $0 ${0/\_/-stable-}' {} \;
# Organize schemas by group
if [ $ORGANIZE_BY_GROUP == true ]; then
for schema in $SCHEMAS_DIR/*.json
do
crdFileName=$(basename $schema .json)
crdKind=${crdFileName%%_*}
crdGroup=${CRD_GROUPS[$crdKind]}
mkdir -p $crdGroup
mv $schema ./$crdGroup
done
fi
CYAN='\033[0;36m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
if [ $conversionResult == 0 ]; then
printf "${GREEN}Successfully converted $NUM_OF_CRDS CRDs to JSON schema${NC}\n"
printf "\nTo validate a CR using various tools, run the relevant command:\n"
printf "\n- ${CYAN}datree:${NC}\n\$ datree test /path/to/file\n"
printf "\n- ${CYAN}kubeconform:${NC}\n\$ kubeconform -summary -output json -schema-location default -schema-location '$SCHEMAS_DIR/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' /path/to/file\n"
printf "\n- ${CYAN}kubeval:${NC}\n\$ kubeval --additional-schema-locations file:\"$SCHEMAS_DIR\" /path/to/file\n\n"
fi
rm -rf $TMP_CRD_DIR
- name: Deploy to Cloudflare R2 - name: Deploy to Cloudflare R2
env: env: