summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-17 11:52:03 -0600
committermo khan <mo@mokhan.ca>2025-06-17 11:52:03 -0600
commit1396c4e251a2bf9eb8c8c22bd4bc25f847f38775 (patch)
treec6ae0cbc1e6f3ab464547914068e1416324d7a61
parentc1606e1851c28160266a8f43cc77d22bf4a8913e (diff)
feat: create sts binary and run it
-rw-r--r--.gitignore1
-rw-r--r--Makefile10
-rwxr-xr-xbin/entrypoint.sh1
-rw-r--r--cmd/sts/main.go22
-rw-r--r--pkg/sts/sts.go16
5 files changed, 48 insertions, 2 deletions
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)),
+ )
+}