Skip to content

Commit

Permalink
Merge pull request #84 from nickgerace/charts
Browse files Browse the repository at this point in the history
Fix CI for charts and move CRD creation to charts
  • Loading branch information
nickgerace authored Mar 16, 2021
2 parents 48ee5e2 + 8eb5be6 commit c35f3bc
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 332 deletions.
1 change: 1 addition & 0 deletions Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN rm -rf /go/src /go/pkg
RUN if [ "${ARCH}" == "amd64" ]; then \
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0; \
fi
RUN curl -sL https://get.helm.sh/helm-v3.5.2-linux-${ARCH}.tar.gz | tar xvzf - -C /usr/local/bin --strip-components=1

ENV GO111MODULE on
ENV DAPPER_ENV REPO TAG DRONE_TAG CROSS
Expand Down
119 changes: 0 additions & 119 deletions crds/backup.yaml

This file was deleted.

94 changes: 0 additions & 94 deletions crds/resourceset.yaml

This file was deleted.

102 changes: 0 additions & 102 deletions crds/restore.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/crds/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func WriteCRD() error {
return err
}

filename := fmt.Sprintf("./crds/%s.yaml", strings.ToLower(bCrd.Spec.Names.Kind))
filename := fmt.Sprintf("./charts/rancher-backup-crd/templates/%s.yaml", strings.ToLower(bCrd.Spec.Names.Kind))
err = ioutil.WriteFile(filename, yamlBytes, 0644)
if err != nil {
return err
Expand Down
45 changes: 29 additions & 16 deletions scripts/package-helm
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
#!/bin/bash
set -e

function edit-charts() {
sed -i \
-e 's/^version:.*/version: '${1}'/' \
-e 's/^appVersion:.*/appVersion: '${1}'/' \
build/charts/rancher-backup/Chart.yaml

sed -i \
-e 's/tag:.*/tag: '${2}'/' \
build/charts/rancher-backup/values.yaml

sed -i \
-e 's/^version:.*/version: '${1}'/' \
-e 's/^appVersion:.*/appVersion: '${1}'/' \
build/charts/rancher-backup-crd/Chart.yaml
}

function package-charts() {
helm package --debug -d ./dist/artifacts ./build/charts/rancher-backup
helm package --debug -d ./dist/artifacts ./build/charts/rancher-backup-crd
}

if ! hash helm 2>/dev/null; then
exit 0
echo "Helm is not installed"
exit 1
fi

cd $(dirname $0)/..
Expand All @@ -12,19 +34,10 @@ rm -rf build/charts
mkdir -p build dist/artifacts
cp -rf charts build/

sed -i \
-e 's/version:.*/version: '${HELM_VERSION}'/' \
-e 's/appVersion:.*/appVersion: '${HELM_VERSION}'/' \
build/charts/rancher-backup/Chart.yaml
edit-charts ${HELM_VERSION} ${HELM_TAG}

sed -i \
-e 's/tag:.*/tag: '${HELM_TAG}'/' \
build/charts/rancher-backup/values.yaml

sed -i \
-e 's/version:.*/version: '${HELM_VERSION}'/' \
-e 's/appVersion:.*/appVersion: '${HELM_VERSION}'/' \
build/charts/rancher-backup-crd/Chart.yaml

helm package -d ./dist/artifacts ./build/charts/rancher-backup
helm package -d ./dist/artifacts ./build/charts/rancher-backup-crd
if ! package-charts; then
echo "package-chart or package-chart-crd failed: trying with dev variable..."
edit-charts ${HELM_VERSION_DEV} ${HELM_TAG_DEV}
package-charts
fi
Loading

0 comments on commit c35f3bc

Please sign in to comment.