-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add script to update artifacthub digest (#769)
* chore: add script to update artifacthub digest Signed-off-by: Charles-Edouard Brétéché <[email protected]> * fix Signed-off-by: Charles-Edouard Brétéché <[email protected]> * script Signed-off-by: Charles-Edouard Brétéché <[email protected]> * install Signed-off-by: Charles-Edouard Brétéché <[email protected]> * install Signed-off-by: Charles-Edouard Brétéché <[email protected]> * fix digest Signed-off-by: Charles-Edouard Brétéché <[email protected]> --------- Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
c4a7259
commit fdc508b
Showing
56 changed files
with
146 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
SED=sed | ||
|
||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
SED=gsed | ||
fi | ||
|
||
for FILE in $(find . -name "artifacthub-pkg.yml") | ||
do | ||
FOLDER=$(dirname "$FILE") | ||
POLICY=$(basename "$FOLDER") | ||
POLICY_FILE="$FOLDER/$POLICY.yaml" | ||
echo "Processing policy $POLICY ($POLICY_FILE) ..." | ||
INSTALL="kubectl apply -f https://raw.githubusercontent.com/kyverno/policies/main/${POLICY_FILE/.\//}" | ||
$SED -i -z "s#install:.*\`\`\`#install: |-\n \`\`\`shell\n $INSTALL\n \`\`\`#" $FILE | ||
DIGEST=$(shasum -U -a 256 "$POLICY_FILE" | cut -d" " -f 1) | ||
echo " Digest: $DIGEST" | ||
$SED -i "s/^digest:.*/digest: $DIGEST/" $FILE | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
# Loop through each policy directory in the repository | ||
for policy_dir in $(find "$GITHUB_WORKSPACE" -type d ! -name '.*' ! -path '*/\.*'); do | ||
# Skip the root directory | ||
if [[ "$policy_dir" == "$GITHUB_WORKSPACE" ]]; then | ||
continue | ||
fi | ||
|
||
# Skip directories that contain subdirectories | ||
if find "$policy_dir" -mindepth 1 -type d -print -quit | read; then | ||
# If it does, skip the filename validation | ||
continue | ||
fi | ||
|
||
# Get the name of the directory | ||
dir_name=$(basename "$policy_dir") | ||
|
||
# Skip if it is the CRDs directory | ||
if [[ $dir_name =~ ^.*CRDs.*$ ]]; then | ||
continue | ||
fi | ||
|
||
# Skip if it is the .hack directory | ||
if [[ $dir_name == ".hack" ]]; then | ||
continue | ||
fi | ||
|
||
# Check if the directory name only contains alphanumeric characters and dashes | ||
if [[ ! $dir_name =~ ^[a-zA-Z0-9-]+$ ]]; then | ||
echo "Directory $dir_name contains invalid characters. Only alphanumeric characters and dashes are allowed." | ||
exit 1 | ||
fi | ||
|
||
# Skip if the directory contains a kustomization.yaml file | ||
if [[ -f "$policy_dir/kustomization.yaml" ]]; then | ||
continue | ||
fi | ||
|
||
# Check if a .yml or .yaml file with the same name as the directory exists in the directory | ||
if [[ ! -f "$policy_dir/$dir_name.yml" ]] && [[ ! -f "$policy_dir/$dir_name.yaml" ]]; then | ||
echo "No .yml or .yaml file named $dir_name found in directory $policy_dir" | ||
exit 1 | ||
fi | ||
|
||
# Validate that artifacthub-pkg.yml or artifacthub-pkg.yaml file is found in the same folder as the policy | ||
if [[ ! -f "$policy_dir/artifacthub-pkg.yml" ]] && [[ ! -f "$policy_dir/artifacthub-pkg.yaml" ]]; then | ||
echo "artifacthub-pkg.yml or artifacthub-pkg.yaml file is not found in the same folder as the policy in directory $policy_dir" | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.