Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ricoberger committed Nov 28, 2024
0 parents commit 1b3b838
Show file tree
Hide file tree
Showing 35 changed files with 2,972 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
github: [ricoberger]
custom: ["https://www.paypal.me/ricoberger"]
41 changes: 41 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "@kobsio/maintainers"
assignees:
- "ricoberger"
groups:
github-actions:
patterns:
- "*"

- package-ecosystem: "docker"
directory: "/cmd/kobs"
schedule:
interval: "monthly"
reviewers:
- "@kobsio/maintainers"
assignees:
- "ricoberger"
groups:
docker:
patterns:
- "*"

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
reviewers:
- "@kobsio/maintainers"
assignees:
- "ricoberger"
groups:
gomod:
patterns:
- "*"
30 changes: 30 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name-template: "$RESOLVED_VERSION"
tag-template: "$RESOLVED_VERSION"
version-template: "v$MAJOR.$MINOR.$PATCH"
categories:
- title: "Added"
labels:
- "changelog: added"
- title: "Fixed"
labels:
- "changelog: fixed"
- title: "Changed"
labels:
- "changelog: changed"
version-resolver:
minor:
labels:
- "changelog: added"
- "changelog: changed"
patch:
labels:
- "changelog: fixed"
default: patch
category-template: "### $TITLE"
change-template: '- #$NUMBER: $TITLE @$AUTHOR'
template: |
$CHANGES
replacers:
- search: ':warning:'
replace: ':warning: _Breaking change:_ :warning:'
86 changes: 86 additions & 0 deletions .github/workflows/continuous-delivery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
name: Continuous Delivery

on:
push:
branches:
- main
tags:
- v*

jobs:
docker:
name: Docker
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Docker Tag
id: tag
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo TAG=${GITHUB_REF:10} >> $GITHUB_ENV
else
echo TAG=main >> $GITHUB_ENV
fi
- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- name: Build and Push Docker Image
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./cmd/kobs/Dockerfile
platforms: linux/amd64,linux/arm64/v8
tags: ghcr.io/${{ github.repository_owner }}/namespacerole-operator:${{ env.TAG }}

helm:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set Version
id: version
run: |
echo "VERSION=$(yq -r .version ./charts/namespacerole-operator/Chart.yaml)" >> "$GITHUB_OUTPUT"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- name: Package and Push Helm Chart
run: |
helm package ./charts/namespacerole-operator --version ${{ env.VERSION }}
helm push ./namespacerole-operator-${{ env.VERSION }}.tgz oci://${{ github.repository_owner }}/charts
39 changes: 39 additions & 0 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Continuous Integration

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

jobs:
go:
name: Go
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum

- name: Lint
run: |
make lint
- name: Test
run: |
make test
- name: Build
run: |
make build
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Release

on:
push:
branches:
- main

permissions:
contents: read

jobs:
changelog:
permissions:
contents: write
pull-requests: write
name: Changelog
runs-on: ubuntu-latest
steps:
- name: Update Changelog
uses: release-drafter/release-drafter@v6
with:
config-name: release.yaml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin/*

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.html

# Go workspace file
go.work

# Kubernetes Generated files - skip generated files, except for vendored files
!vendor/**/zz_generated.*

# editor and IDE paraphernalia
.idea
.vscode
*.swp
*.swo
*~

# Config
config
40 changes: 40 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
run:
timeout: 5m
allow-parallel-runners: true

issues:
exclude-use-default: false
exclude-rules:
- path: "internal/*"
linters:
- dupl
linters:
disable-all: true
enable:
- dupl
- errcheck
- exportloopref
- ginkgolinter
- goconst
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- staticcheck
- typecheck
- unconvert
- unparam
- unused

linters-settings:
revive:
rules:
- name: comment-spacings
goimports:
local-prefixes: github.com/kobsio/namespacerole-operator
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.23.3 AS builder
WORKDIR /workspace

COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download

COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/controller/ internal/controller/

RUN CGO_ENABLED=0 go build -a -o manager cmd/main.go

FROM alpine:3.20.3
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
ENTRYPOINT ["/manager"]
Loading

0 comments on commit 1b3b838

Please sign in to comment.