Skip to content

Commit

Permalink
Drop AutoUpdateServiceClient helper
Browse files Browse the repository at this point in the history
Rename comments for consistency
  • Loading branch information
vapopov committed Sep 18, 2024
1 parent 98af039 commit 4f42c60
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 42 deletions.
11 changes: 4 additions & 7 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,6 @@ func (c *Client) GetVnetConfig(ctx context.Context) (*vnet.VnetConfig, error) {
return c.VnetConfigServiceClient().GetVnetConfig(ctx, &vnet.GetVnetConfigRequest{})
}

// AutoUpdateServiceClient returns an unadorned client for the AutoUpdate service.
func (c *Client) AutoUpdateServiceClient() autoupdatev1pb.AutoUpdateServiceClient {
return autoupdatev1pb.NewAutoUpdateServiceClient(c.conn)
}

// Ping gets basic info about the auth server.
func (c *Client) Ping(ctx context.Context) (proto.PingResponse, error) {
rsp, err := c.grpc.Ping(ctx, &proto.PingRequest{})
Expand Down Expand Up @@ -2871,7 +2866,8 @@ func (c *Client) GetClusterAuditConfig(ctx context.Context) (types.ClusterAuditC

// GetAutoUpdateConfig gets AutoUpdateConfig resource.
func (c *Client) GetAutoUpdateConfig(ctx context.Context) (*autoupdatev1pb.AutoUpdateConfig, error) {
resp, err := c.AutoUpdateServiceClient().GetAutoUpdateConfig(ctx, &autoupdatev1pb.GetAutoUpdateConfigRequest{})
client := autoupdatev1pb.NewAutoUpdateServiceClient(c.conn)
resp, err := client.GetAutoUpdateConfig(ctx, &autoupdatev1pb.GetAutoUpdateConfigRequest{})
if err != nil {
return nil, trace.Wrap(err)
}
Expand All @@ -2880,7 +2876,8 @@ func (c *Client) GetAutoUpdateConfig(ctx context.Context) (*autoupdatev1pb.AutoU

// GetAutoUpdateVersion gets AutoUpdateVersion resource.
func (c *Client) GetAutoUpdateVersion(ctx context.Context) (*autoupdatev1pb.AutoUpdateVersion, error) {
resp, err := c.AutoUpdateServiceClient().GetAutoUpdateVersion(ctx, &autoupdatev1pb.GetAutoUpdateVersionRequest{})
client := autoupdatev1pb.NewAutoUpdateServiceClient(c.conn)
resp, err := client.GetAutoUpdateVersion(ctx, &autoupdatev1pb.GetAutoUpdateVersionRequest{})
if err != nil {
return nil, trace.Wrap(err)
}
Expand Down
2 changes: 1 addition & 1 deletion api/types/autoupdate/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

// TestNewAutoUpdateConfig verifies validation for auto update config resource.
// TestNewAutoUpdateConfig verifies validation for AutoUpdateConfig resource.
func TestNewAutoUpdateConfig(t *testing.T) {
tests := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion api/types/autoupdate/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/gravitational/teleport/api/types"
)

// TestNewAutoUpdateVersion verifies validation for auto update version resource.
// TestNewAutoUpdateVersion verifies validation for AutoUpdateVersion resource.
func TestNewAutoUpdateVersion(t *testing.T) {
tests := []struct {
name string
Expand Down
8 changes: 4 additions & 4 deletions lib/auth/authclient/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ type ReadProxyAccessPoint interface {
// GetUserGroup returns the specified user group resources.
GetUserGroup(ctx context.Context, name string) (types.UserGroup, error)

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

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

Expand Down Expand Up @@ -1183,10 +1183,10 @@ type Cache interface {
// DatabaseObjectsGetter defines methods for fetching database objects.
services.DatabaseObjectsGetter

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

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

// GetAccessGraphSettings returns the access graph settings.
Expand Down
4 changes: 0 additions & 4 deletions lib/auth/authclient/clt.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/gravitational/teleport/api/client/secreport"
apidefaults "github.com/gravitational/teleport/api/defaults"
accessgraphsecretsv1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/accessgraph/v1"
autoupdatev1pb "github.com/gravitational/teleport/api/gen/proto/go/teleport/autoupdate/v1"
clusterconfigpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/clusterconfig/v1"
dbobjectimportrulev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/dbobjectimportrule/v1"
devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1"
Expand Down Expand Up @@ -1824,9 +1823,6 @@ type ClientI interface {
// will return "not implemented" errors (as per the default gRPC behavior).
StaticHostUserClient() services.StaticHostUser

// AutoUpdateServiceClient returns a AutoUpdate service client.
AutoUpdateServiceClient() autoupdatev1pb.AutoUpdateServiceClient

// CloneHTTPClient creates a new HTTP client with the same configuration.
CloneHTTPClient(params ...roundtrip.ClientParam) (*HTTPClient, error)

Expand Down
4 changes: 2 additions & 2 deletions lib/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ type autoUpdateCacheKey struct {

var _ map[autoUpdateCacheKey]struct{} // compile-time hashability check

// GetAutoUpdateConfig gets the autoupdate config from the backend.
// GetAutoUpdateConfig gets the AutoUpdateConfig from the backend.
func (c *Cache) GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdateConfig, error) {
ctx, span := c.Tracer.Start(ctx, "cache/GetAutoUpdateConfig")
defer span.End()
Expand All @@ -1925,7 +1925,7 @@ func (c *Cache) GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdate
return rg.reader.GetAutoUpdateConfig(ctx)
}

// GetAutoUpdateVersion gets the autoupdate version from the backend.
// GetAutoUpdateVersion gets the AutoUpdateVersion from the backend.
func (c *Cache) GetAutoUpdateVersion(ctx context.Context) (*autoupdate.AutoUpdateVersion, error) {
ctx, span := c.Tracer.Start(ctx, "cache/GetAutoUpdateVersion")
defer span.End()
Expand Down
20 changes: 10 additions & 10 deletions lib/services/autoupdates.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,38 @@ import (

// AutoUpdateServiceGetter defines only read-only service methods.
type AutoUpdateServiceGetter interface {
// GetAutoUpdateConfig gets the autoupdate configuration from the backend.
// GetAutoUpdateConfig gets the AutoUpdateConfig singleton resource.
GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdateConfig, error)

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

// AutoUpdateService stores the autoupdate service.
type AutoUpdateService interface {
AutoUpdateServiceGetter

// CreateAutoUpdateConfig creates an auto update configuration.
// CreateAutoUpdateConfig creates the AutoUpdateConfig singleton resource.
CreateAutoUpdateConfig(ctx context.Context, config *autoupdate.AutoUpdateConfig) (*autoupdate.AutoUpdateConfig, error)

// UpdateAutoUpdateConfig updates an auto update configuration.
// UpdateAutoUpdateConfig updates the AutoUpdateConfig singleton resource.
UpdateAutoUpdateConfig(ctx context.Context, config *autoupdate.AutoUpdateConfig) (*autoupdate.AutoUpdateConfig, error)

// UpsertAutoUpdateConfig sets an auto update configuration.
// UpsertAutoUpdateConfig sets the AutoUpdateConfig singleton resource.
UpsertAutoUpdateConfig(ctx context.Context, c *autoupdate.AutoUpdateConfig) (*autoupdate.AutoUpdateConfig, error)

// DeleteAutoUpdateConfig deletes the auto update configuration from the backend.
// DeleteAutoUpdateConfig deletes the AutoUpdateConfig singleton resource.
DeleteAutoUpdateConfig(ctx context.Context) error

// CreateAutoUpdateVersion creates an auto update version.
// CreateAutoUpdateVersion creates the AutoUpdateVersion singleton resource.
CreateAutoUpdateVersion(ctx context.Context, config *autoupdate.AutoUpdateVersion) (*autoupdate.AutoUpdateVersion, error)

// UpdateAutoUpdateVersion updates an auto update version.
// UpdateAutoUpdateVersion updates the AutoUpdateVersion singleton resource.
UpdateAutoUpdateVersion(ctx context.Context, config *autoupdate.AutoUpdateVersion) (*autoupdate.AutoUpdateVersion, error)

// UpsertAutoUpdateVersion sets an auto update version.
// UpsertAutoUpdateVersion sets the AutoUpdateVersion singleton resource.
UpsertAutoUpdateVersion(ctx context.Context, c *autoupdate.AutoUpdateVersion) (*autoupdate.AutoUpdateVersion, error)

// DeleteAutoUpdateVersion deletes the auto update version from the backend.
// DeleteAutoUpdateVersion deletes the AutoUpdateVersion singleton resource.
DeleteAutoUpdateVersion(ctx context.Context) error
}
22 changes: 11 additions & 11 deletions lib/services/local/autoupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
autoUpdateVersionPrefix = "auto_update_version"
)

// AutoUpdateService is responsible for managing auto update configuration and version.
// AutoUpdateService is responsible for managing AutoUpdateConfig and AutoUpdateVersion singleton resources.
type AutoUpdateService struct {
config *generic.ServiceWrapper[*autoupdate.AutoUpdateConfig]
version *generic.ServiceWrapper[*autoupdate.AutoUpdateVersion]
Expand Down Expand Up @@ -81,7 +81,7 @@ func NewAutoUpdateService(backend backend.Backend) (*AutoUpdateService, error) {
}, nil
}

// CreateAutoUpdateConfig creates an auto update configuration singleton.
// CreateAutoUpdateConfig creates the AutoUpdateConfig singleton resource.
func (s *AutoUpdateService) CreateAutoUpdateConfig(
ctx context.Context,
c *autoupdate.AutoUpdateConfig,
Expand All @@ -90,7 +90,7 @@ func (s *AutoUpdateService) CreateAutoUpdateConfig(
return config, trace.Wrap(err)
}

// UpdateAutoUpdateConfig updates an auto update configuration singleton.
// UpdateAutoUpdateConfig updates the AutoUpdateConfig singleton resource.
func (s *AutoUpdateService) UpdateAutoUpdateConfig(
ctx context.Context,
c *autoupdate.AutoUpdateConfig,
Expand All @@ -99,7 +99,7 @@ func (s *AutoUpdateService) UpdateAutoUpdateConfig(
return config, trace.Wrap(err)
}

// UpsertAutoUpdateConfig sets an auto update configuration.
// UpsertAutoUpdateConfig sets the AutoUpdateConfig singleton resource.
func (s *AutoUpdateService) UpsertAutoUpdateConfig(
ctx context.Context,
c *autoupdate.AutoUpdateConfig,
Expand All @@ -108,18 +108,18 @@ func (s *AutoUpdateService) UpsertAutoUpdateConfig(
return config, trace.Wrap(err)
}

// GetAutoUpdateConfig gets the auto update configuration from the backend.
// GetAutoUpdateConfig gets the AutoUpdateConfig singleton resource.
func (s *AutoUpdateService) GetAutoUpdateConfig(ctx context.Context) (*autoupdate.AutoUpdateConfig, error) {
config, err := s.config.GetResource(ctx, types.MetaNameAutoUpdateConfig)
return config, trace.Wrap(err)
}

// DeleteAutoUpdateConfig deletes the auto update configuration from the backend.
// DeleteAutoUpdateConfig deletes the AutoUpdateConfig singleton resource.
func (s *AutoUpdateService) DeleteAutoUpdateConfig(ctx context.Context) error {
return trace.Wrap(s.config.DeleteResource(ctx, types.MetaNameAutoUpdateConfig))
}

// CreateAutoUpdateVersion creates an autoupdate version resource.
// CreateAutoUpdateVersion creates the AutoUpdateVersion singleton resource.
func (s *AutoUpdateService) CreateAutoUpdateVersion(
ctx context.Context,
v *autoupdate.AutoUpdateVersion,
Expand All @@ -128,7 +128,7 @@ func (s *AutoUpdateService) CreateAutoUpdateVersion(
return version, trace.Wrap(err)
}

// UpdateAutoUpdateVersion updates an autoupdate version resource.
// UpdateAutoUpdateVersion updates the AutoUpdateVersion singleton resource.
func (s *AutoUpdateService) UpdateAutoUpdateVersion(
ctx context.Context,
v *autoupdate.AutoUpdateVersion,
Expand All @@ -137,7 +137,7 @@ func (s *AutoUpdateService) UpdateAutoUpdateVersion(
return version, trace.Wrap(err)
}

// UpsertAutoUpdateVersion sets autoupdate version resource.
// UpsertAutoUpdateVersion sets the AutoUpdateVersion singleton resource.
func (s *AutoUpdateService) UpsertAutoUpdateVersion(
ctx context.Context,
v *autoupdate.AutoUpdateVersion,
Expand All @@ -146,13 +146,13 @@ func (s *AutoUpdateService) UpsertAutoUpdateVersion(
return version, trace.Wrap(err)
}

// GetAutoUpdateVersion gets the auto update version from the backend.
// GetAutoUpdateVersion gets the AutoUpdateVersion singleton resource.
func (s *AutoUpdateService) GetAutoUpdateVersion(ctx context.Context) (*autoupdate.AutoUpdateVersion, error) {
version, err := s.version.GetResource(ctx, types.MetaNameAutoUpdateVersion)
return version, trace.Wrap(err)
}

// DeleteAutoUpdateVersion deletes the auto update version from the backend.
// DeleteAutoUpdateVersion deletes the AutoUpdateVersion singleton resource.
func (s *AutoUpdateService) DeleteAutoUpdateVersion(ctx context.Context) error {
return trace.Wrap(s.version.DeleteResource(ctx, types.MetaNameAutoUpdateVersion))
}
4 changes: 2 additions & 2 deletions lib/services/local/autoupdate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
)

// TestAutoUpdateServiceConfigCRUD verifies get/create/update/upsert/delete methods of the backend service
// for auto update config resource.
// for AutoUpdateConfig resource.
func TestAutoUpdateServiceConfigCRUD(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -92,7 +92,7 @@ func TestAutoUpdateServiceConfigCRUD(t *testing.T) {
}

// TestAutoUpdateServiceVersionCRUD verifies get/create/update/upsert/delete methods of the backend service
// for auto update version resource.
// for AutoUpdateVersion resource.
func TestAutoUpdateServiceVersionCRUD(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit 4f42c60

Please sign in to comment.