Standardize app configs (re-submission)

This is a re-submission of [1], which was reverted due to
issues with centos builds. This change can merge now that
centos is no longer supported.

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

- Remove centos files
- Fix mismatch in plugin name, set to python3-k8sapp-APP
- Standardize plugin debian files (rules, *.install)
- plugin wheels saved to /plugin instead of /plugin/<app>

Note:
- Version tracking changes made in [1] were not added here
  as they are addressed in a different commit

[1] https://review.opendev.org/c/starlingx/oidc-auth-armada-app/+/868293

Test Plan:
PASS build-pkgs
PASS wheel version updated
PASS app tarball contains wheel file

Story: 2010542
Task: 47516

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I18b99c9e68270b5dd5607ddaffb229904ac61c65
This commit is contained in:
Leonardo Fagundes Luz Serrano 2023-02-24 17:14:15 -03:00
parent 82db09f19c
commit 02cbe8403b
50 changed files with 48 additions and 306 deletions

View File

@ -32,11 +32,11 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-oidc/*
- python3-k8sapp-oidc/*
vars:
tox_envlist: py39
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:
@ -46,10 +46,10 @@
Run flake8 test for k8sapp_oidc
nodeset: debian-bullseye
files:
- python-k8sapp-oidc/*
- python3-k8sapp-oidc/*
vars:
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:
name: k8sapp-oidc-tox-pylint
@ -63,10 +63,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-oidc/*
- python3-k8sapp-oidc/*
vars:
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:
name: k8sapp-oidc-tox-bandit
@ -75,10 +75,10 @@
Run bandit test for k8sapp_oidc
nodeset: debian-bullseye
files:
- python-k8sapp-oidc/*
- python3-k8sapp-oidc/*
vars:
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:
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
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

@ -29,5 +29,5 @@ console_scripts =
cover-erase = true
verbosity = 2
[wheel]
[bdist_wheel]
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

@ -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

@ -35,5 +35,5 @@ systemconfig.helm_plugins.oidc_auth_apps =
002_oidc-client = k8sapp_oidc.helm.oidc_client:OidcClientHelm
003_secret-observer = k8sapp_oidc.helm.secret_observer:SecretObserverHelm
[wheel]
[bdist_wheel]
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
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# Create the app package.
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar cfz $(APP_TARBALL) -C $(STAGING)/ .