Skip to content

Commit

Permalink
Merge pull request #97 from mallardduck/repo-reorg/combine
Browse files Browse the repository at this point in the history
[main][2/2] Repo reorg Combine
  • Loading branch information
mallardduck authored Oct 17, 2024
2 parents 8d06bd8 + 2ffaec1 commit b08a854
Show file tree
Hide file tree
Showing 189 changed files with 13,397 additions and 286 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
./.dapper
./.cache
./dist
./build
21 changes: 21 additions & 0 deletions .github/workflows/e2e/scripts/hpo-create-project-namespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

USE_RANCHER=${USE_RANCHER:-"false"}
if [ "$USE_RANCHER" = "true" ]; then
kubectl apply -f ./examples/helm-project-operator/ci/project.yaml
fi

kubectl apply -f ./examples/helm-project-operator/ci/namespace.yaml

sleep "${DEFAULT_SLEEP_TIMEOUT_SECONDS}"
if ! kubectl get namespace cattle-project-p-example; then
echo "ERROR: Expected cattle-project-p-example namespace to exist after ${DEFAULT_SLEEP_TIMEOUT_SECONDS} seconds, not found"
exit 1
fi

echo "PASS: Project Registration Namespace was created"
31 changes: 31 additions & 0 deletions .github/workflows/e2e/scripts/hpo-create-projecthelmchart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

kubectl apply -f ./examples/helm-project-operator/ci/project-helm-chart.yaml
sleep ${DEFAULT_SLEEP_TIMEOUT_SECONDS};

if ! kubectl get -n cattle-helm-system job/helm-install-project-operator-example-chart-dummy; then
echo "ERROR: Helm Install Job for Example Chart was never created after ${KUBECTL_WAIT_TIMEOUT} seconds"
echo "PROJECT HELM CHARTS:"
kubectl get projecthelmchart -n cattle-project-p-example -o yaml
echo "HELM CHARTS:"
kubectl get helmcharts -n cattle-helm-system -o yaml
echo "HELM RELEASES:"
kubectl get helmreleases -n cattle-helm-system -o yaml
echo "HELM PROJECT OPERATOR:"
kubectl logs deployment/helm-project-operator -n cattle-helm-system
exit 1
fi

if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-helm-system job/helm-install-project-operator-example-chart-dummy; then
echo "ERROR: Helm Install Job for Example Chart never completed after ${KUBECTL_WAIT_TIMEOUT} seconds"
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system
exit 1
fi
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system

echo "PASS: Adding ProjectHelmChart successfully installed Example Chart"
17 changes: 17 additions & 0 deletions .github/workflows/e2e/scripts/hpo-delete-projecthelmchart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

kubectl delete -f ./examples/helm-project-operator/ci/project-helm-chart.yaml
if kubectl get -n cattle-helm-system job/helm-delete-project-operator-example-chart-dummy --ignore-not-found; then
if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-helm-system job/helm-delete-project-operator-example-chart-dummy; then
echo "ERROR: Helm Uninstall Job for Example Chart never completed after ${KUBECTL_WAIT_TIMEOUT}"
kubectl logs job/helm-delete-project-operator-example-chart-dummy -n cattle-helm-system
exit 1
fi
fi

echo "PASS: Removing ProjectHelmChart successfully uninstalled Example Chart"
69 changes: 69 additions & 0 deletions .github/workflows/e2e/scripts/hpo-install-helm-project-operator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

latest_chart=./packages/helm-project-operator/charts

