make PKG_VERSION into a dictionary of PKG_VERSIONS

This commit is contained in:
parent dbe4a3c590
commit 7551928508
3 changed files with 18 additions and 11 deletions

View File

@ -69,7 +69,7 @@ source_packages:
```
```bash
./build.py -i k8s/kube-apiserver --package-version 1.31
./build.py -b sisyphus -i k8s/kube-apiserver --package-version '{"k8s/kube-apiserver": "1.31"}'
```
#### org/k8s/pause

View File

@ -17,7 +17,7 @@ from jinja2 import Template
ORG_DIR = Path("org")
PKG_VERSION: str = ""
PKG_VERSIONS: dict = {}
@dataclass
@ -113,8 +113,10 @@ class Tags:
if image.is_versioned and image.source_packages:
package_name = image.source_packages[0]
if mat := re.search("{{.*}}", package_name):
assert PKG_VERSION is not None
package_name = Template(package_name).render(version=PKG_VERSION)
assert PKG_VERSIONS is not None
package_name = Template(package_name).render(
version=PKG_VERSIONS[image.canonical_name]
)
version = api_get_source_package_version(branch, package_name)
if image.version_template is not None:
@ -642,9 +644,14 @@ class DockerBuilder:
"--force-rm",
f"--manifest={manifest}",
f"--platform={platforms}",
f"--build-arg=PKG_VERSION={PKG_VERSION}",
".",
]
if PKG_VERSIONS is not None and image.canonical_name in PKG_VERSIONS:
build_cmd.insert(
-1, f"--build-arg=PKG_VERSION={PKG_VERSIONS[image.canonical_name]}"
)
self.run(build_cmd, cwd=image.path)
for tag in tags[1:]:
@ -815,8 +822,9 @@ def parse_args():
help="list of stages to skip",
)
parser.add_argument(
"--package-version",
help="from which package to build",
"--package-versions",
type=json.loads,
help="json string where key is image name, value is the package version",
)
args = parser.parse_args()
@ -829,10 +837,10 @@ def parse_args():
def main():
global PKG_VERSION
global PKG_VERSIONS
args = parse_args()
PKG_VERSION = args.package_version
PKG_VERSIONS = args.package_versions
arches = args.arches
images_info = ImagesInfo()
tags = Tags(args.tags, args.latest)

View File

@ -1,6 +1,5 @@
---
is_versioned: true
version_template: v{{ version }}
source_packages:
- kubernetes{{ version }}
- k8s-trivy-node-collector
...