Skip to content

Commit

Permalink
Merge pull request #66 from openinfradev/v2_air-gap
Browse files Browse the repository at this point in the history
오프라인 환경을 위한 사이트 생성 스크립트 수정
  • Loading branch information
zugwan authored Nov 10, 2021
2 parents fc7f8a5 + 49aad8e commit 4d3b83d
Show file tree
Hide file tree
Showing 22 changed files with 80 additions and 838 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*-manifest.yaml
decapod-base-yaml
cd
output
70 changes: 51 additions & 19 deletions create_site.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
#!/bin/bash
DECAPOD_BASE_URL=https://github.com/openinfradev/decapod-base-yaml.git
BRANCH="main"

if [ $# -eq 0 ]; then
echo 'Error: Missing Arguments "site name"'
exit 1
fi
SITE_NAME=$1

git clone $DECAPOD_BASE_URL .base-yaml
for i in `ls -d .base-yaml/*/ | grep -v docs | sed 's/.base-yaml\///g'`
do
mkdir -p $SITE_NAME/$i
cp .base-yaml/${i}base/site-values.yaml $SITE_NAME/$i
kustomization="$SITE_NAME/${i}kustomization.yaml"
echo "resources:" > $kustomization
echo " - ../base" >> $kustomization
echo "transformers:" >> $kustomization
echo " - site-values.yaml" >> $kustomization
set -e

BASE_SITE="hanu-reference"

function usage {
echo -e "\nUsage: ./$0 site_name [--helm-repo LOCAL_HELM_REPO --registry IMAGE_LOCAL_REGISTRY]"
exit 1
}

# We use "$@" instead of $* to preserve argument-boundary information
ARGS=$(getopt -o 'h:r:' --long 'helm-repo:,registry:' -- "$@") || usage
eval "set -- $ARGS"

while true; do
case $1 in
(-h|--helm-repo)
LOCAL_HELM_REPO=$2; shift 2;;
(-r|--registry)
LOCAL_REGISTRY=$2; shift 2;;
(--) shift; break;;
(*) exit 1;; # error
esac
done
SITE_NAME=("$@")

[ -z $SITE_NAME ] && echo 'Error: missing argument "site_name"' && usage
[ -e $SITE_NAME ] && echo "Error: \"$SITE_NAME\" already exists" && usage
[ ! -z $LOCAL_HELM_REPO ] && [ -z $LOCAL_REGISTRY ] && echo 'Error: Helm repo and Container registry must be specified together' && usage
[ -z $LOCAL_HELM_REPO ] && [ ! -z $LOCAL_REGISTRY ] && echo 'Error: Helm repo and Container registry must be specified together' && usage

rm -rf .base-yaml
[ ! -z $LOCAL_HELM_REPO ] && offline=true && echo "Helm repo: "$LOCAL_HELM_REPO
[ ! -z $LOCAL_REGISTRY ] && echo "Container Image Registry: "$LOCAL_REGISTRY
export LOCAL_HELM_REPO
export LOCAL_REGISTRY

if [ "$offline" = true ]
then
BASE_SITE="hanu-reference-offline"
fi

echo "=== new site $SITE_NAME is creating from $BASE_SITE..."

cp -r $BASE_SITE $SITE_NAME

if [ "$offline" = true ]
then
for yaml in $(find $SITE_NAME -type f -name site-values.yaml -o -name image-values.yaml)
do
cp $yaml .tmp-yaml
cat .tmp-yaml | envsubst > $yaml
rm .tmp-yaml
done
fi
3 changes: 0 additions & 3 deletions gate-centos-lb-ceph-online-multinodes/lma/kustomization.yaml

This file was deleted.

200 changes: 0 additions & 200 deletions gate-centos-lb-ceph-online-multinodes/lma/site-values.yaml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4d3b83d

Please sign in to comment.