chore: migrate yq to V4

This commit is contained in:
Stefan Reimer 2021-12-15 23:19:52 +01:00
parent 7ff4bc9491
commit 1e0ed36280
5 changed files with 18 additions and 15 deletions

View File

@ -4,8 +4,8 @@ set -ex
### TODO
# - https://istio.io/latest/docs/ops/configuration/security/harden-docker-images/
export ISTIO_VERSION=$(yq r Chart.yaml dependencies.name==base.version)
export KIALI_VERSION=$(yq r Chart.yaml dependencies.name==kiali-server.version)
export ISTIO_VERSION=$(yq eval '.dependencies[] | select(.name=="base") | .version' Chart.yaml)
export KIALI_VERSION=$(yq eval '.dependencies[] | select(.name=="kiali-server") | .version' Chart.yaml)
rm -rf istio
curl -sL "https://github.com/istio/istio/releases/download/${ISTIO_VERSION}/istio-${ISTIO_VERSION}-linux-amd64.tar.gz" | tar xz

View File

@ -1,8 +1,9 @@
#!/bin/bash
set -ex
ECK_VERSION=$(yq r Chart.yaml dependencies.name==eck-operator.version)
FLUENT_BIT_VERSION=$(yq r Chart.yaml dependencies.name==fluent-bit.version)
FLUENTD_VERSION=$(yq r Chart.yaml dependencies.name==fluentd.version)
ECK_VERSION=$(yq eval '.dependencies[] | select(.name=="eck-operator") | .version' Chart.yaml)
FLUENT_BIT_VERSION=$(yq eval '.dependencies[] | select(.name=="fluent-bit") | .version' Chart.yaml)
FLUENTD_VERSION=$(yq eval '.dependencies[] | select(.name=="fluentd") | .version' Chart.yaml)
# fix ECK crds handling to adhere to proper helm v3 support which also fixes ArgoCD applying updates on upgrades
helm repo list | grep elastic -qc || { helm repo add elastic https://helm.elastic.co; helm repo update; }
@ -12,7 +13,7 @@ rm -rf charts/eck-operator && helm pull elastic/eck-operator --untar --untardir
mkdir charts/eck-operator/crds
helm template charts/eck-operator/charts/eck-operator-crds --name-template logging > charts/eck-operator/crds/all-crds.yaml
rm -rf charts/eck-operator/charts
yq d charts/eck-operator/Chart.yaml dependencies -i
yq eval -Mi 'del(.dependencies)' charts/eck-operator/Chart.yaml
# Fluent Bit
rm -rf charts/fluent-bit

View File

@ -1,7 +1,8 @@
#!/bin/bash
set -ex
VERSION=$(yq r Chart.yaml dependencies.name==kube-prometheus-stack.version)
PG_VER=$(yq r Chart.yaml dependencies.name==prometheus-pushgateway.version)
VERSION=$(yq eval '.dependencies[] | select(.name=="kube-prometheus-stack") | .version' Chart.yaml)
PG_VER=$(yq eval '.dependencies[] | select(.name=="prometheus-pushgateway") | .version' Chart.yaml)
rm -rf charts/kube-prometheus-stack
helm pull prometheus-community/kube-prometheus-stack --untar --untardir charts --version $VERSION

View File

@ -8,14 +8,15 @@ helm pull fairwinds-stable/gemini --untar --untardir charts
patch -p0 -i gemini.patch --no-backup-if-mismatch
### EBS
VERSION=$(yq r Chart.yaml dependencies.name==aws-ebs-csi-driver.version)
VERSION=$(yq eval '.dependencies[] | select(.name=="aws-ebs-csi-driver") | .version' Chart.yaml)
rm -rf charts/aws-ebs-csi-driver
curl -L -s -o - https://github.com/kubernetes-sigs/aws-ebs-csi-driver/releases/download/helm-chart-aws-ebs-csi-driver-${VERSION}/aws-ebs-csi-driver-${VERSION}.tgz | tar xfz - -C charts
patch -i ebs.patch -p0 --no-backup-if-mismatch
### EFS
VERSION=$(yq r Chart.yaml dependencies.name==aws-efs-csi-driver.version)
VERSION=$(yq eval '.dependencies[] | select(.name=="aws-efs-csi-driver") | .version' Chart.yaml)
rm -rf charts/aws-efs-csi-driver
curl -L -s -o - https://github.com/kubernetes-sigs/aws-efs-csi-driver/releases/download/helm-chart-aws-efs-csi-driver-${VERSION}/aws-efs-csi-driver-${VERSION}.tgz | tar xfz - -C charts
patch -i efs.patch -p0 --no-backup-if-mismatch

View File

@ -89,14 +89,14 @@ function _helm() {
local module=$2
local chart="kubezero-${module}"
local namespace=$(yq r $TMPDIR/kubezero/templates/${module}.yaml spec.destination.namespace)
local namespace="$(yq eval '.spec.destination.namespace' $TMPDIR/kubezero/templates/${module}.yaml)"
targetRevision=""
_version="$(yq r $TMPDIR/kubezero/templates/${module}.yaml spec.source.targetRevision)"
_version="$(yq eval '.spec.source.targetRevision' $TMPDIR/kubezero/templates/${module}.yaml)"
[ -n "$_version" ] && targetRevision="--version $_version"
yq r $TMPDIR/kubezero/templates/${module}.yaml 'spec.source.helm.values' > $TMPDIR/values.yaml
yq eval '.spec.source.helm.values' $TMPDIR/kubezero/templates/${module}.yaml > $TMPDIR/values.yaml
if [ $action == "crds" ]; then
# Allow custom CRD handling
@ -171,10 +171,10 @@ if [ ! -f $CLUSTER/kubezero/application.yaml ]; then
exit 1
fi
KUBEZERO_VERSION=$(yq r $CLUSTER/kubezero/application.yaml 'spec.source.targetRevision')
KUBEZERO_VERSION=$(yq eval '.spec.source.targetRevision' $CLUSTER/kubezero/application.yaml)
# Extract all kubezero values from argo app
yq r $CLUSTER/kubezero/application.yaml 'spec.source.helm.values' > $TMPDIR/values.yaml
yq eval '.spec.source.helm.values' $CLUSTER/kubezero/application.yaml > $TMPDIR/values.yaml
# Render all enabled Kubezero modules
helm template $(chart_location kubezero) -f $TMPDIR/values.yaml --version $KUBEZERO_VERSION --devel --output-dir $TMPDIR