Skip to content

Commit

Permalink
Rename all occurrences auto update to camelcase
Browse files Browse the repository at this point in the history
  • Loading branch information
vapopov committed Sep 18, 2024
1 parent fed1fcd commit ef27d0d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion lib/auth/accesspoint/accesspoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func NewCache(cfg Config) (*cache.Cache, error) {
AppSession: cfg.AppSession,
Apps: cfg.Apps,
ClusterConfig: cfg.ClusterConfig,
AutoupdateService: cfg.AutoUpdateService,
AutoUpdateService: cfg.AutoUpdateService,
CrownJewels: cfg.CrownJewels,
DatabaseObjects: cfg.DatabaseObjects,
DatabaseServices: cfg.DatabaseServices,
Expand Down
12 changes: 6 additions & 6 deletions lib/auth/autoupdate/autoupdatev1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func (s *Service) CreateAutoUpdateVersion(ctx context.Context, req *autoupdate.C
return nil, trace.Wrap(err)
}

autoupdateVersion, err := s.backend.CreateAutoUpdateVersion(ctx, req.Version)
return autoupdateVersion, trace.Wrap(err)
autoUpdateVersion, err := s.backend.CreateAutoUpdateVersion(ctx, req.Version)
return autoUpdateVersion, trace.Wrap(err)
}

// UpdateAutoUpdateVersion updates autoupdate version singleton.
Expand All @@ -225,8 +225,8 @@ func (s *Service) UpdateAutoUpdateVersion(ctx context.Context, req *autoupdate.U
return nil, trace.Wrap(err)
}

autoupdateVersion, err := s.backend.UpdateAutoUpdateVersion(ctx, req.Version)
return autoupdateVersion, trace.Wrap(err)
autoUpdateVersion, err := s.backend.UpdateAutoUpdateVersion(ctx, req.Version)
return autoUpdateVersion, trace.Wrap(err)
}

// UpsertAutoUpdateVersion updates or creates autoupdate version singleton.
Expand All @@ -244,8 +244,8 @@ func (s *Service) UpsertAutoUpdateVersion(ctx context.Context, req *autoupdate.U
return nil, trace.Wrap(err)
}

autoupdateVersion, err := s.backend.UpsertAutoUpdateVersion(ctx, req.Version)
return autoupdateVersion, trace.Wrap(err)
autoUpdateVersion, err := s.backend.UpsertAutoUpdateVersion(ctx, req.Version)
return autoUpdateVersion, trace.Wrap(err)
}

