Skip to content

Commit cc2bf7d

Browse files
committed
refactor: delete fanout mode, rename values-pipeline -> appset-params-template, validate path/keys, refactor params
1 parent 70be906 commit cc2bf7d

30 files changed

Lines changed: 1064 additions & 536 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*.dll
1212
*.so
1313
*.dylib
14+
./server
1415

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

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
FROM golang:1.24 AS build
1+
FROM golang:1.22-alpine AS build
22
WORKDIR /src
3-
4-
COPY go.mod go.sum ./
3+
COPY go.mod ./
54
RUN go mod download
6-
75
COPY . .
8-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/server ./cmd/server
6+
ARG TARGETOS=linux
7+
ARG TARGETARCH=amd64
8+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -ldflags="-s -w" -o /out/argocd-appset-params-template-plugin ./cmd/server
99

1010
FROM gcr.io/distroless/static-debian12:nonroot
11-
COPY --from=build /out/server /server
12-
ENTRYPOINT ["/server"]
11+
COPY --from=build /out/argocd-appset-params-template-plugin /argocd-appset-params-template-plugin
12+
EXPOSE 4355
13+
ENTRYPOINT ["/argocd-appset-params-template-plugin"]

LICENSE

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

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1-
.PHONY: test build run
1+
BINARY := bin/argocd-appset-params-template-plugin
2+
3+
.PHONY: fmt check-fmt vet test build run clean image
4+
5+
fmt:
6+
gofmt -w ./cmd ./internal
7+
8+
check-fmt:
9+
@test -z "$$(gofmt -l ./cmd ./internal)" || (gofmt -l ./cmd ./internal && exit 1)
10+
11+
vet:
12+
go vet ./...
213

314
test:
415
go test ./...
516

617
build:
7-
go build ./cmd/server
18+
mkdir -p bin
19+
go build -o $(BINARY) ./cmd/server
820

921
run:
1022
PLUGIN_TOKEN=dev-token go run ./cmd/server
23+
24+
image:
25+
docker build -t argocd-appset-params-template-plugin:dev .
26+
27+
clean:
28+
rm -rf bin dist coverage.out *.coverprofile

cmd/server/main.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package main
22

33
import (
4+
"context"
45
"log"
56
"net/http"
7+
"os/signal"
8+
"syscall"
9+
"time"
610

7-
"github.com/mitmx/argocd-values-pipeline-plugin/internal/config"
8-
"github.com/mitmx/argocd-values-pipeline-plugin/internal/engine"
9-
"github.com/mitmx/argocd-values-pipeline-plugin/internal/server"
11+
"github.com/mitmx/argocd-appset-params-template-plugin/internal/config"
12+
"github.com/mitmx/argocd-appset-params-template-plugin/internal/engine"
13+
"github.com/mitmx/argocd-appset-params-template-plugin/internal/server"
1014
)
1115

1216
func main() {
@@ -27,7 +31,19 @@ func main() {
2731
IdleTimeout: cfg.IdleTimeout,
2832
}
2933

30-
log.Printf("values-pipeline-plugin listening on %s", cfg.Addr)
34+
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
35+
defer stop()
36+
37+
go func() {
38+
<-ctx.Done()
39+
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
40+
defer cancel()
41+
if err := httpServer.Shutdown(shutdownCtx); err != nil {
42+
log.Printf("shutdown: %v", err)
43+
}
44+
}()
45+
46+
log.Printf("argocd-appset-params-template-plugin listening on %s", cfg.Addr)
3147
if err := httpServer.ListenAndServe(); err != nil && err != http.ErrServerClosed {
3248
log.Fatalf("listen: %v", err)
3349
}

example/applicationset-fanout-example.yaml

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

example/applicationset-resolve-example.yaml

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

example/plugin-configmap.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: ApplicationSet
3+
metadata:
4+
name: clickhouse-operator
5+
namespace: argocd
6+
spec:
7+
goTemplate: true
8+
goTemplateOptions:
9+
- missingkey=error
10+
11+
generators:
12+
- matrix:
13+
generators:
14+
- clusters:
15+
selector:
16+
matchLabels:
17+
clickhouse-operator/enabled: "true"
18+
19+
- plugin:
20+
configMapRef:
21+
name: argocd-appset-params-template-plugin
22+
input:
23+
parameters:
24+
context:
25+
cluster:
26+
name: "{{ .name }}"
27+
nameNormalized: "{{ .nameNormalized }}"
28+
29+
params:
30+
appName: clickhouse-operator
31+
namespace: clickhouse-operator
32+
repoURL: https://docs.altinity.com/clickhouse-operator
33+
chart: altinity-clickhouse-operator
34+
targetRevision: 0.26.2
35+
36+
defaults:
37+
serviceMonitor:
38+
enabled: false
39+
operator:
40+
resources: {}
41+
metrics:
42+
resources: {}
43+
44+
selectorOverrides:
45+
- path: context.cluster.name
46+
overrides:
47+
do-dev0-dev-ctrl1:
48+
serviceMonitor:
49+
enabled: true
50+
operator:
51+
resources:
52+
requests:
53+
cpu: 100m
54+
memory: 320Mi
55+
metrics:
56+
resources:
57+
requests:
58+
cpu: 50m
59+
memory: 64Mi
60+
61+
template:
62+
metadata:
63+
name: "{{ .params.appName }}-{{ .context.cluster.nameNormalized }}"
64+
spec:
65+
project: default
66+
destination:
67+
name: "{{ .context.cluster.name }}"
68+
namespace: "{{ .params.namespace }}"
69+
source:
70+
repoURL: "{{ .params.repoURL }}"
71+
chart: "{{ .params.chart }}"
72+
targetRevision: "{{ .params.targetRevision }}"
73+
helm:
74+
releaseName: "{{ .params.appName }}"
75+
values: |
76+
{{- toYaml .result | nindent 12 }}

0 commit comments

Comments
 (0)