-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Move CSI supported provider logic to script (#703)
**What problem does this PR solve?**: PR #695 was merged before I pushed the refactoring to move the logic into a script - this commit contains those changes. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
- Loading branch information
1 parent
c9e2b36
commit cb6b4ee
Showing
4 changed files
with
37 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
readonly SCRIPT_DIR | ||
|
||
# shellcheck source=hack/common.sh | ||
source "${SCRIPT_DIR}/../common.sh" | ||
|
||
# Below are the lists of CSI Providers allowed for a specific infrastructure. | ||
# - When we support a new infrastructure, we need to a create a new entry in this array using the same convention. | ||
# - When we support a new CSI Provider, we need to add it to one or more of these lists. | ||
declare -rA CSI_PROVIDERS=( | ||
["aws"]='["aws-ebs"]' | ||
["nutanix"]='["nutanix"]' | ||
["docker"]='["local-path"]' | ||
) | ||
|
||
readonly CSI_JSONPATH='.spec.versions[].schema.openAPIV3Schema.properties.spec.properties.addons.properties.csi.properties' | ||
|
||
for provider in "${!CSI_PROVIDERS[@]}"; do | ||
custerconfig_file="${GIT_REPO_ROOT}/api/v1alpha1/crds/caren.nutanix.com_${provider}clusterconfigs.yaml" | ||
cat <<EOF >"${custerconfig_file}.tmp" | ||
$(cat "${GIT_REPO_ROOT}/hack/license-header.yaml.txt") | ||
--- | ||
$(gojq --yaml-input --yaml-output \ | ||
"(${CSI_JSONPATH}.providers.items.properties.name.enum, ${CSI_JSONPATH}.defaultStorage.properties.providerName.enum) |= ${CSI_PROVIDERS[${provider}]}" \ | ||
"${custerconfig_file}") | ||
EOF | ||
|
||
mv "${custerconfig_file}"{.tmp,} | ||
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