Skip to content

feat: add OUTPUT_DIR environment variable support to crd-extractor.sh #581

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged
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
8 changes: 5 additions & 3 deletions Utilities/crd-extractor.sh
Original file line number Diff line number Diff line change
@@ -57,7 +57,8 @@ TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT

# Create final schemas directory
SCHEMAS_DIR=$HOME/.datree/crdSchemas
# Use current directory if OUTPUT_DIR is set, otherwise use default
SCHEMAS_DIR=${OUTPUT_DIR:-$HOME/.datree/crdSchemas}
mkdir -p "$SCHEMAS_DIR"
cd "$SCHEMAS_DIR"

@@ -118,9 +119,10 @@ NC='\033[0m' # No Color

if [ $conversionResult == 0 ]; then
printf "${GREEN}Successfully converted $FETCHED_CRDS CRDs to JSON schema${NC}\n"
printf "Schemas saved to: ${CYAN}$SCHEMAS_DIR${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 '$HOME/.datree/crdSchemas/{{ .Group }}/{{ .ResourceKind }}_{{ .ResourceAPIVersion }}.json' /path/to/file\n"
printf "\n- ${CYAN}kubeval:${NC}\n\$ kubeval --additional-schema-locations file:\"$HOME/.datree/crdSchemas\" /path/to/file\n\n"
printf "\n- ${CYAN}kubeconform:${NC}\n\$ kubeconform -summary -output json -schema-location default -schema-location '$SCHEMAS_DIR/{{ .Group }}/{{ .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