Skip to content
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

오프라인 환경을 위한 사이트 생성 스크립트 수정 #66

Merged
merged 5 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
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
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