Skip to content

Commit

Permalink
Merge pull request #74 from rancher/repo-merge/helm-locker
Browse files Browse the repository at this point in the history
Repo restructure project - Merge helm-locker into local
  • Loading branch information
mallardduck authored Sep 25, 2024
2 parents 0a96861 + ec90559 commit 6309031
Show file tree
Hide file tree
Showing 121 changed files with 5,359 additions and 146 deletions.
File renamed without changes.
10 changes: 5 additions & 5 deletions .github/workflows/e2e/scripts/create-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ source $(dirname $0)/entry

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

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

if ! kubectl get -n cattle-helm-system job/helm-install-project-example-chart-dummy; then
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
Expand All @@ -21,11 +21,11 @@ if ! kubectl get -n cattle-helm-system job/helm-install-project-example-chart-du
exit 1
fi

if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-helm-system job/helm-install-project-example-chart-dummy; then
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-example-chart-dummy -n cattle-helm-system
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system
exit 1
fi
kubectl logs job/helm-install-project-example-chart-dummy -n cattle-helm-system
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system

echo "PASS: Adding ProjectHelmChart successfully installed Example Chart"
10 changes: 5 additions & 5 deletions .github/workflows/e2e/scripts/delete-projecthelmchart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ source $(dirname $0)/entry

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

kubectl delete -f ./examples/ci-example.yaml
if kubectl get -n cattle-helm-system job/helm-delete-project-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-example-chart-dummy; then
kubectl delete -f ./examples/helm-project-operator/ci-example.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-example-chart-dummy -n cattle-helm-system
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"
echo "PASS: Removing ProjectHelmChart successfully uninstalled Example Chart"
17 changes: 17 additions & 0 deletions .github/workflows/e2e/scripts/install-k3d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e
set -x

K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION=v5.4.6

install_k3d(){
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}}
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}"
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
}

install_k3d

k3d version
23 changes: 23 additions & 0 deletions .github/workflows/hl-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "[helm-locker] CI"

on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Set up Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run CI
run: BUILD_TARGET=helm-locker make ci
50 changes: 50 additions & 0 deletions .github/workflows/hl-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 : test-cluster
K3S_VERSION : v1.27.9-k3s1

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name : Set up Go
uses : actions/setup-go@v5
with:
go-version: 1.22
- name : Setup up kubectl
run : |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- name: Set up k3d
run : ./.github/workflows/e2e/scripts/install-k3d.sh
- name: build
run: BUILD_TARGET=helm-locker make build
- name : Setup cluster
run : CLUSTER_NAME=${{ env.CLUSTER_NAME }} K3S_VERSION=${{ env.K3S_VERSION }} ./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
./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 ./...
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml → .github/workflows/hpo-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ci
name: "[helm-project-operator] ci"

env:
CGO_ENABLED: 0
Expand Down Expand Up @@ -29,7 +29,7 @@ jobs:
helm version
- name: Perform CI
run : make ci
push-images:
build-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -45,7 +45,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile
file: ./package/Dockerfile-helm-project-operator
push: false
tags: ${{ env.IMAGE }}
platforms: linux/amd64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: E2E Helm Project Operator
name: "[helm-project-operator] E2E Helm Project Operator"

on:
workflow_dispatch:
Expand Down Expand Up @@ -88,14 +88,19 @@ jobs:

- name: Check if Helm Project Operator is up
run: ./.github/workflows/e2e/scripts/validate-helm-project-operator.sh;

- name: Check if Project Registration Namespace is auto-created on namespace detection
run: ./.github/workflows/e2e/scripts/create-project-namespace.sh;

- name: Deploy Example Chart via ProjectHelmChart CR
run: ./.github/workflows/e2e/scripts/create-projecthelmchart.sh;

- name: Delete Example Chart
run: ./.github/workflows/e2e/scripts/delete-projecthelmchart.sh;

- name: Uninstall Helm Project Operator
run: ./.github/workflows/e2e/scripts/uninstall-helm-project-operator.sh;

- name: Delete k3d cluster
if: always()
run: k3d cluster delete e2e-ci-helm-project-operator
33 changes: 33 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: golangci-lint
on:
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- run: go generate
- run: make build-chart
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56
43 changes: 0 additions & 43 deletions .github/workflows/publish-image.yaml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Publish Images"

on:
push:
tags:
- "v*"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
push:
name : Build and push helm-locker & Helm-Project-Operator images
runs-on : ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name : Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name : Setup go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name : Build, test & validate
run : BUILD_TARGET=helm-locker make ci
- name: Extract metadata (tags, labels) for helm-locker image
id: meta-locker
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/helm-locker
- name: Build and push helm-locker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile-helm-locker
push: true
tags: ${{ steps.meta-locker.outputs.tags }}
labels: ${{ steps.meta-locker.outputs.labels }}
platforms : linux/amd64,linux/arm64
- name: Extract metadata (tags, labels) for Helm-Project-Operator image
id: meta-hpo
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Helm-Project-Operator image
uses: docker/build-push-action@v5
with:
context: .
file: ./package/Dockerfile-helm-project-operator
push: true
tags: ${{ steps.meta-hpo.outputs.tags }}
labels: ${{ steps.meta-hpo.outputs.labels }}
platforms: linux/amd64,linux/arm64
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/.dapper
/.cache
/bin
!/cmd/helm-project-operator/fs/.gitkeep
/cmd/helm-project-operator/fs/*
/dist
*.swp
.idea
/helm-project-operator
/.vscode
/.vscode
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Scan through our [existing issues](https://github.com/rancher/helm-project-opera
- Using the command line:
- [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them.

3. Install or update to **Go 1.17**. For more information, see [the development guide](docs/developing.md).
3. Install or update to **Go 1.17**. For more information, see [the development guide](docs/helm-project-operator/developing.md).

4. Create a working branch and start with your changes!

Expand Down
Loading

0 comments on commit 6309031

Please sign in to comment.