From e6ac3d5fc65797d1d2872ece3fde69968553b294 Mon Sep 17 00:00:00 2001 From: Austin Abro <37223396+AustinAbro321@users.noreply.github.com> Date: Mon, 3 Jun 2024 16:13:03 -0400 Subject: [PATCH] refactor: use root ctx in agent (#2578) ## Description Updates the agent to use ctx from the root ## Checklist before merging - [ ] Test, docs, adr added or updated as needed - [ ] [Contributor Guide Steps](https://github.com/defenseunicorns/zarf/blob/main/.github/CONTRIBUTING.md#developer-workflow) followed --- src/internal/agent/http/server.go | 4 +--- src/internal/agent/start.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/internal/agent/http/server.go b/src/internal/agent/http/server.go index 49fa5a6e7e..2bf93f4d7f 100644 --- a/src/internal/agent/http/server.go +++ b/src/internal/agent/http/server.go @@ -18,7 +18,7 @@ import ( ) // NewAdmissionServer creates a http.Server for the mutating webhook admission handler. -func NewAdmissionServer(port string) *http.Server { +func NewAdmissionServer(ctx context.Context, port string) *http.Server { message.Debugf("http.NewAdmissionServer(%s)", port) c, err := cluster.NewCluster() @@ -26,8 +26,6 @@ func NewAdmissionServer(port string) *http.Server { message.Fatalf(err, err.Error()) } - ctx := context.Background() - // Instances hooks podsMutation := hooks.NewPodMutationHook(ctx, c) fluxGitRepositoryMutation := hooks.NewGitRepositoryMutationHook(ctx, c) diff --git a/src/internal/agent/start.go b/src/internal/agent/start.go index 12ee3bcc8b..83172d2e95 100644 --- a/src/internal/agent/start.go +++ b/src/internal/agent/start.go @@ -30,7 +30,7 @@ const ( // StartWebhook launches the Zarf agent mutating webhook in the cluster. func StartWebhook(ctx context.Context) error { message.Debug("agent.StartWebhook()") - return startServer(ctx, agentHttp.NewAdmissionServer(httpPort)) + return startServer(ctx, agentHttp.NewAdmissionServer(ctx, httpPort)) } // StartHTTPProxy launches the zarf agent proxy in the cluster.