case "${KUBERNETES_DISTRIBUTION_TYPE}" in
"k3s")
cluster_args=""
kubernetes_version=$(kubectl version --short | grep "Server Version" | cut -d ' ' -f3)
case "${kubernetes_version}" in
v1.23.*)
embedded_helm_controller_fixed_version="v1.23.14"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
v1.24.*)
embedded_helm_controller_fixed_version="v1.24.8"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
*)
embedded_helm_controller_fixed_version="v1.25.4"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
esac
;;
"rke")
cluster_args=""
;;
"rke2")
cluster_args=""
kubernetes_version=$(kubectl version --short | grep "Server Version" | cut -d ' ' -f3)
case "${kubernetes_version}" in
v1.23.*)
embedded_helm_controller_fixed_version="v1.23.14"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
v1.24.*)
embedded_helm_controller_fixed_version="v1.24.8"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
*)
embedded_helm_controller_fixed_version="v1.25.4"
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
cluster_args="--set helmController.enabled=false"
fi
;;
esac
;;
*)
echo "KUBERNETES_DISTRIBUTION_TYPE=${KUBERNETES_DISTRIBUTION_TYPE} is unknown"
exit 1
esac

helm upgrade --install --create-namespace -n cattle-helm-system helm-project-operator --set image.repository=${REPO:-rancher}/helm-project-operator --set image.tag=${TAG:-dev} ${cluster_args} ${RANCHER_HELM_ARGS} ${latest_chart}

echo "PASS: Helm Project Operator has been installed"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

helm uninstall --wait -n cattle-helm-system helm-project-operator

echo "PASS: Helm Project Operator has been uninstalled"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

source $(dirname $0)/entry

cd $(dirname $0)/../../../..

if ! kubectl -n cattle-helm-system rollout status deployment helm-project-operator --timeout="${KUBECTL_WAIT_TIMEOUT}"; then
echo "ERROR: Helm Project Operator did not roll out"
kubectl get pods -n cattle-helm-system -o yaml
exit 1
fi

echo "PASS: Helm Project Operator is up and running"
27 changes: 27 additions & 0 deletions .github/workflows/hl-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "[helm-locker] CI"

on:
workflow_call:
pull_request:
push:
branches:
- main

jobs:
build:
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Set up Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name: Run CI
run: BUILD_TARGET=helm-locker make ci
53 changes: 53 additions & 0 deletions .github/workflows/hl-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "[helm-locker] CI-e2e"

on:
pull_request:
push:
branches:
- main
paths:
- 'go.mod'
- 'charts/helm-locker*/**'
- 'crds/helm-locker/**'
- 'package/Dockerfile-helm-locker'
- 'cmd/helm-locker/**'
- 'pkg/helm-locker/**'

env:
CLUSTER_NAME : e2e-ci-helm-locker
K3S_VERSION : v1.27.9-k3s1

jobs:
build:
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Set up Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- uses: azure/setup-kubectl@v3
- uses: azure/setup-helm@v3
- name: build
run: BUILD_TARGET=helm-locker make build
- name : Install k3d
run : ./.github/workflows/e2e/scripts/install-k3d.sh
- name : Setup k3d cluster
run : K3S_VERSION=${{ env.K3S_VERSION }} ./.github/workflows/e2e/scripts/setup-cluster.sh
# temporary hack to run the helm-locker controller in the k3d cluster
- name : run helm-locker
run : |
kubectl create ns cattle-helm-system
./build/bin/helm-locker &
- name : run e2e tests
run: |
k3d kubeconfig get ${{ env.CLUSTER_NAME }} > kubeconfig.yaml
export KUBECONFIG=$(pwd)/kubeconfig.yaml
cd tests && KUBECONFIG=$KUBECONFIG go test -v -race -timeout 30m ./...
69 changes: 69 additions & 0 deletions .github/workflows/hpo-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: "[helm-project-operator] ci"

env:
CGO_ENABLED: 0
YQ_VERSION: v4.44.3

on:
pull_request:
workflow_call:
inputs:
skip_build:
default: 'false'
required: false
type: string

permissions:
contents: read

jobs:
build:
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : setup Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
- uses: azure/setup-helm@v3
- name: Perform CI
run : BUILD_TARGET=helm-project-operator make ci
build-images:
if: ${{ inputs.skip_build != 'true' }}
strategy:
matrix:
arch:
- x64
- arm64
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Set up Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name : Export image version
run : |
source ./scripts/version
echo IMAGE=$IMAGE >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Helm Project Operator image
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile-helm-project-operator
push: false
tags: ${{ env.IMAGE }}
Loading

0 comments on commit b08a854

Please sign in to comment.