// DeleteAutoUpdateVersion deletes autoupdate version singleton.
Expand Down
14 changes: 7 additions & 7 deletions lib/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ type Cache struct {

trustCache services.Trust
clusterConfigCache services.ClusterConfiguration
autoupdateCache *local.AutoUpdateService
autoUpdateCache *local.AutoUpdateService
provisionerCache services.Provisioner
usersCache services.UsersService
accessCache services.Access
Expand Down Expand Up @@ -645,8 +645,8 @@ type Config struct {
Trust services.Trust
// ClusterConfig is a cluster configuration service
ClusterConfig services.ClusterConfiguration
// AutoupdateService is an autoupdate service.
AutoupdateService services.AutoUpdateServiceGetter
// AutoUpdateService is an autoupdate service.
AutoUpdateService services.AutoUpdateServiceGetter
// Provisioner is a provisioning service
Provisioner services.Provisioner
// Users is a users service
Expand Down Expand Up @@ -926,7 +926,7 @@ func New(config Config) (*Cache, error) {
return nil, trace.Wrap(err)
}

autoupdateCache, err := local.NewAutoUpdateService(config.Backend)
autoUpdateCache, err := local.NewAutoUpdateService(config.Backend)
if err != nil {
cancel()
return nil, trace.Wrap(err)
Expand Down Expand Up @@ -970,7 +970,7 @@ func New(config Config) (*Cache, error) {
fnCache: fnCache,
trustCache: local.NewCAService(config.Backend),
clusterConfigCache: clusterConfigCache,
autoupdateCache: autoupdateCache,
autoUpdateCache: autoUpdateCache,
provisionerCache: local.NewProvisioningService(config.Backend),
usersCache: local.NewIdentityService(config.Backend),
accessCache: local.NewAccessService(config.Backend),
Expand Down Expand Up @@ -1907,7 +1907,7 @@ func (c *Cache) GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdate
ctx, span := c.Tracer.Start(ctx, "cache/GetAutoUpdateConfig")
defer span.End()

rg, err := readCollectionCache(c, c.collections.autoupdateConfigs)
rg, err := readCollectionCache(c, c.collections.autoUpdateConfigs)
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -1930,7 +1930,7 @@ func (c *Cache) GetAutoUpdateVersion(ctx context.Context) (*autoupdate.AutoUpdat
ctx, span := c.Tracer.Start(ctx, "cache/GetAutoUpdateVersion")
defer span.End()

rg, err := readCollectionCache(c, c.collections.autoupdateVersions)
rg, err := readCollectionCache(c, c.collections.autoUpdateVersions)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down
32 changes: 16 additions & 16 deletions lib/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type testPack struct {
databaseObjects services.DatabaseObjects
spiffeFederations *local.SPIFFEFederationService
staticHostUsers services.StaticHostUser
autoupdateService services.AutoUpdateService
autoUpdateService services.AutoUpdateService
}

// testFuncs are functions to support testing an object in a cache.
Expand Down Expand Up @@ -363,7 +363,7 @@ func newPackWithoutCache(dir string, opts ...packOption) (*testPack, error) {
}
p.staticHostUsers = staticHostUserService

p.autoupdateService, err = local.NewAutoUpdateService(p.backend)
p.autoUpdateService, err = local.NewAutoUpdateService(p.backend)
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down Expand Up @@ -416,7 +416,7 @@ func newPack(dir string, setupConfig func(c Config) Config, opts ...packOption)
SPIFFEFederations: p.spiffeFederations,
DatabaseObjects: p.databaseObjects,
StaticHostUsers: p.staticHostUsers,
AutoupdateService: p.autoupdateService,
AutoUpdateService: p.autoUpdateService,
MaxRetryPeriod: 200 * time.Millisecond,
EventsC: p.eventsC,
}))
Expand Down Expand Up @@ -823,7 +823,7 @@ func TestCompletenessInit(t *testing.T) {
DatabaseObjects: p.databaseObjects,
SPIFFEFederations: p.spiffeFederations,
StaticHostUsers: p.staticHostUsers,
AutoupdateService: p.autoupdateService,
AutoUpdateService: p.autoUpdateService,
MaxRetryPeriod: 200 * time.Millisecond,
EventsC: p.eventsC,
}))
Expand Down Expand Up @@ -903,7 +903,7 @@ func TestCompletenessReset(t *testing.T) {
DatabaseObjects: p.databaseObjects,
SPIFFEFederations: p.spiffeFederations,
StaticHostUsers: p.staticHostUsers,
AutoupdateService: p.autoupdateService,
AutoUpdateService: p.autoUpdateService,
MaxRetryPeriod: 200 * time.Millisecond,
EventsC: p.eventsC,
}))
Expand Down Expand Up @@ -1109,7 +1109,7 @@ func TestListResources_NodesTTLVariant(t *testing.T) {
DatabaseObjects: p.databaseObjects,
SPIFFEFederations: p.spiffeFederations,
StaticHostUsers: p.staticHostUsers,
AutoupdateService: p.autoupdateService,
AutoUpdateService: p.autoUpdateService,
MaxRetryPeriod: 200 * time.Millisecond,
EventsC: p.eventsC,
neverOK: true, // ensure reads are never healthy
Expand Down Expand Up @@ -1200,7 +1200,7 @@ func initStrategy(t *testing.T) {
DatabaseObjects: p.databaseObjects,
SPIFFEFederations: p.spiffeFederations,
StaticHostUsers: p.staticHostUsers,
AutoupdateService: p.autoupdateService,
AutoUpdateService: p.autoUpdateService,
MaxRetryPeriod: 200 * time.Millisecond,
EventsC: p.eventsC,
}))
Expand Down Expand Up @@ -2674,9 +2674,9 @@ func TestDatabaseObjects(t *testing.T) {
})
}

