-
Notifications
You must be signed in to change notification settings - Fork 135
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
ztp: CNF-11904: Update kustomize version dynamically #1906
base: master
Are you sure you want to change the base?
ztp: CNF-11904: Update kustomize version dynamically #1906
Conversation
@irinamihai: This pull request references CNF-11904 which is a valid jira issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: irinamihai The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
||
# Extract the last openshift-gitops image. | ||
gitops_version=$(echo $gitops_channel | grep -oE "[0-9.\]+") | ||
gitops_image=$(cat $index_results_file | jq --arg gitops_channel "$gitops_channel" --arg gitops_version "$gitops_version" 'select(.name == $gitops_channel) | .entries[] | select(.name | contains($gitops_version)) | .name' | tail -n 1 | tail -n 1 | sed "s/\"//g") |
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.
Such a complicated parsing!
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.
It is a bit, unfortunately. I do need to get the right image through jq.
I will look into it to see if there is an easier way.
|
||
|
||
# Render file based catalog from redhat-operator-index. | ||
podman run --rm registry.redhat.io/redhat/redhat-operator-index:$index_tag render /configs/ > $index_results_file |
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.
Are images from registry.redhat.io can be accessed without authentication?
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.
No, but AFAIK prow can pull from registry.redhat.io 🤔
c954b9f
to
47f326c
Compare
/cc @vitus133 |
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.
Added a couple of comments. Looks good!
|
||
# Extract the last openshift-gitops image. | ||
gitops_version=$(echo $gitops_channel | grep -oE "[0-9.\]+") | ||
gitops_image=$(cat $index_results_file | jq --arg gitops_channel "$gitops_channel" --arg gitops_version "$gitops_version" 'select(.name == $gitops_channel) | .entries[] | select(.name | contains($gitops_version)) | .name' | tail -n 1 | sed "s/\"//g") |
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.
You can tell jq to print the result without the double quotes by using '-r' or '--raw-output' option (also below).
# of the current openshift-gitops operator. | ||
|
||
# Check for empty parameters. | ||
if [[ -z $1 || -z $2 || -z $3 || -z $4 ]]; then |
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.
Can it be simplified by the below?
if [[ $# -ne 4 ]]; then
ztp/gitops-subscriptions/Makefile
Outdated
KUSTOMIZE_VERSION=4.4.0 | ||
KUSTOMIZE_VERSION_DEFAULT=5.2.1 | ||
KUSTOMIZE_GET_VERSION_SCRIPT=../tools/get-kustomize-version/get-gitops-operator-kustomize-version.sh | ||
KUSTOMIZE_VERSION=$(shell ./$(KUSTOMIZE_GET_VERSION_SCRIPT) v4.16 $(GITOPS_OPERATOR_SUB_FILE) $(KUSTOMIZE_VERSION_DEFAULT) $(KUSTOMIZE_VERSION_DIR) && cat $(KUSTOMIZE_VERSION_FILE)) |
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.
I want to see if we can obtain v4.16
from someplace instead of hardcoding it.
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.
May be at least worth putting it in its own variable at the top of the makefile with a note that it needs to be kept up to date?
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.
Idea: Check the current git branch; If it's "release-.*" assume "v${branchname#release-}"
is the OCP version. Otherwise fall back to some hard-coded default?
/hold |
} | ||
|
||
# Check the second parameter points to a file that exists. | ||
if ! test -f $2; then |
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.
if [[ ! -f $2 ]]; then
is more traditional
fi | ||
|
||
# Extract the latest desired openshift-gitops channel. | ||
gitops_channel=$(cat $openshift_gitops_operator_sub | grep "channel: gitops-" | awk '{print $2}') |
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.
awk can also grep; you could shorten this
gitops_channel=$(cat $openshift_gitops_operator_sub | grep "channel: gitops-" | awk '{print $2}') | |
gitops_channel=$(cat $openshift_gitops_operator_sub | awk '/channel: gitops-/ {print $2}') |
fi | ||
|
||
# Get the kustomize version. | ||
podman run --rm $argocd_image kustomize version | grep -oE "v[0-9.\]+" | grep -oE "[0-9.\]+" > $kustomize_version_file |
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.
If you changed this to just send to stdout, you wouldn't need an extra cat
or an assumption about created filenames in your Makefiles above.
Description: - update the ZTP Makefiles to dynamically determine the kustomize version to use - the kustomize version is obtained in a new script by: * looking at the redhat-operator-index & rendering the catalog * searching for the argocd image of the current gitops operator version (in gitops-subscriptions/argocd/deployment/ openshift-gitops-operator.yaml ) * getting the kustomize version from the argocd image - the default kustomize version is set to 5.2.1 for 4.16
47f326c
to
8008b8d
Compare
@irinamihai: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Description:
/cc @sabbir-47 @lack