From ec6a05bf1f91dd173a41a25415d54da1943738cc Mon Sep 17 00:00:00 2001 From: Paolo Chila Date: Thu, 11 Apr 2024 10:31:02 +0200 Subject: [PATCH] fixup! fixup! WIP - refactor handleFleetHosts --- .../actions/handlers/handler_action_policy_change.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/internal/pkg/agent/application/actions/handlers/handler_action_policy_change.go b/internal/pkg/agent/application/actions/handlers/handler_action_policy_change.go index dbc42c38493..65a772caeaf 100644 --- a/internal/pkg/agent/application/actions/handlers/handler_action_policy_change.go +++ b/internal/pkg/agent/application/actions/handlers/handler_action_policy_change.go @@ -129,6 +129,7 @@ func (h *PolicyChangeHandler) validateFleetServerHosts(ctx context.Context, cfg // only set protocol/hosts as that is all Fleet currently sends // copy the client config and apply the changes on this copy newFleetClientConfig := h.config.Fleet.Client + // modify in-place newFleetClientConfig updateFleetConfig(h.log, cfg.Fleet.Client, &newFleetClientConfig) // Test new config @@ -154,7 +155,7 @@ func testFleetConfig(ctx context.Context, log *logger.Logger, clientConfig remot ctx, cancel := context.WithTimeout(ctx, apiStatusTimeout) defer cancel() - // FIXME: a HEAD should be enough as we need to test only the connectivity part + // TODO: a HEAD should be enough as we need to test only the connectivity part resp, err := fleetClient.Send(ctx, http.MethodGet, "/api/status", nil, nil, nil) if err != nil { return errors.New( @@ -247,15 +248,7 @@ func (h *PolicyChangeHandler) applyFleetClientConfig(validatedConfig *remote.Con return nil } - //previousConfig := h.config.Fleet.Client - // h.config.Fleet.Client = *validatedConfig - //// rollback on failure - //defer func() { - // if err != nil { - // h.config.Fleet.Client = previousConfig - // } - //}() // the config has already been validated, no need for error handling fleetClient, _ := client.NewAuthWithConfig(