Skip to content

Commit 0d9d868

Browse files
authored
Merge pull request #876 from rackerlabs/dexop
feat: dexop - operator to manage Oauth2 clients in Dex
2 parents 1e87c1a + d237a17 commit 0d9d868

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+4232
-0
lines changed

.github/workflows/build-dexop.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: build-dexop-images
3+
4+
on:
5+
workflow_dispatch:
6+
push:
7+
tags:
8+
- dexop-v*
9+
paths:
10+
- "go/dexop/**"
11+
12+
jobs:
13+
build-ghcr-registry:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
18+
steps:
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3
22+
23+
- name: Login to ghcr.io
24+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
25+
with:
26+
registry: "ghcr.io"
27+
username: ${{ github.actor }}
28+
password: ${{ secrets.GITHUB_TOKEN }}
29+
30+
- name: Extract tag name
31+
id: extract_tag
32+
run: echo "tag=${GITHUB_REF#refs/tags/dexop-v}" >> $GITHUB_OUTPUT
33+
34+
- name: Build and deploy Dexop image
35+
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6
36+
with:
37+
context: go/dexop/
38+
file: go/dexop/Dockerfile
39+
# push for all main branch commits
40+
push: ${{ github.event_name != 'pull_request' }}
41+
tags: ghcr.io/${{ github.repository }}/dexop:latest,ghcr.io/${{ github.repository }}/dexop:${{ steps.extract_tag.outputs.tag }}
42+
labels: |
43+
org.opencontainers.image.version=${{ steps.extract_tag.outputs.tag }}

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ extend-exclude = [
66
"schema/argo-workflows.json",
77
"python/understack-workflows/tests/json_samples/",
88
"containers/*/patches",
9+
"go.mod"
910
]
1011

1112
[default]

go/dexop/.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore build and test binaries.
3+
bin/

go/dexop/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/*
8+
Dockerfile.cross
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
16+
# Go workspace file
17+
go.work
18+
19+
# Kubernetes Generated files - skip generated files, except for vendored files
20+
!vendor/**/zz_generated.*
21+
22+
# editor and IDE paraphernalia
23+
.idea
24+
.vscode
25+
*.swp
26+
*.swo
27+
*~

go/dexop/.golangci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: "2"
2+
run:
3+
allow-parallel-runners: true
4+
linters:
5+
default: none
6+
enable:
7+
- dupl
8+
- errcheck
9+
- goconst
10+
- gocyclo
11+
- govet
12+
- ineffassign
13+
- lll
14+
- misspell
15+
- nakedret
16+
- prealloc
17+
- staticcheck
18+
- unconvert
19+
- unparam
20+
- unused
21+
exclusions:
22+
generated: lax
23+
rules:
24+
- linters:
25+
- lll
26+
path: api/*
27+
- linters:
28+
- dupl
29+
- lll
30+
path: internal/*
31+
paths:
32+
- third_party$
33+
- builtin$
34+
- examples$
35+
settings:
36+
staticcheck:
37+
dot-import-whitelist:
38+
- fmt
39+
- github.com/onsi/ginkgo/v2
40+
formatters:
41+
enable:
42+
- gofmt
43+
- goimports
44+
exclusions:
45+
generated: lax
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$

go/dexop/.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
golang 1.23.6

go/dexop/Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Build the manager binary
2+
FROM golang:1.23 AS builder
3+
ARG TARGETOS
4+
ARG TARGETARCH
5+
6+
WORKDIR /workspace
7+
# Copy the Go Modules manifests
8+
COPY go.mod go.mod
9+
COPY go.sum go.sum
10+
# cache deps before building and copying source so that we don't need to re-download as much
11+
# and so that source changes don't invalidate our downloaded layer
12+
RUN go mod download
13+
14+
# Copy the go source
15+
COPY cmd/main.go cmd/main.go
16+
COPY api/ api/
17+
COPY internal/controller/ internal/controller/
18+
COPY dex/ dex/
19+
20+
# Build
21+
# the GOARCH has not a default value to allow the binary be built according to the host where the command
22+
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
23+
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
24+
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
25+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
26+
27+
# Use distroless as minimal base image to package the manager binary
28+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
29+
FROM gcr.io/distroless/static:nonroot
30+
WORKDIR /
31+
COPY --from=builder /workspace/manager .
32+
USER 65532:65532
33+
34+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)