Skip to content
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

Make the name of the override-snapshot predictable #3344

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions hack/generate/override-snapshot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function create_component_snapshot {
apiVersion: appstudio.redhat.com/v1alpha1
kind: Snapshot
metadata:
generateName: serverless-operator-${so_version}-override-snapshot-
name: serverless-operator-${so_version}-override-snapshot
labels:
test.appstudio.openshift.io/type: override
application: serverless-operator-${so_version}
Expand Down Expand Up @@ -87,6 +87,8 @@ EOF
# ^ we take the images from the catalogs relatedImages section for the given SO version. We could also extract the bundle image from the catalog (jq -r '. | select(.name == "serverless-operator.v'${so_semversion}'") | .image')
# and extract the CSV from there and use the CSVs relatedImages section.

append_hash_to_snapshot_name "${snapshot_file}"

rm -rf "${tmp_catalog_dir}"
}

Expand All @@ -105,7 +107,7 @@ function create_fbc_snapshots {
apiVersion: appstudio.redhat.com/v1alpha1
kind: Snapshot
metadata:
generateName: serverless-operator-${so_version}-fbc-${ocp_version}-override-snapshot-
name: serverless-operator-${so_version}-fbc-${ocp_version}-override-snapshot
labels:
test.appstudio.openshift.io/type: override
application: serverless-operator-${so_version}-fbc-${ocp_version}
Expand All @@ -117,9 +119,19 @@ EOF
index_image_digest="$(skopeo inspect --no-tags docker://"${index_image}:latest" | jq -r .Digest)"
add_component "${snapshot_file}" "serverless-index-${so_version}-fbc-${ocp_version}" "${index_image}@${index_image_digest}"

append_hash_to_snapshot_name "${snapshot_file}"

done <<< "$(yq read "${rootdir}/olm-catalog/serverless-operator/project.yaml" 'requirements.ocpVersion.list[*]')"
}

function append_hash_to_snapshot_name {
file=${1}
sha_sum="$(sha256sum "$file" | head -c 8)" # get first 8 chars of sha
new_name="$(yq read "$file" metadata.name)-$sha_sum"

yq write --inplace "$file" metadata.name "$new_name"
}

target_dir="${1:?Provide a target directory for the override snapshots as arg[1]}"
create_component_snapshot "${target_dir}"
create_fbc_snapshots "${target_dir}"
Loading