Skip to content

Commit 94f3f68

Browse files
committed
Include lookup of install-template based on version
1 parent a258dc7 commit 94f3f68

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@ version: ## Output the current version.
2525
###########
2626
.ONESHELL:
2727
merge-scripts: create-main-wrapper ## Merge the scripts in the main script
28-
@echo Merging scripts into openshift-install-wrapper
28+
@echo Merging scripts into openshift-install-wrapper.
2929
cd src/scripts && ./.merge-scripts.sh
3030

3131
merge-templates: ## Merge the install-config templates in the templates file
32-
@echo Merging install-config templates into variables file
32+
@echo Merging install-config templates into variables file.
3333
cd src/config/templates && ./.merge-templates.sh
3434

3535
create-main-wrapper: ## Creates the wrapper with all the src/ content
36-
@echo "Combining source files into openshift-install-wrapper"
36+
@echo Combining source files into openshift-install-wrapper.
3737
@cat src/control/00_init.sh src/config/*.sh src/helpers/*.sh src/actions/*.sh src/control/99_execute.sh > openshift-install-wrapper
3838
@chmod +x openshift-install-wrapper
3939

4040
create-binary-wrappers: ## Install helper wrappers for oc, kubectl, openshift-install
41-
@echo Preparing wrappers...
41+
@echo Preparing binary wrappers.
4242
@sed -i 's/^VERSION=.*/VERSION=$(VERSION)/' openshift-install-wrapper
4343
@sed -i "s|^__basedir=.*|__basedir=$(TARGETDIR)|" openshift-install-wrapper
4444
@sed -i "s|^WRAPPER_BASEDIR=.*|WRAPPER_BASEDIR=$(TARGETDIR)/bin|" bin/openshift-install
4545
@sed -i "s|^WRAPPER_BASEDIR=.*|WRAPPER_BASEDIR=$(TARGETDIR)/bin|" bin/oc
4646
@sed -i "s|^WRAPPER_BASEDIR=.*|WRAPPER_BASEDIR=$(TARGETDIR)/bin|" bin/kubectl
4747

4848
create-dirs: ## Create directories
49-
@echo Creating target directory $(TARGETDIR)...
49+
@echo Creating target directory $(TARGETDIR).
5050
@mkdir -p $(TARGETDIR)/{bin,clusters,config}
5151

5252
copy-binary-wrappers: ## Copy wrappers to binaries directory
53-
@echo Copying wrappers...
53+
@echo Copying wrappers.
5454
@mv -f openshift-install-wrapper $(TARGETDIR)/bin
5555
@cp -f bin/* $(TARGETDIR)/bin
5656
@chmod 755 $(TARGETDIR)/bin/openshift-install-wrapper

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ $ openshift-install-wrapper --install \
9797
✔ Installer for 4.4.7 found. Continuing.
9898
→ Checking if the cluster directory already exists...
9999
→ Creating install-config.yaml file...
100+
✔ Using specific install-config for aws-4.4.7...
100101
→ Running "openshift-install" to create a cluster...
101102
✔ Cluster created!
102103
To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/sgarcia/.local/ocp4/clusters/sgarcia-ocp447-3.aws.gmbros.net/auth/kubeconfig'

src/config/10_defaults.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__baseurl=https://mirror.openshift.com/pub/openshift-v4/clients/ocp
33

44
# defaults
5-
VERSION=1.6.0
5+
VERSION=1.7.0
66
VERBOSE=0
77
QUIET=0
88
FORCE=0

src/config/templates/.merge-templates.sh

+13-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@
33
output_file="../30_templates.sh"
44
echo "# install-config templates" > "$output_file"
55

6+
for platform_dir in $(find . -mindepth 1 -maxdepth 1 -type d); do
7+
platform=$(basename "$platform_dir")
8+
if [[ ! -f "$platform_dir/default.yaml" ]]; then
9+
echo "Error: No default.yaml template for $platform platform. Fix the templates and try again."
10+
exit
11+
fi
12+
done
13+
614
for file in $(find . -type f -name "*.yaml"); do
7-
platform=$(basename $(dirname "$file"))
8-
filename=$(basename "$file" .yaml)
9-
key="${platform}-${filename}"
15+
platform=$(basename $(dirname "$file"))
16+
filename=$(basename "$file" .yaml)
17+
key="${platform}-${filename}"
1018

11-
base64_content=$(base64 -w 0 "$file")
12-
echo "INSTALLTEMPLATES[$key]=\"$base64_content\"" >> "$output_file"
19+
base64_content=$(base64 -w 0 "$file")
20+
echo "INSTALLTEMPLATES[$key]=\"$base64_content\"" >> "$output_file"
1321
done
1422
echo "" >> "$output_file"

src/helpers/30_create_install_config.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,30 @@ create_install_config() {
1515

1616
mkdir -p ${clusterdir}
1717
out "→ Creating install-config.yaml file..."
18-
echo ${INSTALLTEMPLATES[${INSTALLOPTS[platform]}-default]} | base64 -d > ${clusterdir}/install-config.yaml
18+
key=${INSTALLOPTS[platform]}-${INSTALLOPTS[version]}
19+
if [[ -n "${INSTALLTEMPLATES[$key]}" ]]; then
20+
success "Using specific install-config template for ${key}..."
21+
installtemplate="${INSTALLTEMPLATES[$key]}"
22+
else
23+
minor_version="${INSTALLOPTS[version]%.*}"
24+
key="${INSTALLOPTS[platform]}-${minor_version}"
25+
26+
if [[ -n "${INSTALLTEMPLATES[$key]}" ]]; then
27+
success "Using specific install-config template for ${key}..."
28+
installtemplate="${INSTALLTEMPLATES[$key]}"
29+
else
30+
key="${INSTALLOPTS[platform]}-default"
31+
32+
if [[ -n "${INSTALLTEMPLATES[$key]}" ]]; then
33+
success "Using default install-config template for ${INSTALLOPTS[platform]}..."
34+
installtemplate="${INSTALLTEMPLATES[$key]}"
35+
else
36+
die "Unable to find a valid install-config template for the given platform/version."
37+
fi
38+
fi
39+
fi
40+
41+
echo ${installtemplate} | base64 -d > ${clusterdir}/install-config.yaml
1942

2043
sed -i "s/NAME/${INSTALLOPTS[name]}/g;" ${clusterdir}/install-config.yaml
2144
sed -i "s/DOMAIN/${INSTALLOPTS[domain]}/g;" ${clusterdir}/install-config.yaml

0 commit comments

Comments
 (0)