-
Notifications
You must be signed in to change notification settings - Fork 183
cmd-import: also populate coreos-assembler.config-gitrev #4282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is older than coreos-assembler.container-config-git and is used in various places in the pipeline/CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly adds the coreos-assembler.config-gitrev metadata field during OCI image import, ensuring compatibility with older pipeline components. The change is straightforward and well-implemented. I have one suggestion to improve maintainability by replacing magic strings for dictionary keys with constants.
| source = metadata.get('Labels', {}).get('org.opencontainers.image.source') | ||
| commit = metadata.get('Labels', {}).get('org.opencontainers.image.revision') | ||
| if source and commit: | ||
| meta['coreos-assembler.container-config-git'] = { | ||
| 'origin': source, | ||
| 'commit': commit, | ||
| } | ||
| meta['coreos-assembler.config-gitrev'] = commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve maintainability and avoid potential typos from magic strings, consider defining the dictionary keys used here as constants. This is particularly useful for keys that are part of a specification (like OCI labels) or are shared across different parts of the codebase.
You could define them at the top of the file, for example:
# OCI image spec labels
OCI_LABEL_SOURCE = 'org.opencontainers.image.source'
OCI_LABEL_REVISION = 'org.opencontainers.image.revision'
# COSA metadata keys
COSA_META_CONTAINER_CONFIG_GIT = 'coreos-assembler.container-config-git'
COSA_META_CONFIG_GITREV = 'coreos-assembler.config-gitrev'And then use these constants in this block:
source = metadata.get('Labels', {}).get(OCI_LABEL_SOURCE)
commit = metadata.get('Labels', {}).get(OCI_LABEL_REVISION)
if source and commit:
meta[COSA_META_CONTAINER_CONFIG_GIT] = {
'origin': source,
'commit': commit,
}
meta[COSA_META_CONFIG_GITREV] = commit
Does this advocate for us finding and fixing those few places rather than adding 2nd order backwards compat? |
The .config-gitrev is legacy. Let's update to use the newer API. xref: coreos/coreos-assembler#4282
The .config-gitrev is legacy. Let's update to use the newer API. xref: coreos/coreos-assembler#4282
At least here is a start: |
The .config-gitrev is legacy. Let's update to use the newer API. xref: coreos/coreos-assembler#4282
|
Yup, sure. Trying to fix clients SGTM too. |
The .config-gitrev is legacy. Let's update to use the newer API. xref: coreos/coreos-assembler#4282
The .config-gitrev is legacy. Let's update to use the newer API. xref: coreos/coreos-assembler#4282
This is older than coreos-assembler.container-config-git and is used in various places in the pipeline/CI.