You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/10/13 07:56:37 UTC
[camel-k] 01/03: Refactors the kustomize release sub-directory into a script
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 75cc695b1db1efdf195735c697da2915e8dad5f7
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Wed Jul 27 10:21:07 2022 +0100
Refactors the kustomize release sub-directory into a script
* 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.
---
.gitignore | 2 +-
install/Makefile | 2 +-
install/config | 1 +
install/example/kustomization.yaml | 2 +-
install/operator/kustomization.yaml | 2 +-
install/platform/kustomization.yaml | 8 +++-
install/release/Makefile | 60 --------------------------
install/setup-cluster/kustomization.yaml | 4 +-
install/setup/kustomization.yaml | 2 +-
script/Makefile | 5 +++
script/check_platform.sh | 37 ++++++++++------
script/release_kustomize.sh | 74 ++++++++++++++++++++++++++++++++
12 files changed, 117 insertions(+), 82 deletions(-)
diff --git a/.gitignore b/.gitignore
index 1702b92a4..14fbc3c0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -166,4 +166,4 @@ config/**/*.gen.tmpl
config/**/*.gen.yaml
config/**/*.gen.json
-release/*-installer*
+*-installer*
diff --git a/install/Makefile b/install/Makefile
index e0c497908..a84e6273f 100644
--- a/install/Makefile
+++ b/install/Makefile
@@ -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
diff --git a/install/config b/install/config
new file mode 120000
index 000000000..3ca249e06
--- /dev/null
+++ b/install/config
@@ -0,0 +1 @@
+../config
\ No newline at end of file
diff --git a/install/example/kustomization.yaml b/install/example/kustomization.yaml
index 6c0d51d85..6b9541ac7 100644
--- a/install/example/kustomization.yaml
+++ b/install/example/kustomization.yaml
@@ -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
diff --git a/install/operator/kustomization.yaml b/install/operator/kustomization.yaml
index 3b5d1f1e0..e9412ac08 100644
--- a/install/operator/kustomization.yaml
+++ b/install/operator/kustomization.yaml
@@ -43,4 +43,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
-- ../../config/manager
+- ../config/manager
diff --git a/install/platform/kustomization.yaml b/install/platform/kustomization.yaml
index 7102db801..b425aeb51 100644
--- a/install/platform/kustomization.yaml
+++ b/install/platform/kustomization.yaml
@@ -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
diff --git a/install/release/Makefile b/install/release/Makefile
deleted file mode 100644
index c35ba2a9a..000000000
--- a/install/release/Makefile
+++ /dev/null
@@ -1,60 +0,0 @@
-# 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.
-
-#
-# Include the main camel-k Makefile containing
-# basic common recipes like kustomize and vars
-# like VERSION
-#
-
-.PHONY: $(SUBDIRS)
-
-INSTALLDIR := $(RELEASE_NAME)-installer
-CONFIG := ../../config
-INSTALL := ../../install
-CMDUTIL := cmd/util
-
-RELEASE := $(CONFIG) $(INSTALL)
-
-default: release
-
-check-vars:
-ifndef RELEASE_VERSION
- $(error RELEASE_VERSION is not set)
-endif
-ifndef RELEASE_NAME
- $(error RELEASE_NAME is not set)
-endif
-
-create:
- #@ Make a new build directory
- @mkdir -p $(INSTALLDIR)
- #@ Copy directories into build directory
- @for rel in $(RELEASE); do \
- relname=$$(basename $$rel); \
- for dir in `find $$rel -mindepth 1 -maxdepth 1 \( ! -iname "*release*" \)`; do \
- mkdir -p "$(INSTALLDIR)/$$relname"; \
- cp -rfL $$dir $(INSTALLDIR)/$$relname/; \
- done \
- done
- #@ Copy the platform-check go source since its built and run during install
- @mkdir -p $(INSTALLDIR)/$(CMDUTIL) && \
- cp -rf ../../$(CMDUTIL)/platform-check $(INSTALLDIR)/$(CMDUTIL)/
-
-release: check-vars create
- #@tar zcvf $(INSTALLDIR)-$(RELEASE_VERSION).tar.gz $(INSTALLDIR)
-
-clean:
- @rm -rf *-installer *.tar.gz
diff --git a/install/setup-cluster/kustomization.yaml b/install/setup-cluster/kustomization.yaml
index 88d4747cb..cfce7838b 100644
--- a/install/setup-cluster/kustomization.yaml
+++ b/install/setup-cluster/kustomization.yaml
@@ -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
diff --git a/install/setup/kustomization.yaml b/install/setup/kustomization.yaml
index 9b3c34e6f..c10dfd653 100644
--- a/install/setup/kustomization.yaml
+++ b/install/setup/kustomization.yaml
@@ -18,4 +18,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
-- ../../config/rbac
+- ../config/rbac
diff --git a/script/Makefile b/script/Makefile
index 89d4ebca5..1f5c56cad 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -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:
diff --git a/script/check_platform.sh b/script/check_platform.sh
index 2b43f18d9..f3afc3b4e 100755
--- a/script/check_platform.sh
+++ b/script/check_platform.sh
@@ -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
}
@@ -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
diff --git a/script/release_kustomize.sh b/script/release_kustomize.sh
new file mode 100755
index 000000000..7f842420e
--- /dev/null
+++ b/script/release_kustomize.sh
@@ -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}"