Skip to content

Commit

Permalink
remove direct GetAutoUpdateX invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoShaka committed Oct 4, 2024
1 parent 4967ce6 commit 2ef013c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
6 changes: 0 additions & 6 deletions lib/auth/authclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,6 @@ type ReadProxyAccessPoint interface {

// GetUserGroup returns the specified user group resources.
GetUserGroup(ctx context.Context, name string) (types.UserGroup, error)

// GetAutoUpdateConfig gets the AutoUpdateConfig from the backend.
GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdateConfig, error)

// GetAutoUpdateVersion gets the AutoUpdateVersion from the backend.
GetAutoUpdateVersion(ctx context.Context) (*autoupdate.AutoUpdateVersion, error)
}

// SnowflakeSessionWatcher is watcher interface used by Snowflake web session watcher.
Expand Down
2 changes: 1 addition & 1 deletion lib/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ type Cache struct {

trustCache services.Trust
clusterConfigCache services.ClusterConfiguration
autoUpdateCache *local.AutoUpdateService
autoUpdateCache services.AutoUpdateService
provisionerCache services.Provisioner
usersCache services.UsersService
accessCache services.Access
Expand Down
2 changes: 1 addition & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ func (process *TeleportProcess) newAccessCacheForClient(cfg accesspoint.Config,
cfg.WebSession = client.WebSessions()
cfg.WebToken = client.WebTokens()
cfg.WindowsDesktops = client
cfg.AutoUpdateService = client
cfg.AutoUpdateService = client.AutoUpdateClient()

return accesspoint.NewCache(cfg)
}
Expand Down
4 changes: 2 additions & 2 deletions tool/tctl/common/edit_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func testEditAutoUpdateConfig(t *testing.T, clt *authclient.Client) {
_, err = runEditCommand(t, clt, []string{"edit", "autoupdate_config"}, withEditor(editor))
require.NoError(t, err, "expected editing autoupdate config to succeed")

actual, err := clt.GetAutoUpdateConfig(ctx)
actual, err := clt.AutoUpdateClient().GetAutoUpdateConfig(ctx)
require.NoError(t, err, "failed to get autoupdate config after edit")
assert.NotEqual(t, initial.GetSpec().GetToolsAutoupdate(), actual.GetSpec().GetToolsAutoupdate(),
"tools_autoupdate should have been modified by edit")
Expand Down Expand Up @@ -614,7 +614,7 @@ func testEditAutoUpdateVersion(t *testing.T, clt *authclient.Client) {
_, err = runEditCommand(t, clt, []string{"edit", "autoupdate_version"}, withEditor(editor))
require.NoError(t, err, "expected editing autoupdate version to succeed")

actual, err := clt.GetAutoUpdateVersion(ctx)
actual, err := clt.AutoUpdateClient().GetAutoUpdateVersion(ctx)
require.NoError(t, err, "failed to get autoupdate version after edit")
assert.NotEqual(t, initial.GetSpec().GetToolsVersion(), actual.GetSpec().GetToolsVersion(),
"tools_autoupdate should have been modified by edit")
Expand Down
16 changes: 8 additions & 8 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3069,13 +3069,13 @@ func (rc *ResourceCommand) getCollection(ctx context.Context, client *authclient
}
return &staticHostUserCollection{items: hostUsers}, nil
case types.KindAutoUpdateConfig:
config, err := client.GetAutoUpdateConfig(ctx)
config, err := client.AutoUpdateClient().GetAutoUpdateConfig(ctx)
if err != nil {
return nil, trace.Wrap(err)
}
return &autoUpdateConfigCollection{config}, nil
case types.KindAutoUpdateVersion:
version, err := client.GetAutoUpdateVersion(ctx)
version, err := client.AutoUpdateClient().GetAutoUpdateVersion(ctx)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down Expand Up @@ -3433,9 +3433,9 @@ func (rc *ResourceCommand) createAutoUpdateConfig(ctx context.Context, client *a
}

if rc.IsForced() {
_, err = client.UpsertAutoUpdateConfig(ctx, config)
_, err = client.AutoUpdateClient().UpsertAutoUpdateConfig(ctx, config)
} else {
_, err = client.CreateAutoUpdateConfig(ctx, config)
_, err = client.AutoUpdateClient().CreateAutoUpdateConfig(ctx, config)
}
if err != nil {
return trace.Wrap(err)
Expand All @@ -3450,7 +3450,7 @@ func (rc *ResourceCommand) updateAutoUpdateConfig(ctx context.Context, client *a
if err != nil {
return trace.Wrap(err)
}
if _, err := client.UpdateAutoUpdateConfig(ctx, config); err != nil {
if _, err := client.AutoUpdateClient().UpdateAutoUpdateConfig(ctx, config); err != nil {
return trace.Wrap(err)
}
fmt.Println("autoupdate_config has been updated")
Expand All @@ -3464,9 +3464,9 @@ func (rc *ResourceCommand) createAutoUpdateVersion(ctx context.Context, client *
}

if rc.IsForced() {
_, err = client.UpsertAutoUpdateVersion(ctx, version)
_, err = client.AutoUpdateClient().UpsertAutoUpdateVersion(ctx, version)
} else {
_, err = client.CreateAutoUpdateVersion(ctx, version)
_, err = client.AutoUpdateClient().CreateAutoUpdateVersion(ctx, version)
}
if err != nil {
return trace.Wrap(err)
Expand All @@ -3481,7 +3481,7 @@ func (rc *ResourceCommand) updateAutoUpdateVersion(ctx context.Context, client *
if err != nil {
return trace.Wrap(err)
}
if _, err := client.UpdateAutoUpdateVersion(ctx, version); err != nil {
if _, err := client.AutoUpdateClient().UpdateAutoUpdateVersion(ctx, version); err != nil {
return trace.Wrap(err)
}
fmt.Println("autoupdate_version has been updated")
Expand Down

0 comments on commit 2ef013c

Please sign in to comment.