// TestAutoupdateConfig tests that CRUD operations on autoupdate config resource is
// TestAutoUpdateConfig tests that CRUD operations on AutoUpdateConfig resources are
// replicated from the backend to the cache.
func TestAutoupdateConfig(t *testing.T) {
func TestAutoUpdateConfig(t *testing.T) {
t.Parallel()

p := newTestPack(t, ForAuth)
Expand All @@ -2687,11 +2687,11 @@ func TestAutoupdateConfig(t *testing.T) {
return newAutoUpdateConfig(t), nil
},
create: func(ctx context.Context, item *autoupdate.AutoUpdateConfig) error {
_, err := p.autoupdateService.UpsertAutoUpdateConfig(ctx, item)
_, err := p.autoUpdateService.UpsertAutoUpdateConfig(ctx, item)
return trace.Wrap(err)
},
list: func(ctx context.Context) ([]*autoupdate.AutoUpdateConfig, error) {
item, err := p.autoupdateService.GetAutoUpdateConfig(ctx)
item, err := p.autoUpdateService.GetAutoUpdateConfig(ctx)
if trace.IsNotFound(err) {
return []*autoupdate.AutoUpdateConfig{}, nil
}
Expand All @@ -2705,12 +2705,12 @@ func TestAutoupdateConfig(t *testing.T) {
return []*autoupdate.AutoUpdateConfig{item}, trace.Wrap(err)
},
deleteAll: func(ctx context.Context) error {
return trace.Wrap(p.autoupdateService.DeleteAutoUpdateConfig(ctx))
return trace.Wrap(p.autoUpdateService.DeleteAutoUpdateConfig(ctx))
},
})
}

// TestAutoUpdateVersion tests that CRUD operations on autoupdate version resource is
// TestAutoUpdateVersion tests that CRUD operations on AutoUpdateVersion resource are
// replicated from the backend to the cache.
func TestAutoUpdateVersion(t *testing.T) {
t.Parallel()
Expand All @@ -2723,11 +2723,11 @@ func TestAutoUpdateVersion(t *testing.T) {
return newAutoUpdateVersion(t), nil
},
create: func(ctx context.Context, item *autoupdate.AutoUpdateVersion) error {
_, err := p.autoupdateService.UpsertAutoUpdateVersion(ctx, item)
_, err := p.autoUpdateService.UpsertAutoUpdateVersion(ctx, item)
return trace.Wrap(err)
},
list: func(ctx context.Context) ([]*autoupdate.AutoUpdateVersion, error) {
item, err := p.autoupdateService.GetAutoUpdateVersion(ctx)
item, err := p.autoUpdateService.GetAutoUpdateVersion(ctx)
if trace.IsNotFound(err) {
return []*autoupdate.AutoUpdateVersion{}, nil
}
Expand All @@ -2741,7 +2741,7 @@ func TestAutoUpdateVersion(t *testing.T) {
return []*autoupdate.AutoUpdateVersion{item}, trace.Wrap(err)
},
deleteAll: func(ctx context.Context) error {
return trace.Wrap(p.autoupdateService.DeleteAutoUpdateVersion(ctx))
return trace.Wrap(p.autoUpdateService.DeleteAutoUpdateVersion(ctx))
},
})
}
Expand Down
76 changes: 38 additions & 38 deletions lib/cache/collections.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ type cacheCollections struct {
globalNotifications collectionReader[notificationGetter]
accessMonitoringRules collectionReader[accessMonitoringRuleGetter]
spiffeFederations collectionReader[SPIFFEFederationReader]
autoupdateConfigs collectionReader[autoupdateConfigGetter]
autoupdateVersions collectionReader[autoupdateVersionGetter]
autoUpdateConfigs collectionReader[autoUpdateConfigGetter]
autoUpdateVersions collectionReader[autoUpdateVersionGetter]
}

