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: 47187

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I1088f47e7c95cc77727acff921286c550dbd0217
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-21 06:43:29 -03:00
parent 89dd9025c7
commit 12c005958c
54 changed files with 68 additions and 320 deletions

View File

@ -34,10 +34,10 @@
- starlingx/update - starlingx/update
- starlingx/utilities - starlingx/utilities
files: files:
- python-k8sapp-oidc/* - python3-k8sapp-oidc/*
vars: vars:
tox_envlist: py27 tox_envlist: py27
tox_extra_args: -c python-k8sapp-oidc/k8sapp_oidc/tox.ini tox_extra_args: -c python3-k8sapp-oidc/k8sapp_oidc/tox.ini
- job: - job:
name: k8sapp-oidc-tox-py39 name: k8sapp-oidc-tox-py39
@ -51,11 +51,11 @@
- starlingx/update - starlingx/update
- starlingx/utilities - starlingx/utilities
files: files:
- python-k8sapp-oidc/* - python3-k8sapp-oidc/*
vars: vars:
tox_envlist: py39 tox_envlist: py39
python_version: 3.9 python_version: 3.9
tox_extra_args: -c python-k8sapp-oidc/k8sapp_oidc/tox.ini tox_extra_args: -c python3-k8sapp-oidc/k8sapp_oidc/tox.ini
- job: - job:
@ -65,10 +65,10 @@
Run flake8 test for k8sapp_oidc Run flake8 test for k8sapp_oidc
nodeset: ubuntu-focal nodeset: ubuntu-focal
files: files:
- python-k8sapp-oidc/* - python3-k8sapp-oidc/*
vars: vars:
tox_envlist: flake8 tox_envlist: flake8
tox_extra_args: -c python-k8sapp-oidc/k8sapp_oidc/tox.ini tox_extra_args: -c python3-k8sapp-oidc/k8sapp_oidc/tox.ini
- job: - job:
name: k8sapp-oidc-tox-pylint name: k8sapp-oidc-tox-pylint
@ -82,10 +82,10 @@
- starlingx/update - starlingx/update
- starlingx/utilities - starlingx/utilities
files: files:
- python-k8sapp-oidc/* - python3-k8sapp-oidc/*
vars: vars:
tox_envlist: pylint tox_envlist: pylint
tox_extra_args: -c python-k8sapp-oidc/k8sapp_oidc/tox.ini tox_extra_args: -c python3-k8sapp-oidc/k8sapp_oidc/tox.ini
- job: - job:
name: k8sapp-oidc-tox-bandit name: k8sapp-oidc-tox-bandit
@ -94,10 +94,10 @@
Run bandit test for k8sapp_oidc Run bandit test for k8sapp_oidc
nodeset: ubuntu-focal nodeset: ubuntu-focal
files: files:
- python-k8sapp-oidc/* - python3-k8sapp-oidc/*
vars: vars:
tox_envlist: bandit tox_envlist: bandit
tox_extra_args: -c python-k8sapp-oidc/k8sapp_oidc/tox.ini tox_extra_args: -c python3-k8sapp-oidc/k8sapp_oidc/tox.ini
- job: - job:
name: stx-oidc-auth-armada-app-upload-git-mirror name: stx-oidc-auth-armada-app-upload-git-mirror

View File

@ -1 +0,0 @@
flock

View File

@ -1,2 +0,0 @@
stx-oidc-auth-helm
oidcauthtools

View File

@ -1,3 +0,0 @@
stx-oidc-auth-helm
oidc-auth-tools
python-k8sapp-oidc

View File

@ -1,2 +0,0 @@
stx-oidc-auth-helm
python-k8sapp-oidc

View File

@ -1 +0,0 @@
oidcauthtools-wheels

View File

@ -1 +0,0 @@
dex-0.8.2.tgz#dex#https://github.com/dexidp/helm-charts/releases/download/dex-0.8.2/dex-0.8.2.tgz#https##

View File

@ -1,3 +1,3 @@
stx-oidc-auth-helm
oidc-auth-tools oidc-auth-tools
python-k8sapp-oidc python3-k8sapp-oidc
stx-oidc-auth-helm

View File

@ -1,2 +0,0 @@
SRC_DIR="oidcauthtools"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -1,74 +0,0 @@
%global pypi_name oidcauthtools
Summary: OIDC authentication tool package
Name: %{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
BuildRequires: python-pbr >= 2.0.0
BuildRequires: python-setuptools
BuildRequires: python2-wheel
Requires: python2-mechanize
Requires: python2-html5lib
Requires: python2-webencodings
Requires: python-pbr >= 2.0.0
%description
This package contains OIDC authentication tools to obtain token
from DEX and setup kubernetes credential for a user.
%define local_bindir /usr/bin/
%define pythonroot /usr/lib/python2.7/site-packages
%prep
%setup
# Remove bundled egg-info
rm -rf *.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}
%{__python} setup.py install --root=$RPM_BUILD_ROOT \
--install-lib=%{pythonroot} \
--prefix=/usr \
--install-data=/usr/share \
--single-version-externally-managed
mkdir -p $RPM_BUILD_ROOT/wheels
install -m 644 dist/*.whl $RPM_BUILD_ROOT/wheels/
%global _buildsubdir %{_builddir}/%{name}-%{version}
install -d 755 %{buildroot}%{local_bindir}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%license LICENSE
%defattr(-,root,root,-)
/usr/bin/*
%{python2_sitelib}/oidcauthtools
%{python2_sitelib}/*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/wheels/*

View File

@ -1,3 +1,2 @@
usr/bin/oidc-auth usr/bin/oidc-auth
usr/lib/python3/dist-packages/oidcauthtools-1.0.0.egg-info/* usr/lib/python3/dist-packages/oidcauthtools*/*
usr/lib/python3/dist-packages/oidcauthtools/*

View File

@ -1,8 +1,11 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# export DH_VERBOSE = 1 # export DH_VERBOSE = 1
export PBR_VERSION=1.0.0 export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export ROOT=$(CURDIR)/debian/tmp 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
%: %:
dh $@ --with=python3 --buildsystem=pybuild dh $@ --with=python3 --buildsystem=pybuild

View File

@ -31,5 +31,5 @@ console_scripts =
cover-erase = true cover-erase = true
verbosity = 2 verbosity = 2
[wheel] [bdist_wheel]
universal = 1 universal = 1

View File

@ -1,6 +0,0 @@
SRC_DIR="k8sapp_oidc"
# Keep the SRCREV in sync with stx-oidc-auth-helm so the app version is the same
# as the plugin version
TIS_BASE_SRCREV=860834c14ba54eb047ef02bde7a1f2407ce700ad
TIS_PATCH_VER=GITREVCOUNT

View File

@ -1,52 +0,0 @@
%global app_name oidc-auth-apps
%global pypi_name k8sapp-oidc
%global sname k8sapp_oidc
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: OIDC authorization K8S app
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: OIDC authorization 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 +0,0 @@
plugins/oidc-auth-apps/*.whl

View File

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

View File

@ -1,22 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=oidc-auth-apps
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp_oidc
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)
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-oidc
debver: 1.0-1
src_path: k8sapp_oidc
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1 @@
plugins/*.whl

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 = oidc-auth-apps
export PYBUILD_NAME = k8sapp_oidc
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-oidc
debver: 1.0-1
src_path: k8sapp_oidc
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/oidc-auth-armada-app
BASE_SRCREV: 860834c14ba54eb047ef02bde7a1f2407ce700ad

View File

@ -37,5 +37,5 @@ systemconfig.helm_plugins.oidc_auth_apps =
002_oidc-client = k8sapp_oidc.helm.oidc_client:OidcClientHelm 002_oidc-client = k8sapp_oidc.helm.oidc_client:OidcClientHelm
003_secret-observer = k8sapp_oidc.helm.secret_observer:SecretObserverHelm 003_secret-observer = k8sapp_oidc.helm.secret_observer:SecretObserverHelm
[wheel] [bdist_wheel]
universal = 1 universal = 1

View File

@ -1,13 +0,0 @@
SRC_DIR="stx-oidc-auth-helm"
# Keep the SRCREV in sync with python-k8sapp-oidc so the app version is the same
# as the plugin version
TIS_BASE_SRCREV=860834c14ba54eb047ef02bde7a1f2407ce700ad
TIS_PATCH_VER=GITREVCOUNT
COPY_LIST="$PKG_BASE/$SRC_DIR/files/*"
COPY_LIST_TO_TAR="\
$STX_BASE/downloads/dex-0.8.2.tgz
$STX_BASE/helm-charts/secret-observer/secret-observer/helm-charts \
"

View File

@ -1,111 +0,0 @@
# Application tunables (maps to metadata)
%global app_name oidc-auth-apps
%global helm_repo stx-platform
# Install location
%global app_folder /usr/local/share/applications/helm
# backup location of dex overrides
%global override_backup /opt/oidc-auth-apps
# Build variables
%global helm_folder /usr/lib/helm
# the dex chart tar name
%global dex_tar_name dex-0.8.2.tgz
Summary: The StarlingX K8S application for OIDC authorization
Name: stx-oidc-auth-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: %{name}-%{version}.tar.gz
# a patch for secret observer
Patch01: 0001-move-metadata-release-for-helmv3.patch
# secret-observer source from stx/helm-charts/secret-observer
# plugin source from stx/oidc-auth-armada-app/python-k8sapp-oidc
# dex-helm source from stx/downloads/dex-0.8.2.tgz
BuildArch: noarch
BuildRequires: helm
BuildRequires: python-k8sapp-oidc
BuildRequires: python-k8sapp-oidc-wheels
%description
The StarlingX K8S application for OIDC authorization
%prep
%setup
%patch01 -p1
%build
# This chart does not require chartmuseum server since
# it has no dependency on local or stable repos.
# Make the charts. These produce a tgz file
cd helm-charts
make oidc-client
make secret-observer
# switch back to source root
cd -
# patch the dex chart
tar xf %{dex_tar_name}
rm %{dex_tar_name}
patch -p1 < files/0001-Create-new-config-value-extraStaticClients.patch
find dex -type f -print0 | xargs -0 tar zcf %{dex_tar_name}
rm -r dex
# 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
%define app_path %{_builddir}/%{app_tarball}
# Setup staging
mkdir -p %{app_staging}
cp files/metadata.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp helm-charts/*.tgz %{app_staging}/charts
cp dex*.tgz %{app_staging}/charts
cp -R fluxcd-manifests %{app_staging}/
# Copy the plugins: installed in the buildroot
mkdir -p %{app_staging}/plugins
cp /plugins/%{app_name}/*.whl %{app_staging}/plugins
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
# calculate checksum of all files in app_staging
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
# package the app
tar -zcf %app_path -C %{app_staging}/ .
# switch back to source root
cd -
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %app_path %{buildroot}/%{app_folder}
install -d -m 750 %{buildroot}/%{override_backup}
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball}
%dir %attr(750, postgres, postgres) %{override_backup}

View File

@ -45,7 +45,7 @@ override_dh_auto_build:
sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING)/metadata.yaml sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING)/metadata.yaml
# Copy the plugins: installed in the buildroot # Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins mkdir -p $(STAGING)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins cp /plugins/*.whl $(STAGING)/plugins
# Create the app package. # Create the app package.
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar cfz $(APP_TARBALL) -C $(STAGING)/ . tar cfz $(APP_TARBALL) -C $(STAGING)/ .

View File

@ -11,4 +11,6 @@ dl_files:
md5sum: bfbe56a46cf23c68d27c6a018a565d95 md5sum: bfbe56a46cf23c68d27c6a018a565d95
revision: revision:
dist: $STX_DIST dist: $STX_DIST
PKG_GITREVCOUNT: true GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/oidc-auth-armada-app
BASE_SRCREV: 860834c14ba54eb047ef02bde7a1f2407ce700ad