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

fix(chart): Updated release to not duplicate AH config #6022

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion charts/karpenter-crd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: karpenter-crd
description: A Helm chart for Karpenter Custom Resource Definitions (CRDs)
description: A Helm chart for Karpenter Custom Resource Definitions (CRDs).
type: application
version: 0.36.0
appVersion: 0.36.0
Expand Down
15 changes: 15 additions & 0 deletions charts/karpenter-crd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# karpenter-crd

![Version: 0.36.0](https://img.shields.io/badge/Version-0.36.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.36.0](https://img.shields.io/badge/AppVersion-0.36.0-informational?style=flat-square)

A Helm chart for Karpenter Custom Resource Definitions (CRDs).

**Homepage:** <https://karpenter.sh/>

## Source Code

* <https://github.com/aws/karpenter/>

----------------------------------------------

Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).
20 changes: 20 additions & 0 deletions charts/karpenter-crd/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}

----------------------------------------------

Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).
2 changes: 1 addition & 1 deletion charts/karpenter-crd/artifacthub-repo.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
repositoryID: fda7ffc4-4672-4218-8264-321ec3b4e3cc
repositoryID: 2cfb6f76-afe1-447f-b036-cd2e230d07d7
owners: []
# - name: awsadmin1
# email: [email protected]
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions charts/karpenter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ cosign verify public.ecr.aws/karpenter/karpenter:0.36.0 \
| webhook.metrics.port | int | `8001` | The container port to use for webhook metrics. |
| webhook.port | int | `8443` | The container port to use for the webhook. |

----------------------------------------------

Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).
4 changes: 3 additions & 1 deletion charts/karpenter/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ cosign verify public.ecr.aws/karpenter/karpenter:{{ template "chart.version" . }

{{ template "chart.valuesSection" . }}

{{ template "helm-docs.versionFooter" . }}
----------------------------------------------

Autogenerated from chart metadata using [helm-docs](https://github.com/norwoodj/helm-docs/).
49 changes: 39 additions & 10 deletions hack/release/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,23 @@ build() {
}

publishHelmChart() {
local oci_repo helm_chart version commit_sha build_date ah_config_file_name helm_chart_artifact helm_chart_digest
local oci_repo helm_chart version commit_sha build_date helm_chart_artifact helm_chart_digest

oci_repo="${1}"
helm_chart="${2}"
version="${3}"
commit_sha="${4}"
build_date="${5}"

ah_config_file_name="${helm_chart}/artifacthub-repo.yaml"
helm_chart_artifact="${helm_chart}-${version}.tgz"

updateAhConfig "${oci_repo}" "${helm_chart}"

yq e -i ".appVersion = \"${version}\"" "charts/${helm_chart}/Chart.yaml"
yq e -i ".version = \"${version}\"" "charts/${helm_chart}/Chart.yaml"

cd charts
if [[ -s "${ah_config_file_name}" ]] && [[ "$oci_repo" == "${RELEASE_REPO_ECR}" ]]; then
# ECR requires us to create an empty config file for an alternative
# media type artifact push rather than /dev/null
# https://github.com/aws/containers-roadmap/issues/1074
temp=$(mktemp)
echo {} > "${temp}"
oras push "${oci_repo}${helm_chart}:artifacthub.io" --config "${temp}:application/vnd.cncf.artifacthub.config.v1+yaml" "${ah_config_file_name}:application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml"
fi

helm dependency update "${helm_chart}"
helm lint "${helm_chart}"
helm package "${helm_chart}" --version "${version}"
Expand All @@ -110,6 +104,41 @@ publishHelmChart() {
cosignOciArtifact "${version}" "${commit_sha}" "${build_date}" "${oci_repo}${helm_chart}:${version}@${helm_chart_digest}"
}

updateAhConfig() {
local oci_repo helm_chart ah_config_path image_config_path image_config media_type oci_repository oci_image old_config_digest blob_digest

oci_repo="${1}"
helm_chart="${2}"

ah_config_path="./charts/${helm_chart}/artifacthub-repo.yaml"

if [[ -f "${ah_config_path}" ]] && [[ "${oci_repo}" == "${RELEASE_REPO_ECR}" ]]; then
# ECR requires us to create an empty config file for an alternative
# media type artifact push rather than /dev/null
# https://github.com/aws/containers-roadmap/issues/1074
image_config_path="$(mktemp)"
echo "{}" > "${image_config_path}"

image_config="${image_config_path}:application/vnd.cncf.artifacthub.config.v1+yaml"
media_type="application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml"
oci_repository="${oci_repo}${helm_chart}"
oci_image="${oci_repository}:artifacthub.io"

old_config_digest="$(crane digest "${oci_image}" || true)"

if [[ -n "${old_config_digest}" ]]; then
stevehipwell marked this conversation as resolved.
Show resolved Hide resolved
blob_digest="$(oras manifest fetch --output - "${oci_repository}@${old_config_digest}" | jq -r --arg mediaType "${media_type}" '.layers[] | select(.mediaType == $mediaType) | .digest')"

if [[ "$(oras blob fetch --output - "${oci_repository}@${blob_digest}")" != "$(cat "${ah_config_path}")" ]]; then
oras push --config "${image_config}" "${oci_image}" "${ah_config_path}:${media_type}"
crane delete "${oci_repository}@${old_config_digest}"
fi
else
oras push --config "${image_config}" "${oci_image}" "${ah_config_path}:${media_type}"
fi
fi
}

cosignOciArtifact() {
local version commit_sha build_date artifact

Expand Down
Loading