Standardize app configs

Fixed versioning and adjusted some build files
to bring them as close to a standard as possible.

- Removed centos files
- Added version tracking via GITREVCOUNT
- Fixed mismatch in plugin name, set to python3-k8sapp-<app>
- Standardized plugin debian files (rules, *.install)
- Plugin wheels saved to /plugin instead of /plugin/<app>

Test Plan:
PASS - Build-pkgs -a
PASS - Build-image
PASS - Install, bootstrap, unlock
PASS - app tarball contains wheel file
PASS - wheel versioning updated properly

Story: 2010542
Task: 47188

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I0b1885aa3902c1225931c450fd854bbae72398f8
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-21 06:41:06 -03:00
parent 0a65cd0d90
commit 2ab4107716
47 changed files with 59 additions and 257 deletions

View File

@ -30,10 +30,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-cert-manager/*
- python3-k8sapp-cert-manager/*
vars:
tox_envlist: py27
tox_extra_args: -c python-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
tox_extra_args: -c python3-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
- job:
name: k8sapp-cert-mgr-tox-flake8
@ -42,10 +42,10 @@
Run flake8 test for k8sapp-cert-manager
nodeset: ubuntu-focal
files:
- python-k8sapp-cert-manager/*
- python3-k8sapp-cert-manager/*
vars:
tox_envlist: flake8
tox_extra_args: -c python-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
tox_extra_args: -c python3-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
- job:
name: k8sapp-cert-mgr-tox-pylint
@ -59,10 +59,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-cert-manager/*
- python3-k8sapp-cert-manager/*
vars:
tox_envlist: pylint
tox_extra_args: -c python-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
tox_extra_args: -c python3-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
- job:
name: k8sapp-cert-mgr-tox-bandit
@ -71,10 +71,10 @@
Run bandit test for k8sapp-cert-manager
nodeset: ubuntu-focal
files:
- python-k8sapp-cert-manager/*
- python3-k8sapp-cert-manager/*
vars:
tox_envlist: bandit
tox_extra_args: -c python-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
tox_extra_args: -c python3-k8sapp-cert-manager/k8sapp_cert_manager/tox.ini
- job:
name: stx-cert-manager-armada-app-upload-git-mirror

View File

@ -1 +0,0 @@
flock

View File

@ -1 +0,0 @@
stx-cert-manager-helm

View File

@ -1,2 +0,0 @@
stx-cert-manager-helm
python-k8sapp-cert-manager

View File

@ -1,2 +0,0 @@
stx-cert-manager-helm
python-k8sapp-cert-manager

View File

@ -1,2 +0,0 @@
helm-charts-certmanager-1d6ecc9cf8d841782acb5f3d3c28467c24c5fd18.tar.gz#helm-charts-certmanager#https://github.com/jetstack/cert-manager/archive/1d6ecc9cf8d841782acb5f3d3c28467c24c5fd18.tar.gz#http##
helm-charts-certmanager-1.7.1.tar.gz#helm-charts#https://github.com/cert-manager/cert-manager/archive/refs/tags/v1.7.1.tar.gz#http##

View File

@ -1,2 +1,2 @@
python-k8sapp-cert-manager
stx-cert-manager-helm
python3-k8sapp-cert-manager
stx-cert-manager-helm

View File

@ -1,8 +0,0 @@
SRC_DIR="k8sapp_cert_manager"
OPT_DEP_LIST="$STX_BASE/cert-manager-armada-app/stx-cert-manager-helm"
# Keep the SRCREV in sync with stx-cert-manager-helm so the app version is the
# same as the plugin version
TIS_BASE_SRCREV=94d4c26f982e2e8c222517900c504580d1e3a09d
TIS_PATCH_VER=GITREVCOUNT

View File

@ -1,52 +0,0 @@
%global app_name cert-manager
%global pypi_name k8sapp-cert-manager
%global sname k8sapp_cert_manager
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: Cert Manager
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-pip
BuildRequires: python2-wheel
%description
StarlingX sysinv extensions: Certificate Manager K8S app
%prep
%setup
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}.%{tis_patch_ver}
export SKIP_PIP_INSTALL=1
%{__python2} setup.py install --skip-build --root %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/plugins/%{app_name}
install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/%{app_name}/
%files
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/plugins/*

View File

@ -1,2 +0,0 @@
usr/lib/python3/dist-packages/k8sapp_cert_manager-1.0.0.egg-info/*
usr/lib/python3/dist-packages/k8sapp_cert_manager/*

View File

@ -1,25 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=cert-manager
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp_cert_manager
export ROOT=debian/tmp
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_install:
python3 setup.py install --install-layout=deb --root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins/$(APP_NAME)
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
# (tbogue) FIXME
PYTHONDIR=$(CURDIR) stestr run || true
endif

View File

@ -1,7 +0,0 @@
---
debname: python3-k8sapp-cert-manager
debver: 1.0-1
src_path: k8sapp_cert_manager
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1 @@
usr/lib/python3/dist-packages/k8sapp_*

View File

@ -0,0 +1,33 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME = cert-manager
export PYBUILD_NAME = k8sapp_cert_manager
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export MAJOR = $(shell echo $(DEB_VERSION) | cut -f 1 -d '-')
export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export PBR_VERSION = $(MAJOR).$(MINOR_PATCH)
export ROOT = $(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL = 1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_install:
env | sort
python3 setup.py install \
--install-layout=deb \
--root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
override_dh_auto_test:
PYTHONDIR=$(CURDIR) stestr run

View File

@ -0,0 +1,9 @@
---
debname: python3-k8sapp-cert-manager
debver: 1.0-1
src_path: k8sapp_cert_manager
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/cert-manager-armada-app
BASE_SRCREV: df8fc0aa19972d84f0198ad5beff3bbcd654844b

View File

@ -39,5 +39,5 @@ systemconfig.helm_plugins.cert_manager =
systemconfig.app_lifecycle =
cert-manager = k8sapp_cert_manager.lifecycle.lifecycle_cert_manager:CertManagerAppLifecycleOperator
[wheel]
[bdist_wheel]
universal = 1

View File

@ -1,21 +0,0 @@
SRC_DIR="stx-cert-manager-helm"
# Keep the SRCREV in sync with python-k8sapp-cert-manager so the app version is
# the same as the plugin version
TIS_BASE_SRCREV=94d4c26f982e2e8c222517900c504580d1e3a09d
TIS_PATCH_VER=GITREVCOUNT
TAR_NAME=helm-charts-certmanager
CM_VERSION=1.7.1
TARBALL="$TAR_NAME-$CM_VERSION.tar.gz"
COPY_LIST="${CGCS_BASE}/downloads/$TARBALL $PKG_BASE/$SRC_DIR/files/* $PKG_BASE/$SRC_DIR/fluxcd-manifests/*"
COPY_LIST_TO_TAR="\
$STX_BASE/helm-charts/psp-rolebinding/psp-rolebinding/helm-charts \
"
OPT_DEP_LIST="\
$STX_BASE/cert-manager-armada-app/python-k8sapp-cert-manager \
"

View File

@ -1,120 +0,0 @@
# Application tunables (maps to metadata)
%global app_name cert-manager
%global helm_repo stx-platform
# Install location
%global app_folder /usr/local/share/applications/helm
# Build variables
%global helm_folder /usr/lib/helm
%global cm_version 1.7.1
Summary: StarlingX Cert-Manager Application FluxCD Helm Charts
Name: stx-cert-manager-helm
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: helm-charts-certmanager-%{version}.tar.gz
Source1: Makefile
Source2: 0001-Patch-for-acmesolver-and-chartyaml-cm-v1.7.1.patch
Source3: helm-charts-certmanager-%{cm_version}.tar.gz
BuildArch: noarch
BuildRequires: helm
BuildRequires: chartmuseum
BuildRequires: python-k8sapp-cert-manager
BuildRequires: python-k8sapp-cert-manager-wheels
%description
StarlingX Cert-Manager Application FluxCD Helm Charts
%prep
%setup -n helm-charts-certmanager-%{version}
%build
# Host a server for the charts
chartmuseum --debug --port=8879 --context-path='/charts' --storage="local" --storage-local-rootdir="." &
sleep 2
helm repo add local http://localhost:8879/charts
# Make psp-rolebinding chart. These produce a tgz file
cd helm-charts
make psp-rolebinding
cd -
# Extract the cert-manager chart
cd %{_builddir}
rm -rf fluxcd
/usr/bin/mkdir -p fluxcd
cd fluxcd
/usr/bin/tar xfv %{SOURCE3}
# Apply patches with our modifications
cd %{_builddir}/fluxcd/helm-charts
cp %{SOURCE2} .
patch -p1 < %{SOURCE2}
# Copy CRD yaml files to templates
cp deploy/crds/*.yaml deploy/charts/cert-manager/templates/
# Copy Makefile
cd deploy/charts
cp %{SOURCE1} .
# Remove files causing lint error from cert-manager release
rm cert-manager/templates/BUILD.bazel
rm cert-manager/templates/deployment.yaml.orig
# Make the updated cert-manager helm-chart
make cert-manager
mv *.tgz %{app_name}-%{version}-%{tis_patch_ver}.tgz
cd -
# Terminate helm server (the last background task)
kill %1
# Create a chart tarball compliant with sysinv kube-app.py
%define app_staging %{_builddir}/staging
%define app_tarball %{app_name}-%{version}-%{tis_patch_ver}.tgz
# Setup the staging directory
cd %{_builddir}/helm-charts-certmanager-%{version}
mkdir -p %{app_staging}
cp files/metadata.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp %{_builddir}/fluxcd/helm-charts/deploy/charts/*.tgz %{app_staging}/charts
cp %{_builddir}/helm-charts-certmanager-%{version}/helm-charts/psp*.tgz %{app_staging}/charts
cp -Rv fluxcd-manifests %{app_staging}/
cd %{app_staging}
# Populate metadata
sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml
sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml
sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p %{app_staging}/plugins
cp /plugins/%{app_name}/*.whl %{app_staging}/plugins
# Generate checksum file and package the tarball
cd -
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar -zcf %{_builddir}/%{app_tarball} -C %{app_staging}/ .
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %{_builddir}/%{app_tarball} %{buildroot}/%{app_folder}
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball}

View File

@ -68,7 +68,7 @@ override_dh_auto_build:
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# Generate checksum file and package the tarball
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5

View File

@ -14,4 +14,6 @@ dl_files:
md5sum: 5e3db9fc3aed832e69ddd50d608260a5
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/cert-manager-armada-app
BASE_SRCREV: df8fc0aa19972d84f0198ad5beff3bbcd654844b