Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 7f87f64

Browse files
committed
Switch to a template machanism that embeds the config directly
* Switch to goreleaser & Github workflows * Build with Go 1.17 * Disable vendoring * Update deps
1 parent 377677a commit 7f87f64

File tree

1,049 files changed

+815
-408736
lines changed

Some content is hidden

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

1,049 files changed

+815
-408736
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.17
20+
21+
- name: Build
22+
run: go build -v ./

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.17
20+
21+
- name: Run GoReleaser
22+
uses: goreleaser/goreleaser-action@v2
23+
with:
24+
distribution: goreleaser
25+
version: latest
26+
args: release --rm-dist
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
build/
22
.idea/
3+
dist/

.goreleaser.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
before:
4+
hooks:
5+
# You may remove this if you don't use go modules.
6+
- go mod tidy
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
ldflags:
11+
- -s -w
12+
- -X github.com/gini/dexter/version.VERSION={{.Version}}
13+
- -X github.com/gini/dexter/version.GITHASH={{.Commit}}
14+
- -X github.com/gini/dexter/version.DOB={{.Date}}
15+
- -X cmd.buildTimeClientID={{ if index .Env "CLIENT_ID" }}{{ .Env.CLIENT_ID }}{{ else }}""{{ end }}
16+
- -X cmd.buildTimeClientSecret={{ if index .Env "CLIENT_SECRET" }}{{ .Env.CLIENT_SECRET }}{{ else }}""{{ end }}
17+
- -X cmd.buildTimeProvider={{ if index .Env "DEFAULT_PROVIDER" }}{{ .Env.DEFAULT_PROVIDER }}{{ else }}""{{ end }}
18+
goos:
19+
- linux
20+
- darwin
21+
goarch:
22+
- amd64
23+
- arm64
24+
ignore:
25+
- goos: linux
26+
goarch: arm64
27+
universal_binaries:
28+
- replace: true
29+
archives:
30+
- replacements:
31+
darwin: Darwin
32+
linux: Linux
33+
windows: Windows
34+
amd64: x86_64
35+
checksum:
36+
name_template: 'checksums.txt'
37+
snapshot:
38+
name_template: "{{ incpatch .Version }}-next"
39+
changelog:
40+
sort: asc
41+
filters:
42+
exclude:
43+
- '^docs:'
44+
- '^test:'

.travis.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 108 deletions
This file was deleted.

README.md

Lines changed: 87 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# dexter
22

