Skip to content

Commit

Permalink
refactor: makes gcp provider private.
Browse files Browse the repository at this point in the history
  • Loading branch information
VAveryanov8 committed Dec 13, 2024
1 parent 51b7b3d commit 700395c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions pkg/cloudmeta/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (
"github.com/pkg/errors"
)

// GCPMetadata is a wrapper around gcp metadata client.
type GCPMetadata struct {
// gcpMetadata is a wrapper around gcp metadata client.
type gcpMetadata struct {
meta *metadata.Client
}

// NewGCPMetadata returns gcp metadata provider.
func NewGCPMetadata() *GCPMetadata {
return &GCPMetadata{
// newGCPMetadata returns gcp metadata provider.
func newGCPMetadata() *gcpMetadata {
return &gcpMetadata{
meta: metadata.NewClient(nil),
}
}

// Metadata returns InstanceMetadata from gcp if available.
func (gcp *GCPMetadata) Metadata(ctx context.Context) (InstanceMetadata, error) {
func (gcp *gcpMetadata) Metadata(ctx context.Context) (InstanceMetadata, error) {
machineType, err := gcp.getMachineType(ctx)
if err != nil {
return InstanceMetadata{}, errors.Wrap(err, "gcp.meta.GetWithContext")
Expand All @@ -34,7 +34,7 @@ func (gcp *GCPMetadata) Metadata(ctx context.Context) (InstanceMetadata, error)
}, nil
}

func (gcp *GCPMetadata) getMachineType(ctx context.Context) (string, error) {
func (gcp *gcpMetadata) getMachineType(ctx context.Context) (string, error) {
// The machine type for this VM. This value has the following format: projects/PROJECT_NUM/machineTypes/MACHINE_TYPE.
machineType, err := gcp.meta.GetWithContext(ctx, "instance/machine-type")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloudmeta/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewCloudMeta() (*CloudMeta, error) {
return nil, err
}

gcpMeta := NewGCPMetadata()
gcpMeta := newGCPMetadata()

return &CloudMeta{
providers: []CloudMetadataProvider{
Expand Down

0 comments on commit 700395c

Please sign in to comment.