// setupCollections returns a registry of collections.
Expand Down Expand Up @@ -768,23 +768,23 @@ func setupCollections(c *Cache, watches []types.WatchKind) (*cacheCollections, e
}
collections.byKind[resourceKind] = collections.spiffeFederations
case types.KindAutoUpdateConfig:
if c.AutoupdateService == nil {
if c.AutoUpdateService == nil {
return nil, trace.BadParameter("missing parameter AutoUpdateService")
}
collections.autoupdateConfigs = &genericCollection[*autoupdate.AutoUpdateConfig, autoupdateConfigGetter, autoupdateConfigExecutor]{
collections.autoUpdateConfigs = &genericCollection[*autoupdate.AutoUpdateConfig, autoUpdateConfigGetter, autoUpdateConfigExecutor]{
cache: c,
watch: watch,
}
collections.byKind[resourceKind] = collections.autoupdateConfigs
collections.byKind[resourceKind] = collections.autoUpdateConfigs
case types.KindAutoUpdateVersion:
if c.AutoupdateService == nil {
if c.AutoUpdateService == nil {
return nil, trace.BadParameter("missing parameter AutoUpdateService")
}
collections.autoupdateVersions = &genericCollection[*autoupdate.AutoUpdateVersion, autoupdateVersionGetter, autoupdateVersionExecutor]{
collections.autoUpdateVersions = &genericCollection[*autoupdate.AutoUpdateVersion, autoUpdateVersionGetter, autoUpdateVersionExecutor]{
cache: c,
watch: watch,
}
collections.byKind[resourceKind] = collections.autoupdateVersions
collections.byKind[resourceKind] = collections.autoUpdateVersions
default:
return nil, trace.BadParameter("resource %q is not supported", watch.Kind)
}
Expand Down Expand Up @@ -1290,75 +1290,75 @@ type clusterNameGetter interface {
GetClusterName(opts ...services.MarshalOption) (types.ClusterName, error)
}

type autoupdateConfigExecutor struct{}
type autoUpdateConfigExecutor struct{}

func (autoupdateConfigExecutor) getAll(ctx context.Context, cache *Cache, loadSecrets bool) ([]*autoupdate.AutoUpdateConfig, error) {
config, err := cache.AutoupdateService.GetAutoUpdateConfig(ctx)
func (autoUpdateConfigExecutor) getAll(ctx context.Context, cache *Cache, loadSecrets bool) ([]*autoupdate.AutoUpdateConfig, error) {
config, err := cache.AutoUpdateService.GetAutoUpdateConfig(ctx)
return []*autoupdate.AutoUpdateConfig{config}, trace.Wrap(err)
}

func (autoupdateConfigExecutor) upsert(ctx context.Context, cache *Cache, resource *autoupdate.AutoUpdateConfig) error {
_, err := cache.autoupdateCache.UpsertAutoUpdateConfig(ctx, resource)
func (autoUpdateConfigExecutor) upsert(ctx context.Context, cache *Cache, resource *autoupdate.AutoUpdateConfig) error {
_, err := cache.autoUpdateCache.UpsertAutoUpdateConfig(ctx, resource)
return trace.Wrap(err)
}

func (autoupdateConfigExecutor) deleteAll(ctx context.Context, cache *Cache) error {
return cache.autoupdateCache.DeleteAutoUpdateConfig(ctx)
func (autoUpdateConfigExecutor) deleteAll(ctx context.Context, cache *Cache) error {
return cache.autoUpdateCache.DeleteAutoUpdateConfig(ctx)
}

func (autoupdateConfigExecutor) delete(ctx context.Context, cache *Cache, resource types.Resource) error {
return cache.autoupdateCache.DeleteAutoUpdateConfig(ctx)
func (autoUpdateConfigExecutor) delete(ctx context.Context, cache *Cache, resource types.Resource) error {
return cache.autoUpdateCache.DeleteAutoUpdateConfig(ctx)
}

func (autoupdateConfigExecutor) isSingleton() bool { return true }
func (autoUpdateConfigExecutor) isSingleton() bool { return true }

func (autoupdateConfigExecutor) getReader(cache *Cache, cacheOK bool) autoupdateConfigGetter {
func (autoUpdateConfigExecutor) getReader(cache *Cache, cacheOK bool) autoUpdateConfigGetter {
if cacheOK {
return cache.autoupdateCache
return cache.autoUpdateCache
}
return cache.Config.AutoupdateService
return cache.Config.AutoUpdateService
}

type autoupdateConfigGetter interface {
type autoUpdateConfigGetter interface {
GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdateConfig, error)
}

var _ executor[*autoupdate.AutoUpdateConfig, autoupdateConfigGetter] = autoupdateConfigExecutor{}
var _ executor[*autoupdate.AutoUpdateConfig, autoUpdateConfigGetter] = autoUpdateConfigExecutor{}

type autoupdateVersionExecutor struct{}
type autoUpdateVersionExecutor struct{}

func (autoupdateVersionExecutor) getAll(ctx context.Context, cache *Cache, loadSecrets bool) ([]*autoupdate.AutoUpdateVersion, error) {
version, err := cache.AutoupdateService.GetAutoUpdateVersion(ctx)
func (autoUpdateVersionExecutor) getAll(ctx context.Context, cache *Cache, loadSecrets bool) ([]*autoupdate.AutoUpdateVersion, error) {
version, err := cache.AutoUpdateService.GetAutoUpdateVersion(ctx)
return []*autoupdate.AutoUpdateVersion{version}, trace.Wrap(err)
}

func (autoupdateVersionExecutor) upsert(ctx context.Context, cache *Cache, resource *autoupdate.AutoUpdateVersion) error {
_, err := cache.autoupdateCache.UpsertAutoUpdateVersion(ctx, resource)
func (autoUpdateVersionExecutor) upsert(ctx context.Context, cache *Cache, resource *autoupdate.AutoUpdateVersion) error {
_, err := cache.autoUpdateCache.UpsertAutoUpdateVersion(ctx, resource)
return trace.Wrap(err)
}

func (autoupdateVersionExecutor) deleteAll(ctx context.Context, cache *Cache) error {
return cache.autoupdateCache.DeleteAutoUpdateVersion(ctx)
func (autoUpdateVersionExecutor) deleteAll(ctx context.Context, cache *Cache) error {
return cache.autoUpdateCache.DeleteAutoUpdateVersion(ctx)
}

func (autoupdateVersionExecutor) delete(ctx context.Context, cache *Cache, resource types.Resource) error {
return cache.autoupdateCache.DeleteAutoUpdateVersion(ctx)
func (autoUpdateVersionExecutor) delete(ctx context.Context, cache *Cache, resource types.Resource) error {
return cache.autoUpdateCache.DeleteAutoUpdateVersion(ctx)
}

func (autoupdateVersionExecutor) isSingleton() bool { return true }
func (autoUpdateVersionExecutor) isSingleton() bool { return true }

func (autoupdateVersionExecutor) getReader(cache *Cache, cacheOK bool) autoupdateVersionGetter {
func (autoUpdateVersionExecutor) getReader(cache *Cache, cacheOK bool) autoUpdateVersionGetter {
if cacheOK {
return cache.autoupdateCache
return cache.autoUpdateCache
}
return cache.Config.AutoupdateService
return cache.Config.AutoUpdateService
}

type autoupdateVersionGetter interface {
type autoUpdateVersionGetter interface {
GetAutoUpdateVersion(ctx context.Context) (*autoupdate.AutoUpdateVersion, error)
}

var _ executor[*autoupdate.AutoUpdateVersion, autoupdateVersionGetter] = autoupdateVersionExecutor{}
var _ executor[*autoupdate.AutoUpdateVersion, autoUpdateVersionGetter] = autoUpdateVersionExecutor{}

type userExecutor struct{}

Expand Down
Loading

0 comments on commit ef27d0d

Please sign in to comment.