Skip to content

Commit

Permalink
wip: add switch
Browse files Browse the repository at this point in the history
  • Loading branch information
avallete committed Nov 29, 2024
1 parent 1caa8fe commit 9067734
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pkg/config/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
)

type ConfigUpdater struct {
client v1API.ClientWithResponses
client v1API.ClientWithResponses
skipSecrets bool
}

func NewConfigUpdater(client v1API.ClientWithResponses) ConfigUpdater {
return ConfigUpdater{client: client}
func NewConfigUpdater(client v1API.ClientWithResponses, skipSecrets bool) ConfigUpdater {
return ConfigUpdater{client: client, skipSecrets: skipSecrets}
}

func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfig, filter ...func(string) bool) error {
Expand Down Expand Up @@ -123,7 +124,13 @@ func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string,
return nil
}
}
if resp, err := u.client.V1UpdateAuthServiceConfigWithResponse(ctx, projectRef, c.StripUpdateBodySecrets(c.ToUpdateAuthConfigBody())); err != nil {
var updateBody v1API.UpdateAuthConfigBody
if u.skipSecrets {
updateBody = c.StripUpdateBodySecrets(c.ToUpdateAuthConfigBody())
} else {
updateBody = c.ToUpdateAuthConfigBody()
}
if resp, err := u.client.V1UpdateAuthServiceConfigWithResponse(ctx, projectRef, updateBody); err != nil {
return errors.Errorf("failed to update Auth config: %w", err)
} else if status := resp.StatusCode(); status < 200 || status >= 300 {
return errors.Errorf("unexpected status %d: %s", status, string(resp.Body))
Expand Down

0 comments on commit 9067734

Please sign in to comment.