mirror of
https://github.com/kastenhq/kubestr.git
synced 2024-12-14 11:57:56 +00:00
Avoid magic numbers in driver generation script (#73)
- Used constants - Added comments
This commit is contained in:
parent
ce8324577f
commit
8a1b8b23bb
1 changed files with 6 additions and 2 deletions
|
@ -14,6 +14,7 @@ cleanse_str() {
|
||||||
}
|
}
|
||||||
|
|
||||||
current_directory=$(dirname "$0")
|
current_directory=$(dirname "$0")
|
||||||
|
# The Driver information is scraped from the `Production Drivers` table on this page
|
||||||
curl https://raw.githubusercontent.com/kubernetes-csi/docs/master/book/src/drivers.md -o ${current_directory}/../extra/csi-drivers
|
curl https://raw.githubusercontent.com/kubernetes-csi/docs/master/book/src/drivers.md -o ${current_directory}/../extra/csi-drivers
|
||||||
|
|
||||||
cat <<EOT >> ${current_directory}/../extra/csi-drivers-temp.go
|
cat <<EOT >> ${current_directory}/../extra/csi-drivers-temp.go
|
||||||
|
@ -25,13 +26,16 @@ package kubestr
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
|
||||||
|
# The `Production Drivers` table has 8 columns as of now,
|
||||||
|
# with the last column of `Other Features` skipped for quite a few of the drivers.
|
||||||
|
MIN_COLS_PROD_DRIVERS=7
|
||||||
|
|
||||||
echo "var CSIDriverList = []*CSIDriver{" >> ${current_directory}/../extra/csi-drivers-temp.go
|
echo "var CSIDriverList = []*CSIDriver{" >> ${current_directory}/../extra/csi-drivers-temp.go
|
||||||
while read p; do
|
while read p; do
|
||||||
if [[ $p == [* ]]; then
|
if [[ $p == [* ]]; then
|
||||||
IFS='|'
|
IFS='|'
|
||||||
read -a fields <<< "$p"
|
read -a fields <<< "$p"
|
||||||
if [[ ${#fields[@]} -lt 7 ]]; then
|
if [[ ${#fields[@]} -lt $MIN_COLS_PROD_DRIVERS ]]; then
|
||||||
echo skipping "${fields[0]}"
|
echo skipping "${fields[0]}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -44,7 +48,7 @@ while read p; do
|
||||||
access_modes=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[5]}| sed 's/"//g')
|
access_modes=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[5]}| sed 's/"//g')
|
||||||
dynamic_provisioning=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[6]})
|
dynamic_provisioning=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[6]})
|
||||||
|
|
||||||
if [[ ${#fields[@]} -ge 8 ]]; then
|
if [[ ${#fields[@]} -gt $MIN_COLS_PROD_DRIVERS ]]; then
|
||||||
features=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[7]})
|
features=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<${fields[7]})
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue