From 2f6f8a46d411829c321d5eb9fad6e32cf920fb71 Mon Sep 17 00:00:00 2001 From: Jagatguru Prasad Mishra Date: Thu, 25 Apr 2024 06:31:52 -0400 Subject: [PATCH] Auto-increment Harbor Charts Version The current commit enables helm auto-versioning to the harbor charts. Test Plan: PASS: Build all packages generating an application tarball verifying all versions on the charts and application make sense. PASS: Introduce temporary chart changes and ensure that the versions increment as expected. PASS: Validate basic application lifecycle operations: upload/apply/remove/delete. Story: 2010929 Task: 49973 Change-Id: I646afd509ef0d3ba7b0955028898d345f3149c3d Signed-off-by: Jagatguru Prasad Mishra --- debian_pkg_dirs | 1 + .../harbor-helm/debian/deb_folder/changelog | 5 ++ .../harbor-helm/debian/deb_folder/control | 16 ++++++ .../harbor-helm/debian/deb_folder/copyright | 41 ++++++++++++++ .../debian/deb_folder/harbor-helm.install | 1 + .../patches}/0001-AddNodeAffinityToPods.patch | 0 .../debian/deb_folder/patches/series | 1 + .../harbor-helm/debian/deb_folder/rules | 26 +++++++++ .../debian/deb_folder/source/format | 1 + .../harbor-helm/debian/meta_data.yaml | 15 ++++++ .../harbor-helm/harbor-helm}/files/Makefile | 6 +-- stx-harbor-helm/debian/deb_folder/changelog | 6 +++ stx-harbor-helm/debian/deb_folder/control | 4 +- stx-harbor-helm/debian/deb_folder/copyright | 4 +- stx-harbor-helm/debian/deb_folder/rules | 53 ++++++++----------- stx-harbor-helm/debian/meta_data.yaml | 7 +-- stx-harbor-helm/stx-harbor-helm/README | 5 -- .../stx-harbor-helm/files/index.yaml | 3 -- .../stx-harbor-helm/files/repositories.yaml | 12 ----- .../fluxcd-manifests/harbor/helmrelease.yaml | 2 +- 20 files changed, 141 insertions(+), 68 deletions(-) create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/changelog create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/control create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/copyright create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/harbor-helm.install rename {stx-harbor-helm/stx-harbor-helm/files => helm-charts/upstream/harbor-helm/debian/deb_folder/patches}/0001-AddNodeAffinityToPods.patch (100%) create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/patches/series create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/rules create mode 100644 helm-charts/upstream/harbor-helm/debian/deb_folder/source/format create mode 100644 helm-charts/upstream/harbor-helm/debian/meta_data.yaml rename {stx-harbor-helm/stx-harbor-helm => helm-charts/upstream/harbor-helm/harbor-helm}/files/Makefile (80%) delete mode 100644 stx-harbor-helm/stx-harbor-helm/README delete mode 100644 stx-harbor-helm/stx-harbor-helm/files/index.yaml delete mode 100644 stx-harbor-helm/stx-harbor-helm/files/repositories.yaml diff --git a/debian_pkg_dirs b/debian_pkg_dirs index 8f4cfb7..a9a7722 100644 --- a/debian_pkg_dirs +++ b/debian_pkg_dirs @@ -1,2 +1,3 @@ +helm-charts/upstream/harbor-helm python3-k8sapp-harbor stx-harbor-helm diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/changelog b/helm-charts/upstream/harbor-helm/debian/deb_folder/changelog new file mode 100644 index 0000000..8ff5f3d --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/changelog @@ -0,0 +1,5 @@ +harbor-helm (1.12-1) unstable; urgency=medium + + * Initial release. + + -- Jagatguru Prasad Mishra Thu, 25 Apr 2024 03:39:52 -0400 diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/control b/helm-charts/upstream/harbor-helm/debian/deb_folder/control new file mode 100644 index 0000000..80acda5 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/control @@ -0,0 +1,16 @@ +Source: harbor-helm +Section: libs +Priority: optional +Maintainer: StarlingX Developers +Build-Depends: debhelper-compat (= 13), + helm +Standards-Version: 4.5.1 +Homepage: https://www.starlingx.io + +Package: harbor-helm +Section: libs +Architecture: any +Depends: ${misc:Depends} +Description: StarlingX harbor Application Helm Charts + This package contains helm charts for the harbor application. + diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/copyright b/helm-charts/upstream/harbor-helm/debian/deb_folder/copyright new file mode 100644 index 0000000..38d2004 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/copyright @@ -0,0 +1,41 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: harbor-helm +Source: https://opendev.org/starlingx/app-harbor/ + +Files: * +Copyright: (c) 2024 Wind River Systems, Inc +License: Apache-2 + Licensed 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 + . + https://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. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in `/usr/share/common-licenses/Apache-2.0'. +# If you want to use GPL v2 or later for the /debian/* files use +# the following clauses, or change it to suit. Delete these two lines +Files: debian/* +Copyright: 2024 Wind River Systems, Inc +License: Apache-2 + Licensed 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 + . + https://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. + . + On Debian-based systems the full text of the Apache version 2.0 license + can be found in `/usr/share/common-licenses/Apache-2.0'. + diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/harbor-helm.install b/helm-charts/upstream/harbor-helm/debian/deb_folder/harbor-helm.install new file mode 100644 index 0000000..8777963 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/harbor-helm.install @@ -0,0 +1 @@ +usr/lib/helm/* \ No newline at end of file diff --git a/stx-harbor-helm/stx-harbor-helm/files/0001-AddNodeAffinityToPods.patch b/helm-charts/upstream/harbor-helm/debian/deb_folder/patches/0001-AddNodeAffinityToPods.patch similarity index 100% rename from stx-harbor-helm/stx-harbor-helm/files/0001-AddNodeAffinityToPods.patch rename to helm-charts/upstream/harbor-helm/debian/deb_folder/patches/0001-AddNodeAffinityToPods.patch diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/patches/series b/helm-charts/upstream/harbor-helm/debian/deb_folder/patches/series new file mode 100644 index 0000000..95059eb --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/patches/series @@ -0,0 +1 @@ +0001-AddNodeAffinityToPods.patch diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/rules b/helm-charts/upstream/harbor-helm/debian/deb_folder/rules new file mode 100644 index 0000000..b1d21f2 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/rules @@ -0,0 +1,26 @@ +#!/usr/bin/make -f +# export DH_VERBOSE = 1 + +export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ') +export PATCH_VERSION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.') +export CHART_BASE_VERSION = $(shell echo $(DEB_VERSION) | sed 's/-/./' | cut -d '.' -f 1-3) +export CHART_VERSION = $(CHART_BASE_VERSION)+STX.$(PATCH_VERSION) + +export ROOT = debian/tmp +export APP_FOLDER = $(ROOT)/usr/lib/helm +%: + dh $@ +override_dh_auto_build: + # Move harbor source + mkdir -p harbor + mv $(shell ls -1 | egrep -v 'Makefile|debian' | tr '\n' ' ') harbor + + # Create the TGZ file. + make CHART_VERSION=$(CHART_VERSION) harbor + +override_dh_auto_install: + # Install the app tar file. + install -d -m 755 $(APP_FOLDER) + install -p -D -m 755 harbor*.tgz $(APP_FOLDER) +override_dh_auto_test: + diff --git a/helm-charts/upstream/harbor-helm/debian/deb_folder/source/format b/helm-charts/upstream/harbor-helm/debian/deb_folder/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/deb_folder/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/helm-charts/upstream/harbor-helm/debian/meta_data.yaml b/helm-charts/upstream/harbor-helm/debian/meta_data.yaml new file mode 100644 index 0000000..64229f4 --- /dev/null +++ b/helm-charts/upstream/harbor-helm/debian/meta_data.yaml @@ -0,0 +1,15 @@ +--- +debname: harbor-helm +debver: 1.12-1 +dl_path: + name: harbor-1.12.0.tar.gz + url: https://github.com/goharbor/harbor-helm/archive/refs/tags/v1.12.0.tar.gz + sha256sum: 0a132e920b2861db46fdc2d5dae05df4fb4a27b22c9fe679ae63e99cbd2070b8 +src_files: + - harbor-helm/files/Makefile +revision: + dist: $STX_DIST + stx_patch: 0 + GITREVCOUNT: + SRC_DIR: ${MY_REPO}/stx/app-harbor/helm-charts/upstream/harbor-helm + BASE_SRCREV: e097b7cfda6e1258151c9143f274bebec31335c9 diff --git a/stx-harbor-helm/stx-harbor-helm/files/Makefile b/helm-charts/upstream/harbor-helm/harbor-helm/files/Makefile similarity index 80% rename from stx-harbor-helm/stx-harbor-helm/files/Makefile rename to helm-charts/upstream/harbor-helm/harbor-helm/files/Makefile index eff605d..a9b44e4 100644 --- a/stx-harbor-helm/stx-harbor-helm/files/Makefile +++ b/helm-charts/upstream/harbor-helm/harbor-helm/files/Makefile @@ -1,7 +1,7 @@ # # Copyright 2017 The Openstack-Helm Authors. # -# Copyright (c) 2019 Wind River Systems, Inc. +# Copyright (c) 2024 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # @@ -25,18 +25,16 @@ $(CHARTS): init-%: if [ -f $*/Makefile ]; then make -C $*; fi - if [ -f $*/requirements.yaml ]; then helm dep up $*; fi lint-%: init-% if [ -d $* ]; then helm lint $*; fi build-%: lint-% - if [ -d $* ]; then helm package $*; fi + if [ -d $* ]; then helm package --version $(CHART_VERSION) $*; fi clean: @echo "Clean all build artifacts" rm -f */templates/_partials.tpl */templates/_globals.tpl - rm -f *tgz */charts/*tgz */requirements.lock rm -rf */charts */tmpcharts %: diff --git a/stx-harbor-helm/debian/deb_folder/changelog b/stx-harbor-helm/debian/deb_folder/changelog index d634509..0c13616 100644 --- a/stx-harbor-helm/debian/deb_folder/changelog +++ b/stx-harbor-helm/debian/deb_folder/changelog @@ -1,3 +1,9 @@ +stx-harbor-helm (1.0-2) unstable; urgency=medium + + * Update package to automatically version itself. + + -- Jagatguru Prasad Mishra Thu, 25 Apr 2024 05:41:49 +0000 + stx-harbor-helm (1.0-1) unstable; urgency=medium * Initial release. diff --git a/stx-harbor-helm/debian/deb_folder/control b/stx-harbor-helm/debian/deb_folder/control index ec53a1a..e3d19b0 100644 --- a/stx-harbor-helm/debian/deb_folder/control +++ b/stx-harbor-helm/debian/deb_folder/control @@ -3,10 +3,8 @@ Section: libs Priority: optional Maintainer: StarlingX Developers Build-Depends: debhelper-compat (= 13), - chartmuseum, helm, - procps, - python3-k8sapp-harbor, + harbor-helm, python3-k8sapp-harbor-wheels, build-info Standards-Version: 4.5.1 diff --git a/stx-harbor-helm/debian/deb_folder/copyright b/stx-harbor-helm/debian/deb_folder/copyright index ac77fe5..5318e00 100644 --- a/stx-harbor-helm/debian/deb_folder/copyright +++ b/stx-harbor-helm/debian/deb_folder/copyright @@ -3,7 +3,7 @@ Upstream-Name: stx-harbor-helm Source: https://opendev.org/starlingx/app-harbor/ Files: * -Copyright: (c) 2013-2023 Wind River Systems, Inc +Copyright: (c) 2013-2024 Wind River Systems, Inc License: Apache-2 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ License: Apache-2 # If you want to use GPL v2 or later for the /debian/* files use # the following clauses, or change it to suit. Delete these two lines Files: debian/* -Copyright: 2021 Wind River Systems, Inc +Copyright: 2024 Wind River Systems, Inc License: Apache-2 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/stx-harbor-helm/debian/deb_folder/rules b/stx-harbor-helm/debian/deb_folder/rules index e17ac4b..e5de834 100755 --- a/stx-harbor-helm/debian/deb_folder/rules +++ b/stx-harbor-helm/debian/deb_folder/rules @@ -8,11 +8,10 @@ export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 export RELEASE = $(shell cat /etc/build.info | grep SW_VERSION | cut -d'"' -f2) export REVISION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.') -export HARBOR_PKG="helm-charts-harbor-v1.12.0.tar.gz" -export HARBOR_PKG_TGZ= "helm-charts-harbor-v1.12.0.tgz" export APP_NAME = harbor export APP_VERSION = $(RELEASE)-$(REVISION) -export APP_TARBALL_FLUXCD = $(APP_NAME)-$(APP_VERSION).tgz +export APP_TARBALL = $(APP_NAME)-$(APP_VERSION).tgz +export HELM_FOLDER = /usr/lib/helm export HELM_REPO = stx-platform export STAGING = staging @@ -20,36 +19,26 @@ export STAGING = staging dh $@ override_dh_auto_build: - # Host a server for the helm charts. - chartmuseum --debug --port=8879 --context-path='/charts' --storage="local" --storage-local-rootdir="." & - sleep 2 - helm repo add local http://localhost:8879/charts - - # Extract the harbor chart - rm -rf fluxcd - mkdir -p fluxcd - tar -C fluxcd -xf $(HARBOR_PKG) - - # Apply Patches - cd fluxcd/helm-charts/ && patch --no-backup-if-mismatch --fuzz=0 -p1 < ../../files/0001-AddNodeAffinityToPods.patch - - # create a tgz file - cd fluxcd && mkdir -p output/ && mv helm-charts harbor &&tar -czvf output/$(HARBOR_PKG_TGZ) harbor/ - - # Terminate the helm chart server. - pkill chartmuseum - # Setup the staging directory. + mkdir -p $(STAGING) + cp files/metadata.yaml $(STAGING) + cp -Rv fluxcd-manifests $(STAGING) mkdir -p $(STAGING)/charts + cp /usr/lib/helm/*.tgz $(STAGING)/charts - # Copy the fluxcd manifests - cp -R fluxcd-manifests/ $(STAGING)/ - - # Copy the built chart to staging - cp fluxcd/output/$(HARBOR_PKG_TGZ) $(STAGING)/charts/ + # Adjust the helmrelease yamls based on the chart versions + for c in $(STAGING)/charts/*; do \ + chart=$$(basename $$c .tgz); \ + chart_name=$${chart%-*}; \ + chart_version=$${chart##*-}; \ + echo "Found $$chart; name: $$chart_name, version: $$chart_version"; \ + chart_manifest=$$(find $(STAGING)/fluxcd-manifests -name helmrelease.yaml -exec grep -q "chart:.*$$chart_name" {} \; -print); \ + echo "Updating manifest: $$chart_manifest"; \ + sed -i "s/REPLACE_HELM_CHART_VERSION/$$chart_version/g" $$chart_manifest; \ + grep version $$chart_manifest; \ + done # Populate metadata. - cp files/metadata.yaml $(STAGING) sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING)/metadata.yaml sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING)/metadata.yaml sed -i 's/HELM_REPLACE_REPO/$(HELM_REPO)/g' $(STAGING)/metadata.yaml @@ -58,9 +47,9 @@ override_dh_auto_build: mkdir -p $(STAGING)/plugins cp /plugins/*.whl $(STAGING)/plugins - # Generate checksum file and package the tarball + # Create the app package. cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 - tar -zcf $(APP_TARBALL_FLUXCD) -C $(STAGING)/ . + tar cfz $(APP_TARBALL) -C $(STAGING)/ . # Cleanup staging rm -rf $(STAGING) @@ -68,8 +57,8 @@ override_dh_auto_build: override_dh_auto_install: # Install the app tar file. install -d -m 755 $(APP_FOLDER) - install -p -D -m 755 $(APP_TARBALL_FLUXCD) $(APP_FOLDER) + install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER) override_dh_auto_test: -override_dh_usrlocal: +override_dh_usrlocal: \ No newline at end of file diff --git a/stx-harbor-helm/debian/meta_data.yaml b/stx-harbor-helm/debian/meta_data.yaml index 89910d7..4cd2bb1 100644 --- a/stx-harbor-helm/debian/meta_data.yaml +++ b/stx-harbor-helm/debian/meta_data.yaml @@ -1,12 +1,7 @@ --- debname: stx-harbor-helm -debver: 1.0-1 +debver: 1.0-2 src_path: stx-harbor-helm -dl_files: - helm-charts-harbor-v1.12.0.tar.gz: - topdir: helm-charts - url: https://github.com/goharbor/harbor-helm/archive/refs/tags/v1.12.0.tar.gz - md5sum: f650eba90361abe4972fa94489a54cb1 revision: dist: $STX_DIST GITREVCOUNT: diff --git a/stx-harbor-helm/stx-harbor-helm/README b/stx-harbor-helm/stx-harbor-helm/README deleted file mode 100644 index b773ef4..0000000 --- a/stx-harbor-helm/stx-harbor-helm/README +++ /dev/null @@ -1,5 +0,0 @@ -This directory contains all StarlingX charts that need to be built for this -application. Some charts are common across applications. These common charts -reside in the stx-config/kubernetes/helm-charts directory. To include these in -this application update the build_srpm.data file and use the COPY_LIST_TO_TAR -mechanism to populate these common charts. diff --git a/stx-harbor-helm/stx-harbor-helm/files/index.yaml b/stx-harbor-helm/stx-harbor-helm/files/index.yaml deleted file mode 100644 index 36db709..0000000 --- a/stx-harbor-helm/stx-harbor-helm/files/index.yaml +++ /dev/null @@ -1,3 +0,0 @@ -apiVersion: v1 -entries: {} -generated: 2019-01-07T12:33:46.098166523-06:00 diff --git a/stx-harbor-helm/stx-harbor-helm/files/repositories.yaml b/stx-harbor-helm/stx-harbor-helm/files/repositories.yaml deleted file mode 100644 index e613b63..0000000 --- a/stx-harbor-helm/stx-harbor-helm/files/repositories.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -generated: 2019-01-02T15:19:36.215111369-06:00 -repositories: -- caFile: "" - cache: /builddir/.helm/repository/cache/local-index.yaml - certFile: "" - keyFile: "" - name: local - password: "" - url: http://127.0.0.1:8879/charts - username: "" - diff --git a/stx-harbor-helm/stx-harbor-helm/fluxcd-manifests/harbor/helmrelease.yaml b/stx-harbor-helm/stx-harbor-helm/fluxcd-manifests/harbor/helmrelease.yaml index a8855c4..05a50b8 100644 --- a/stx-harbor-helm/stx-harbor-helm/fluxcd-manifests/harbor/helmrelease.yaml +++ b/stx-harbor-helm/stx-harbor-helm/fluxcd-manifests/harbor/helmrelease.yaml @@ -15,7 +15,7 @@ spec: chart: spec: chart: harbor - version: 1.12.0 + version: REPLACE_HELM_CHART_VERSION sourceRef: kind: HelmRepository name: stx-platform