From 1396c4e251a2bf9eb8c8c22bd4bc25f847f38775 Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 17 Jun 2025 11:52:03 -0600 Subject: feat: create sts binary and run it --- .gitignore | 1 + Makefile | 10 ++++++++-- bin/entrypoint.sh | 1 + cmd/sts/main.go | 22 ++++++++++++++++++++++ pkg/sts/sts.go | 16 ++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 cmd/sts/main.go create mode 100644 pkg/sts/sts.go diff --git a/.gitignore b/.gitignore index 3c35ead..3657eff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /bin/authzd /bin/sparkled +/bin/sts .env.* /tmp /log diff --git a/Makefile b/Makefile index 07d65fb..6af1771 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,11 @@ bin/authzd: bin/sparkled: @go build -o ./bin/sparkled ./cmd/sparkled/main.go +bin/sts: + @go build -o ./bin/sts ./cmd/sts/main.go + clean: - @rm -f ./bin/authzd ./bin/sparkled + @rm -f ./bin/authzd ./bin/sparkled ./bin/sts @go clean -testcache setup: @@ -28,7 +31,7 @@ setup: @echo "Installing Python dependencies..." pip install dumb-init -build: bin/authzd bin/sparkled +build: bin/authzd bin/sparkled bin/sts test-unit: @go test -shuffle=on ./... @@ -62,6 +65,9 @@ run-envoy: run-sparkled: clean build @go tool godotenv -f .env.local,.env ./bin/sparkled +run-sts: clean build + @go tool godotenv -f .env.local,.env ./bin/sts + sh-image: build-builder-image @docker run --rm -it $(IMAGE_TAG) /bin/sh diff --git a/bin/entrypoint.sh b/bin/entrypoint.sh index a3b9a0e..c69b149 100755 --- a/bin/entrypoint.sh +++ b/bin/entrypoint.sh @@ -8,6 +8,7 @@ cd "$(dirname "$0")/.." ./bin/envoy.sh & # launch envoy in background ./bin/authzd & # launch authzd in background +./bin/sts & # launch sts in background /usr/bin/env -i - \ APP_ENV="$APP_ENV" \ diff --git a/cmd/sts/main.go b/cmd/sts/main.go new file mode 100644 index 0000000..89dd49f --- /dev/null +++ b/cmd/sts/main.go @@ -0,0 +1,22 @@ +package main + +import ( + "context" + "net/http" + "os" + + "github.com/xlgmokha/x/pkg/log" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/sts" +) + +func main() { + logger := log.New(os.Stdout, log.Fields{"app": "sts"}) + ctx := logger.WithContext(context.Background()) + + logger.Log().Str("status", "ready").Send() + pls.LogError(ctx, http.ListenAndServe( + ":9090", + sts.New(ctx), + )) +} diff --git a/pkg/sts/sts.go b/pkg/sts/sts.go new file mode 100644 index 0000000..ae75e8a --- /dev/null +++ b/pkg/sts/sts.go @@ -0,0 +1,16 @@ +package sts + +import ( + "context" + "net/http" + + "github.com/xlgmokha/x/pkg/log" + "github.com/xlgmokha/x/pkg/x" +) + +func New(ctx context.Context) http.Handler { + return x.Middleware[http.Handler]( + http.NewServeMux(), + log.HTTP(log.From(ctx)), + ) +} -- cgit v1.2.3