Skip to content

Commit 3de12e0

Browse files
committed
initial commit
1 parent 4e2c654 commit 3de12e0

File tree

13 files changed

+706
-1
lines changed

13 files changed

+706
-1
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker Image CI
2+
3+
# publish new image when changes are made to the
4+
# Dockerfile, main.go, or any files in the templates directory
5+
on:
6+
push:
7+
paths:
8+
- 'Dockerfile'
9+
- 'main.go'
10+
- 'templates/**'
11+
12+
env:
13+
REGISTRY: ghcr.io
14+
REPOSITORY: ${{ github.repository }}
15+
IMAGE_NAME: vault-sdk-go-app
16+
17+
jobs:
18+
build:
19+
name: Build docker images
20+
runs-on: ubuntu-latest
21+
22+
permissions:
23+
contents: read
24+
packages: write
25+
attestations: write
26+
id-token: write
27+
28+
steps:
29+
- name: checkout code
30+
uses: actions/checkout@v5
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v4
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GH_TOKEN_PACKAGES }}
37+
38+
- name: Extract metadata for Docker
39+
id: meta
40+
uses: docker/metadata-action@v4
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}
43+
tags: type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
44+
- name: Build and push Landing Page Docker image
45+
uses: docker/build-push-action@v7
46+
with:
47+
file: ./Dockerfile
48+
context: .
49+
push: true
50+
github-token: ${{ secrets.GH_TOKEN_PACKAGES }}
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
*.exe
2+
*.exe~
3+
pc
4+
**/pc
5+
*tfstate*
6+
*.zip
7+
*.tar.gz
8+
*.rar
9+
*.plan
10+
public/**
11+
themes/**
12+
**.DS_Store
13+
**.git
14+
logs/**
15+
junk/**
16+
17+
## terraform files
18+
*.tfstate
19+
*.tfstate.*
20+
.terraform/**
21+
**/.terraform/**
22+
.terraform.tfstate.lock.info
23+
**/.terraform.tfstate.lock.info
24+
tf.plan
25+
tfplan
26+
crash.log
27+
crash.*.log
28+
29+
.vscode
30+
!.vale.ini
31+
.styles/**
32+
.vscode/**
33+
**settings.json*
34+
python/public
35+
env/
36+
out/
37+
~
38+
nohup.out
39+
env/
40+
actions-runner/**
41+
token
42+
*.old

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM golang:1.25
4+
LABEL org.opencontainers.image.source=https://github.com/mister-ken/github-action-test
5+
WORKDIR /app
6+
COPY go.mod go.sum ./
7+
RUN go mod download
8+
COPY *.go ./
9+
ADD templates /app/templates
10+
RUN CGO_ENABLED=0 GOOS=linux go build -o test-vault-client
11+
EXPOSE 8080
12+
# CMD ["./test-vault-client"]
13+
CMD ["sleep", "infinity"]

Justfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
set shell := ["bash", "-c"]
2+
set positional-arguments
3+
4+
default: all
5+
all: version build deploy-k8s status test clean
6+
clean-all: clean
7+
8+
[group('k8s')]
9+
version:
10+
@echo ">> running $0"
11+
vault version
12+
docker --version
13+
kubectl version --client
14+
minikube version
15+
16+
[group('k8s')]
17+
build: clean
18+
@echo ">> running $0"
19+
docker build --tag k8s-vault-client .
20+
kubectl get secret vault-auth-secret -o json | jq -r ".data.token" | base64 --decode > token
21+
22+
[group('k8s')]
23+
deploy-k8s:
24+
@echo ">> running $0"
25+
minikube image load docker.io/library/k8s-vault-client:latest
26+
kubectl apply -f manifests/go-app.yaml
27+
echo "kubectl port-forward pod/vault-client 8080:8080"
28+
29+
[group('k8s')]
30+
status:
31+
@echo ">> running $0"
32+
kubectl get pods
33+
34+
[group('exe')]
35+
test:
36+
@echo ">> running $0"
37+
go run main.go
38+
39+
[group('docker')]
40+
test-docker:
41+
@echo ">> running $0"
42+
docker run -d --name k8s-vault-client --publish 8080:8080 k8s-vault-client
43+
44+
45+
[group('k8s')]
46+
test-k8s:
47+
@echo ">> running $0"
48+
kubectl apply -f k8s-auth/go-app.yaml
49+
echo "kubectl port-forward pod/devwebapp 8080:8080"
50+
51+
[group('k8s')]
52+
clean:
53+
@echo ">> running $0"
54+
kubectl delete -f go-app.yaml || true
55+
kubectl apply -f vault-auth-service-account.yaml || true
56+
kubectl apply -f vault-auth-secret.yaml || true
57+
minikube image rm docker.io/library/k8s-vault-client:latest || true
58+
docker stop $(docker ps -aq --filter name=k8s-vault-client) || true
59+
docker rm $(docker ps -aq --filter name=k8s-vault-client) || true

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
# learn-vault-golang-sdk
1+
# Image k8s auth with SDK
2+
3+
Container with Kubernetes authentication and the Vault Go SDK. It is used in the devdot tutorial for the Vault SDK.
4+
5+
## update image used in the tutorial
6+
7+
If you update Dockerfile, main.go or anyfile the `templates/` folder there is a github action to update the image. Check the actions tab to see if the action was a success then it will be available through a git pull.
8+
9+
```
10+
docker pull ghcr.io/mister-ken/github-action-test/k8s-vault-client:latest
11+
```
12+
13+
The the [package page](https://github.com/mister-ken/github-action-test/pkgs/container/github-action-test%2Fk8s-vault-client) for more details.
14+
>>>>>>> 2ce8bcd (initial commit)

go.mod

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
module github.gom/hashicorp/hello-vault-go/quick-start
2+
3+
go 1.23.0
4+
5+
toolchain go1.24.4
6+
7+
require (
8+
github.com/gin-gonic/gin v1.11.0
9+
github.com/hashicorp/vault/api v1.22.0
10+
github.com/hashicorp/vault/api/auth/approle v0.11.0
11+
github.com/hashicorp/vault/api/auth/aws v0.11.0
12+
github.com/hashicorp/vault/api/auth/azure v0.10.0
13+
github.com/hashicorp/vault/api/auth/gcp v0.11.0
14+
github.com/hashicorp/vault/api/auth/kubernetes v0.10.0
15+
github.com/hashicorp/vault/api/auth/userpass v0.11.0
16+
)
17+
18+
require (
19+
cloud.google.com/go/auth v0.16.2 // indirect
20+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
21+
cloud.google.com/go/compute/metadata v0.7.0 // indirect
22+
cloud.google.com/go/iam v1.5.2 // indirect
23+
github.com/aws/aws-sdk-go v1.55.7 // indirect
24+
github.com/bytedance/sonic v1.14.0 // indirect
25+
github.com/bytedance/sonic/loader v0.3.0 // indirect
26+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
27+
github.com/cloudwego/base64x v0.1.6 // indirect
28+
github.com/fatih/color v1.18.0 // indirect
29+
github.com/felixge/httpsnoop v1.0.4 // indirect
30+
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
31+
github.com/gin-contrib/sse v1.1.0 // indirect
32+
github.com/go-jose/go-jose/v4 v4.1.1 // indirect
33+
github.com/go-logr/logr v1.4.2 // indirect
34+
github.com/go-logr/stdr v1.2.2 // indirect
35+
github.com/go-playground/locales v0.14.1 // indirect
36+
github.com/go-playground/universal-translator v0.18.1 // indirect
37+
github.com/go-playground/validator/v10 v10.27.0 // indirect
38+
github.com/goccy/go-json v0.10.2 // indirect
39+
github.com/goccy/go-yaml v1.18.0 // indirect
40+
github.com/google/s2a-go v0.1.9 // indirect
41+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
42+
github.com/googleapis/gax-go/v2 v2.14.2 // indirect
43+
github.com/hashicorp/errwrap v1.1.0 // indirect
44+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
45+
github.com/hashicorp/go-hclog v1.6.3 // indirect
46+
github.com/hashicorp/go-multierror v1.1.1 // indirect
47+
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
48+
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
49+
github.com/hashicorp/go-secure-stdlib/awsutil v0.3.0 // indirect
50+
github.com/hashicorp/go-secure-stdlib/parseutil v0.2.0 // indirect
51+
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
52+
github.com/hashicorp/go-sockaddr v1.0.7 // indirect
53+
github.com/hashicorp/go-uuid v1.0.2 // indirect
54+
github.com/hashicorp/hcl v1.0.1-vault-7 // indirect
55+
github.com/jmespath/go-jmespath v0.4.0 // indirect
56+
github.com/json-iterator/go v1.1.12 // indirect
57+
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
58+
github.com/leodido/go-urn v1.4.0 // indirect
59+
github.com/mattn/go-colorable v0.1.14 // indirect
60+
github.com/mattn/go-isatty v0.0.20 // indirect
61+
github.com/mitchellh/go-homedir v1.1.0 // indirect
62+
github.com/mitchellh/mapstructure v1.5.0 // indirect
63+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
64+
github.com/modern-go/reflect2 v1.0.2 // indirect
65+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
66+
github.com/pkg/errors v0.9.1 // indirect
67+
github.com/quic-go/qpack v0.5.1 // indirect
68+
github.com/quic-go/quic-go v0.54.0 // indirect
69+
github.com/ryanuber/go-glob v1.0.0 // indirect
70+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
71+
github.com/ugorji/go/codec v1.3.0 // indirect
72+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
73+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
74+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
75+
go.opentelemetry.io/otel v1.36.0 // indirect
76+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
77+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
78+
go.uber.org/mock v0.5.0 // indirect
79+
golang.org/x/arch v0.20.0 // indirect
80+
golang.org/x/crypto v0.40.0 // indirect
81+
golang.org/x/mod v0.25.0 // indirect
82+
golang.org/x/net v0.42.0 // indirect
83+
golang.org/x/oauth2 v0.30.0 // indirect
84+
golang.org/x/sync v0.16.0 // indirect
85+
golang.org/x/sys v0.35.0 // indirect
86+
golang.org/x/text v0.27.0 // indirect
87+
golang.org/x/time v0.12.0 // indirect
88+
golang.org/x/tools v0.34.0 // indirect
89+
google.golang.org/api v0.242.0 // indirect
90+
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect
91+
google.golang.org/genproto/googleapis/api v0.0.0-20250505200425-f936aa4a68b2 // indirect
92+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
93+
google.golang.org/grpc v1.73.0 // indirect
94+
google.golang.org/protobuf v1.36.9 // indirect
95+
)

0 commit comments

Comments
 (0)