Skip to content
Draft
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
56 changes: 56 additions & 0 deletions .github/workflows/cleaner-operator-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Push Cleanup Operator

on:
push:
branches: ["main"]
paths:
- "operators/cleaner/**"
workflow_dispatch:

permissions:
contents: read

env:
REGISTRY: altinnplatformvalidationtests.azurecr.io
IMAGE_NAME: cleanup-controller

jobs:
build-and-push:
runs-on: ubuntu-latest
environment: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./operators/cleaner/go.mod

- name: Azure Login
uses: azure/login@532459ea530d8321f2fb9bb10d1e0bcf23869a43 # v3.0.0
with:
client-id: "${{ secrets.AZURE_CLIENT_ID }}"
tenant-id: "${{ secrets.AZURE_TENANT_ID }}"
subscription-id: "${{ secrets.AZURE_SUBSCRIPTION_ID }}"

- name: Login to ACR
run: |
az acr login --name ${{ env.REGISTRY }}

- name: Set image tag
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "img=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Build Docker image (Kubebuilder)
run: |
make docker-build IMG=${{ steps.vars.outputs.img }}
working-directory: ./operators/cleaner

- name: Push Docker image (Kubebuilder)
run: |
make docker-push IMG=${{ steps.vars.outputs.img }}
working-directory: ./operators/cleaner
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
41 changes: 41 additions & 0 deletions .github/workflows/cleaner-operator-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Cleanup Operator

on:
workflow_dispatch:
inputs:
image_tag:
description: "Image tag to deploy (e.g. sha, semver, latest)"
required: true
type: string

permissions:
contents: "read"

env:
REGISTRY: altinnplatformvalidationtests.azurecr.io
IMAGE_NAME: cleanup-controller

jobs:
deploy:
runs-on: ubuntu-latest
environment: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup k8s client
uses: ./.github/actions/setup-k8s
with:
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Build full image reference
id: img
run: |
echo "image=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.image_tag }}" >> $GITHUB_OUTPUT

- name: Deploy operator
run: |
make deploy IMG=${{ steps.img.outputs.image }}
33 changes: 33 additions & 0 deletions .github/workflows/cleaner-operator-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint

on:
push:
pull_request:

permissions: {}

jobs:
lint:
permissions:
contents: read
name: Run on Ubuntu
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operators/cleaner

steps:
- name: Clone the code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: ./operators/cleaner/go.mod

- name: Check linter configuration
run: make lint-config
- name: Run linter
run: make lint
42 changes: 42 additions & 0 deletions .github/workflows/cleaner-operator-test-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: E2E Tests

on:
push:
pull_request:

permissions: {}

jobs:
test-e2e:
permissions:
contents: read
name: Run on Ubuntu
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operators/cleaner

steps:
- name: Clone the code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: operators/cleaner/go.mod

- name: Install the latest version of kind
run: |
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(go env GOARCH)
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

- name: Verify kind installation
run: kind version

- name: Running Test e2e
run: |
go mod tidy
make test-e2e
33 changes: 33 additions & 0 deletions .github/workflows/cleaner-operator-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Tests

on:
push:
pull_request:

permissions: {}

jobs:
test:
permissions:
contents: read
name: Run on Ubuntu
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./operators/cleaner

steps:
- name: Clone the code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Setup Go
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
with:
go-version-file: operators/cleaner/go.mod

- name: Running Tests
run: |
go mod tidy
make test
11 changes: 11 additions & 0 deletions operators/cleaner/.custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file configures golangci-lint with module plugins.
# When you run 'make lint', it will automatically build a custom golangci-lint binary
# with all the plugins listed below.
#
# See: https://golangci-lint.run/plugins/module-plugins/
version: v2.11.4
plugins:
# logcheck validates structured logging calls and parameters (e.g., balanced key-value pairs)
- module: "sigs.k8s.io/logtools"
import: "sigs.k8s.io/logtools/logcheck/gclplugin"
version: latest
35 changes: 35 additions & 0 deletions operators/cleaner/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "Kubebuilder DevContainer",
"image": "golang:1.25",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": false,
"dockerDefaultAddressPool": "base=172.30.0.0/16,size=24"
},
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/common-utils:2": {
"upgradePackages": true
}
},

"runArgs": ["--privileged", "--init"],

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-azuretools.vscode-docker"
]
}
},

"remoteEnv": {
"GO111MODULE": "on"
},

"onCreateCommand": "bash .devcontainer/post-install.sh"
}

Loading
Loading