Skip to content

Commit

Permalink
Refactors the kustomize release sub-directory into a script
Browse files Browse the repository at this point in the history
* Intention was to provide a version of the source that only
  includes the kustomize install/config files rather than the user
  cloning the whole repository.

* Migrates the release from a sub-directory to a rule in the main
  Makefile that fires off the release_kustomize.sh script

* To avoid changing level paths for the config directory (../..), adds
  a symlink into the install directory which is at the same level as
  it would be in the release archive.
  • Loading branch information
phantomjinx authored and tadayosi committed Oct 13, 2022
1 parent 4d092ef commit 75cc695
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ config/**/*.gen.tmpl
config/**/*.gen.yaml
config/**/*.gen.json

release/*-installer*
*-installer*
2 changes: 1 addition & 1 deletion install/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ HEALTH_PORT ?= 8081
# Operator Logging Level: string [info, debug, 0, 1]
LOGGING_LEVEL ?= info

CONFIG := ../config
CONFIG := config
MANAGER := $(CONFIG)/manager
SAMPLES := $(CONFIG)/samples
RBAC := $(CONFIG)/rbac
Expand Down
1 change: 1 addition & 0 deletions install/config
2 changes: 1 addition & 1 deletion install/example/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../config/samples/bases/camel_v1_integration.yaml
- ../config/samples/bases/camel_v1_integration.yaml
2 changes: 1 addition & 1 deletion install/operator/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../config/manager
- ../config/manager
8 changes: 7 additions & 1 deletion install/platform/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@
# limitations under the License.
# ---------------------------------------------------------------------------

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

#
# * patch-integration-platform.yaml
# customizes the integration platform custom resource
# Edit the patch manually to add required configuration
#
resources:
- ../../config/samples/bases/camel_v1_integrationplatform.yaml
- ../config/samples/bases/camel_v1_integrationplatform.yaml

patchesStrategicMerge:
- ../config/samples/patch-integration-platform.yaml
60 changes: 0 additions & 60 deletions install/release/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions install/setup-cluster/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../config/crd
- ../../config/rbac/user-cluster-role.yaml
- ../config/crd
- ../config/rbac/user-cluster-role.yaml
2 changes: 1 addition & 1 deletion install/setup/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- ../../config/rbac
- ../config/rbac
5 changes: 5 additions & 0 deletions script/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,11 @@ release-nightly: clean codegen set-module-version set-version build-resources bu
release-helm:
./script/release_helm.sh

release-kustomize:
RELEASE_VERSION=$(CUSTOM_VERSION) \
RELEASE_NAME=$(PACKAGE) \
./script/release_kustomize.sh

install-crc:
./script/install_crc.sh $(CUSTOM_VERSION)
install-minikube:
Expand Down
37 changes: 23 additions & 14 deletions script/check_platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

location=$(dirname $0)
rootdir=$location/../
cmdutil="./cmd/util"
check_binary="./platform-check"

check_platform() {
set +e
echo $(./platform-check)
echo $(${check_binary})
set -e
}

Expand All @@ -40,23 +45,27 @@ is_binary_available() {
echo "ERROR: No '${client}' binary found in path."
}

location=$(dirname $0)
rootdir=$location/../

cd $rootdir
if [ -d "./cmd/util/platform-check" ]; then
if [ -d "${cmdutil}/platform-check" ]; then

if [ -f "${check_binary}" ]; then
#
# Avoid compiling again if binary already exists
#
go_result=$(check_platform)
else
hasgo=$(is_binary_available "go")
if [ "${hasgo}" == "OK" ]; then
go build ${cmdutil}/platform-check/
if [ $? == 0 ]; then
go_result=$(check_platform)
else
go_result="ERROR: failed to build platform-check binary"
fi

hasgo=$(is_binary_available "go")
if [ "${hasgo}" == "OK" ]; then
go build ./cmd/util/platform-check/
if [ $? == 0 ]; then
go_result=$(check_platform)
else
go_result="ERROR: failed to build platform-check binary"
go_result="ERROR: cannot build platform-check"
fi

else
go_result="ERROR: cannot build platform-check"
fi

else
Expand Down
74 changes: 74 additions & 0 deletions script/release_kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

location=$(dirname $0)
rootdir=$(realpath ${location}/..)
configdir="config"
installdir="install"
cmdutildir="cmd/util" # make cmd a hidden directory

check_env_var() {
if [ -z "${2}" ]; then
echo "Error: ${1} env var not defined"
exit 1
fi
}

check_env_var "RELEASE_VERSION" ${RELEASE_VERSION}
check_env_var "RELEASE_NAME" ${RELEASE_NAME}

pushd ${rootdir}

releasedir="${RELEASE_NAME}-${RELEASE_VERSION}-installer"
zipname="${RELEASE_NAME}-${RELEASE_VERSION}-installer.zip"

if [ -d "${releasedir}" ]; then
rm -rf "${releasedir}"
fi
mkdir -p ${releasedir}

#
# Copies contents of install and converts softlinks
# to target files.
#
cp -rfL "${installdir}"/* "${releasedir}/"

#
# Copy the platform-check go source since its built and run during install
#
mkdir -p "${releasedir}/.${cmdutildir}/"
cp -rf "${cmdutildir}/platform-check" "${releasedir}/.${cmdutildir}/"

#
# Update location of cmd to point to hidden directory version
#
sed -i 's~^cmdutil=.*~cmdutil=\"./.cmd/util\"~' ${releasedir}/script/check_platform.sh

#
# Copy the config directory
#
cp -rfL "${configdir}" "${releasedir}/"

#
# Zip up the release
#
if [ -f "${zipname}" ]; then
rm -f "${zipname}"
fi
zip -r "${zipname}" "${releasedir}" && rm -rf "${releasedir}"

0 comments on commit 75cc695

Please sign in to comment.