Compare commits
2 Commits
Author | SHA256 | Date | |
---|---|---|---|
9e14ce3cc2 | |||
dcb31ca578 |
23
.gitea/workflows/check_manifest.yaml
Normal file
23
.gitea/workflows/check_manifest.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
name: Check Release Manifest Local Charts Versions
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches-ignore:
|
||||||
|
- "devel"
|
||||||
|
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync-pr-project:
|
||||||
|
name: "Check Release Manifest Local Charts Versions"
|
||||||
|
runs-on: tumbleweed
|
||||||
|
steps:
|
||||||
|
# Waiting on PR to get merged for support in upstream action/checkout action
|
||||||
|
- uses: 'https://github.com/yangskyboxlabs/action-checkout@sha256'
|
||||||
|
name: Checkout repository
|
||||||
|
with:
|
||||||
|
object-format: 'sha256'
|
||||||
|
- name: Setup dependencies
|
||||||
|
run: |
|
||||||
|
zypper in -y python3-ruamel.yaml
|
||||||
|
- name: Check release manifest
|
||||||
|
run: |
|
||||||
|
python3 .obs/manifest-check.py --check
|
84
.obs/manifest-check.py
Executable file
84
.obs/manifest-check.py
Executable file
@@ -0,0 +1,84 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import ruamel.yaml
|
||||||
|
import pathlib
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
|
||||||
|
yaml = ruamel.yaml.YAML()
|
||||||
|
|
||||||
|
def get_chart_version(chart_name: str) -> str:
|
||||||
|
with open(f"./{chart_name}/Chart.yaml") as f:
|
||||||
|
chart = yaml.load(f)
|
||||||
|
return chart["version"]
|
||||||
|
|
||||||
|
def get_charts(chart):
|
||||||
|
if not chart["chart"].startswith("%%CHART_REPO%%"):
|
||||||
|
# Not a locally managed chart
|
||||||
|
return {}
|
||||||
|
|
||||||
|
chart_name = chart["chart"][len("%%CHART_REPO%%/%%IMG_PREFIX%%"):]
|
||||||
|
charts = { chart_name: chart["version"] }
|
||||||
|
for child_chart in chart.get("dependencyCharts", []) + chart.get("addonCharts", []):
|
||||||
|
charts.update(get_charts(child_chart))
|
||||||
|
return charts
|
||||||
|
|
||||||
|
def get_charts_list():
|
||||||
|
with open("./release-manifest-image/release_manifest.yaml") as f:
|
||||||
|
manifest = yaml.load(f)
|
||||||
|
charts = {}
|
||||||
|
for chart in manifest["spec"]["components"]["workloads"]["helm"]:
|
||||||
|
charts.update(get_charts(chart))
|
||||||
|
return charts
|
||||||
|
|
||||||
|
def check_charts(fix: bool) -> bool:
|
||||||
|
success = True
|
||||||
|
charts = get_charts_list()
|
||||||
|
to_fix = {}
|
||||||
|
for chart in charts:
|
||||||
|
expected_version = get_chart_version(chart)
|
||||||
|
if expected_version != charts[chart]:
|
||||||
|
success = False
|
||||||
|
to_fix[f'%%CHART_REPO%%/%%IMG_PREFIX%%{chart}'] = expected_version
|
||||||
|
print(f"{chart}: Expected: {expected_version}, Got: {charts[chart]}")
|
||||||
|
if fix and not success:
|
||||||
|
fix_charts(to_fix)
|
||||||
|
return True
|
||||||
|
return success
|
||||||
|
|
||||||
|
def fix_charts(to_fix):
|
||||||
|
manifest_path = pathlib.Path("./release-manifest-image/release_manifest.yaml")
|
||||||
|
manifest = yaml.load(manifest_path)
|
||||||
|
yaml.indent(mapping=2, sequence=4, offset=2)
|
||||||
|
yaml.width = 4096
|
||||||
|
for chart_index, chart in enumerate(manifest["spec"]["components"]["workloads"]["helm"]):
|
||||||
|
changed = False
|
||||||
|
if chart["chart"] in to_fix.keys():
|
||||||
|
changed = True
|
||||||
|
chart["version"] = to_fix[chart["chart"]]
|
||||||
|
for subchart_index, subchart in enumerate(chart.get("addonCharts", [])):
|
||||||
|
if subchart["chart"] in to_fix.keys():
|
||||||
|
changed = True
|
||||||
|
subchart["version"] = to_fix[subchart["chart"]]
|
||||||
|
chart["addonCharts"][subchart_index] = subchart
|
||||||
|
for subchart_index, subchart in enumerate(chart.get("dependencyCharts", [])):
|
||||||
|
if subchart["chart"] in to_fix.keys():
|
||||||
|
changed = True
|
||||||
|
subchart["version"] = to_fix[subchart["chart"]]
|
||||||
|
chart["dependencyCharts"][subchart_index] = subchart
|
||||||
|
if changed:
|
||||||
|
manifest["spec"]["components"]["workloads"]["helm"][chart_index] = chart
|
||||||
|
yaml.dump(manifest, manifest_path)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Checking charts versions in release manifest")
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-c', '--check', action='store_true')
|
||||||
|
args = parser.parse_args()
|
||||||
|
if not check_charts(not args.check):
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("All local charts in release manifest are using the right version")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
10
.pre-commit-config.yaml
Normal file
10
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
repos:
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: check-manifest
|
||||||
|
name: "Check release-manifest"
|
||||||
|
entry: .obs/manifest-check.py
|
||||||
|
language: python
|
||||||
|
additional_dependencies: ['ruamel.yaml']
|
||||||
|
pass_filenames: false
|
||||||
|
always_run: true
|
@@ -76,13 +76,13 @@ spec:
|
|||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
type: HelmChart
|
type: HelmChart
|
||||||
operatingSystem:
|
operatingSystem:
|
||||||
version: "6.0"
|
version: '6.0'
|
||||||
zypperID: "SL-Micro"
|
zypperID: SL-Micro
|
||||||
cpeScheme: "cpe:/o:suse:sl-micro:6.0"
|
cpeScheme: cpe:/o:suse:sl-micro:6.0
|
||||||
prettyName: "SUSE Linux Micro 6.0"
|
prettyName: SUSE Linux Micro 6.0
|
||||||
supportedArchs:
|
supportedArchs:
|
||||||
- "x86_64"
|
- x86_64
|
||||||
- "aarch64"
|
- aarch64
|
||||||
workloads:
|
workloads:
|
||||||
helm:
|
helm:
|
||||||
- prettyName: Rancher
|
- prettyName: Rancher
|
||||||
@@ -105,20 +105,20 @@ spec:
|
|||||||
repository: https://charts.rancher.io
|
repository: https://charts.rancher.io
|
||||||
- prettyName: MetalLB
|
- prettyName: MetalLB
|
||||||
releaseName: metallb
|
releaseName: metallb
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%metallb-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%metallb-chart'
|
||||||
version: %%CHART_MAJOR%%.0.1+up0.14.9
|
version: '%%CHART_MAJOR%%.0.1+up0.14.9'
|
||||||
- prettyName: CDI
|
- prettyName: CDI
|
||||||
releaseName: cdi
|
releaseName: cdi
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%cdi-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%cdi-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up0.4.0
|
version: '%%CHART_MAJOR%%.0.0+up0.4.0'
|
||||||
- prettyName: KubeVirt
|
- prettyName: KubeVirt
|
||||||
releaseName: kubevirt
|
releaseName: kubevirt
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%kubevirt-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%kubevirt-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up0.4.0
|
version: '%%CHART_MAJOR%%.0.0+up0.4.0'
|
||||||
addonCharts:
|
addonCharts:
|
||||||
- releaseName: kubevirt-dashboard-extension
|
- releaseName: kubevirt-dashboard-extension
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%kubevirt-dashboard-extension-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%kubevirt-dashboard-extension-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up1.2.1
|
version: '%%CHART_MAJOR%%.0.0+up1.2.1'
|
||||||
- prettyName: NeuVector
|
- prettyName: NeuVector
|
||||||
releaseName: neuvector
|
releaseName: neuvector
|
||||||
chart: neuvector
|
chart: neuvector
|
||||||
@@ -136,8 +136,8 @@ spec:
|
|||||||
version: 2.0.1
|
version: 2.0.1
|
||||||
- prettyName: EndpointCopierOperator
|
- prettyName: EndpointCopierOperator
|
||||||
releaseName: endpoint-copier-operator
|
releaseName: endpoint-copier-operator
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%endpoint-copier-operator-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%endpoint-copier-operator-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up0.2.1
|
version: '%%CHART_MAJOR%%.0.0+up0.2.1'
|
||||||
- prettyName: Elemental
|
- prettyName: Elemental
|
||||||
releaseName: elemental-operator
|
releaseName: elemental-operator
|
||||||
chart: oci://registry.suse.com/rancher/elemental-operator-chart
|
chart: oci://registry.suse.com/rancher/elemental-operator-chart
|
||||||
@@ -153,25 +153,25 @@ spec:
|
|||||||
version: 3.0.0
|
version: 3.0.0
|
||||||
- prettyName: SRIOV
|
- prettyName: SRIOV
|
||||||
releaseName: sriov-network-operator
|
releaseName: sriov-network-operator
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%sriov-network-operator-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%sriov-network-operator-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up1.4.0
|
version: '%%CHART_MAJOR%%.0.0+up1.4.0'
|
||||||
dependencyCharts:
|
dependencyCharts:
|
||||||
- releaseName: sriov-crd
|
- releaseName: sriov-crd
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%sriov-crd-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%sriov-crd-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up1.4.0
|
version: '%%CHART_MAJOR%%.0.0+up1.4.0'
|
||||||
- prettyName: Akri
|
- prettyName: Akri
|
||||||
releaseName: akri
|
releaseName: akri
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%akri-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%akri-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up0.12.20
|
version: '%%CHART_MAJOR%%.0.0+up0.12.20'
|
||||||
addonCharts:
|
addonCharts:
|
||||||
- releaseName: akri-dashboard-extension
|
- releaseName: akri-dashboard-extension
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%akri-dashboard-extension-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%akri-dashboard-extension-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up1.2.1
|
version: '%%CHART_MAJOR%%.0.0+up1.2.1'
|
||||||
- prettyName: Metal3
|
- prettyName: Metal3
|
||||||
releaseName: metal3
|
releaseName: metal3
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%metal3-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%metal3-chart'
|
||||||
version: %%CHART_MAJOR%%.0.1+up0.9.4
|
version: '%%CHART_MAJOR%%.0.1+up0.9.4'
|
||||||
- prettyName: RancherTurtles
|
- prettyName: RancherTurtles
|
||||||
releaseName: rancher-turtles
|
releaseName: rancher-turtles
|
||||||
chart: %%CHART_REPO%%/%%IMG_PREFIX%%rancher-turtles-chart
|
chart: '%%CHART_REPO%%/%%IMG_PREFIX%%rancher-turtles-chart'
|
||||||
version: %%CHART_MAJOR%%.0.0+up0.14.1
|
version: '%%CHART_MAJOR%%.0.0+up0.14.1'
|
||||||
|
Reference in New Issue
Block a user