3-
[![Build Status](https://travis-ci.org/gini/dexter.svg?branch=master)](https://travis-ci.org/gini/dexter)
4-
53
`dexter` is a OIDC (OpenId Connect) helper to create a hassle-free Kubernetes login experience powered by Google or Azure as Identity Provider.
64
All you need is a properly configured Google or Azure client ID & secret.
75

@@ -50,39 +48,101 @@ writing.
5048

5149
## Installation
5250

53-
You can download a prebuilt version from the [Github release section](https://github.com/gini/dexter/releases) or build it yourself:
51+
You can download a prebuilt version from the [Github release section](https://github.com/gini/dexter/releases) or build it yourself.
52+
The easiest way to get everything set up correctly (e.g. ldflags) is to use [goreleaser](https://goreleaser.com).
5453

5554
```
56-
go get -u github.com/gini/dexter
57-
cd $GOPATH/src/github.com/gini/dexter
55+
# cd DEXTER_SOURCE
56+
# goreleaser release --snapshot --rm-dist
57+
• releasing...
58+
• loading config file file=.goreleaser.yml
59+
• loading environment variables
60+
• getting and validating git state
61+
• building... commit=377677a03da17461acf7775519518fb3336e6753 latest tag=v0.4.1
62+
• pipe skipped error=disabled during snapshot mode
63+
• parsing tag
64+
• running before hooks
65+
• running hook=go mod tidy
66+
• setting defaults
67+
• snapshotting
68+
• building snapshot... version=0.4.2-next
69+
• checking distribution directory
70+
• --rm-dist is set, cleaning it up
71+
• loading go mod information
72+
• build prerequisites
73+
• writing effective config file
74+
• writing config=dist/config.yaml
75+
• building binaries
76+
• building binary=dist/dexter_darwin_arm64/dexter
77+
• building binary=dist/dexter_darwin_amd64/dexter
78+
• building binary=dist/dexter_linux_amd64/dexter
79+
• universal binaries
80+
• creating from 2 binaries binary=dist/dexter_darwin_all/dexter
81+
• archives
82+
• creating archive=dist/dexter_0.4.2-next_Linux_x86_64.tar.gz
83+
• creating archive=dist/dexter_0.4.2-next_Darwin_all.tar.gz
84+
• calculating checksums
85+
• storing release metadata
86+
• writing file=dist/artifacts.json
87+
• writing file=dist/metadata.json
88+
• release succeeded after 8.18s
89+
```
5890

59-
# Linux
60-
OS=linux make
91+
Check `./dist` for the build that matches your platform.
6192

62-
# MacOS
63-
OS=darwin make
64-
```
93+
### Embed credentials and template
6594

66-
It is possible to embed your Google credentials into the resulting binary.
95+
You can also customize the build and embed client credentails and a default kubectl config into the binary. Again, using `goreleaser` for the build is the easiest approach.
96+
Client credentials are embedded automatically when you set two environment variables.
6797

6898
```
69-
CLIENT_ID=abc123.apps.googleusercontent.com CLIENT_SECRET=mySecret OS=linux make
99+
CLIENT_ID=abc123.apps.googleusercontent.com
100+
CLIENT_SECRET=mySecret
70101
```
71102

72-
You can streamline your user experience even more by also specifying a
73-
default provider. `dexter auth` will then run the specified provider.
103+
You can streamline your user experience even more by also specifying a default provider. `dexter auth` will then run the specified provider.
74104
Valid choices are `google` and `azure`.
75105

76106
```
77-
DEFAULT_PROVIDER=google make
107+
DEFAULT_PROVIDER=google
108+
```
109+
110+
If you want to to change the default config template that is deployed when there is no config on the system you have to replace the contents of `./tmpl/kube-config.yaml` with your valid kubectl configuration.
111+
This can come in handy if you want to pre-populate clusters and certificates.
112+
113+
```
114+
apiVersion: v1
115+
clusters:
116+
- cluster:
117+
certificate-authority-data: XXX
118+
server: https://stage.cluster:6443
119+
name: stage
120+
- cluster:
121+
certificate-authority-data: YYY
122+
server: https://production.cluster:6443
123+
name: production
124+
contexts:
125+
- context:
126+
cluster: stage
127+
user: {{ .User }}
128+
name: stage
129+
- context:
130+
cluster: production
131+
user: {{ .User }}
132+
name: production
133+
current-context: stage
134+
kind: Config
135+
preferences: {}
78136
```
79137

138+
Please make sure that you have `{{ .User }}` in all contexts that need you want to enrich with the OIDC account you are about to configure.
139+
80140
## Run dexter
81141

82142
Run `dexter` without a command to access the help screen/intro.
83143

84144
```
85-
❯ ./build/dexter_darwin_amd64
145+
❯ ./dexter
86146
.___ __
87147
__| _/____ ___ ____/ |_ ___________
88148
/ __ |/ __ \\ \/ /\ __\/ __ \_ __ \
@@ -111,9 +171,9 @@ Use "dexter [command] --help" for more information about a command.
111171
Running `dexter auth [Idp]` will start the authentication process.
112172

113173
```
114-
❯ ./build/dexter_darwin_amd64 auth --help
174+
❯ ./dexter auth --help
115175
Use a provider sub-command to authenticate against your identity provider of choice.
116-
For details go to: https://blog.gini.net/
176+
For details go to: https://gini.net/en/blog/frictionless-kubernetes-openid-connect-integration/
117177
118178
Usage:
119179
dexter auth [flags]
@@ -124,15 +184,15 @@ Available Commands:
124184
google Authenticate with the Google Identity Provider
125185
126186
Flags:
127-
-c, --callback string Callback URL. The listen address is dreived from that. (default "http://127.0.0.1:64464/callback")
128-
-i, --client-id string Google clientID (default "REDACTED")
129-
-s, --client-secret string Google clientSecret (default "REDACTED")
130-
-d, --dry-run Toggle config overwrite
131-
-h, --help help for auth
132-
-k, --kube-config string Overwrite the default location of kube config (default "/Users/dkerwin/.kube/config")
133-
-t, --kube-config-template string Template to bootstrap a empty kube config from. Must be an open HTTP endpoint serving the raw file
134-
-u, --kube-username string Username identifier in the kube config
135-
-f, --write-email string Write user email to the specified file for use with other tooling
187+
-c, --callback string Callback URL. The listen address is dreived from that. (default "http://127.0.0.1:64464/callback")
188+
-i, --client-id string Google clientID (default "REDACTED")
189+
-s, --client-secret string Google clientSecret (default "REDACTED")
190+
-d, --dry-run Toggle config overwrite
191+
-h, --help help for auth
192+
-k, --kube-config string Overwrite the default location of kube config (default "/Users/dkerwin/.kube/config")
193+
-t, --kube-template Use the embedded template when there is no kubectl configuration (default true)
194+
-u, --kube-username string Username identifier in the kube config
195+
-f, --write-email string Write user email to the specified file for use with other tooling
136196
137197
Global Flags:
138198
-v, --verbose verbose output

0 commit comments

Comments
 (0)