diff --git a/pkg/blockstorage/azure/auth.go b/pkg/blockstorage/azure/auth.go index 415ee9c707e..2d34693179d 100644 --- a/pkg/blockstorage/azure/auth.go +++ b/pkg/blockstorage/azure/auth.go @@ -55,11 +55,6 @@ type AzureAuthenticator interface { } func NewAzureAuthenticator(config map[string]string) (AzureAuthenticator, error) { - // NewAzureAuthenticator opens up the possibility to Auth with: - //1. Env variables - //2. Managed Identity - //3. Workload Identity - //4. AzureCli switch { case isMSICredsAvailable(config): return &MsiAuthenticator{}, nil diff --git a/pkg/blockstorage/azure/azuredisk.go b/pkg/blockstorage/azure/azuredisk.go index 1b773f3896c..a9feeb9e7b5 100644 --- a/pkg/blockstorage/azure/azuredisk.go +++ b/pkg/blockstorage/azure/azuredisk.go @@ -240,7 +240,7 @@ func (s *AdStorage) SnapshotCopyWithArgs(ctx context.Context, from blockstorage. if err != nil { return nil, errors.Wrap(err, "Poller failed to retrieve snapshot") } - snap, err := s.SnapshotGet(ctx, blockstorage.String(createSnapRes.ID)) + snap, err := s.SnapshotGet(ctx, blockstorage.StringFromPtr(createSnapRes.ID)) if err != nil { return nil, errors.Wrapf(err, "Failed to Get Snapshot after create, snaphotName %s", snapName) } @@ -379,21 +379,21 @@ func (s *AdStorage) VolumeParse(ctx context.Context, volume interface{}) (*block if vol.Tags != nil { tags = blockstorage.StringMap(vol.Tags) } - az := blockstorage.String(vol.Location) + az := blockstorage.StringFromPtr(vol.Location) if z := vol.Zones; len(z) > 0 { az = az + "-" + *(z[0]) } return &blockstorage.Volume{ Type: s.Type(), - ID: blockstorage.String(vol.ID), + ID: blockstorage.StringFromPtr(vol.ID), Encrypted: encrypted, SizeInBytes: blockstorage.Int64(vol.Properties.DiskSizeBytes), Az: az, Tags: blockstorage.MapToKeyValue(tags), VolumeType: string(*vol.SKU.Name), CreationTime: blockstorage.TimeStamp(*vol.Properties.TimeCreated), - Attributes: map[string]string{"Users": blockstorage.String(vol.ManagedBy)}, + Attributes: map[string]string{"Users": blockstorage.StringFromPtr(vol.ManagedBy)}, }, nil } diff --git a/pkg/blockstorage/helper_test.go b/pkg/blockstorage/helper_test.go index 6dcbef90799..2097c86eec7 100644 --- a/pkg/blockstorage/helper_test.go +++ b/pkg/blockstorage/helper_test.go @@ -18,14 +18,6 @@ func (h *HelperSuite) TestStringSlice(c *C) { c.Assert(target[1], Equals, source[1]) } -func (s *HelperSuite) TestStringSlicePtr(c *C) { - source := []string{"test1", "test2"} - res := StringSlicePtr(source) - target := *res - c.Assert(target[0], Equals, source[0]) - c.Assert(target[1], Equals, source[1]) -} - func (s *HelperSuite) TestSliceStringPtr(c *C) { source := []string{"test1", "test2"} res := SliceStringPtr(source) @@ -35,18 +27,6 @@ func (s *HelperSuite) TestSliceStringPtr(c *C) { } } -func (s *HelperSuite) TestBoolFromPtr(c *C) { - source := true - target := Bool(&source) - c.Assert(target, Equals, source) -} - -func (s *HelperSuite) TestBoolToPtr(c *C) { - source := true - target := BoolPtr(source) - c.Assert(*target, Equals, source) -} - func (s *HelperSuite) TestIntFromPtr(c *C) { source := 1 target := Int(&source) @@ -59,24 +39,6 @@ func (s *HelperSuite) TestIntToPtr(c *C) { c.Assert(*target, Equals, source) } -func (s *HelperSuite) TestFloat32FromPtr(c *C) { - source := float32(1) - target := Float32(&source) - c.Assert(target, Equals, source) -} - -func (s *HelperSuite) TestFloat32ToPtr(c *C) { - source := float32(1) - target := Float32Ptr(source) - c.Assert(*target, Equals, source) -} - -func (s *HelperSuite) TestStringFromPtr(c *C) { - source := "test" - target := String(&source) - c.Assert(target, Equals, source) -} - func (s *HelperSuite) TestStringToPtr(c *C) { source := "test" target := StringPtr(source) diff --git a/pkg/blockstorage/helpers.go b/pkg/blockstorage/helpers.go index 74c7c10256c..104295d22e7 100644 --- a/pkg/blockstorage/helpers.go +++ b/pkg/blockstorage/helpers.go @@ -141,11 +141,6 @@ func StringSlice(s *[]string) []string { return nil } -// StringSlicePtr returns a pointer to the passed string slice. -func StringSlicePtr(s []string) *[]string { - return azto.Ptr(s) -} - // SliceStringPtr returns a slice of string pointers from the passed string slice. func SliceStringPtr(s []string) []*string { ms := make([]*string, len(s)) @@ -155,19 +150,6 @@ func SliceStringPtr(s []string) []*string { return ms } -// Bool returns a bool value for the passed bool pointer. It returns false if the pointer is nil. -func Bool(b *bool) bool { - if b != nil { - return *b - } - return false -} - -// BoolPtr returns a pointer to the passed bool. -func BoolPtr(b bool) *bool { - return &b -} - // Int returns an int value for the passed int pointer. It returns 0 if the pointer is nil. func Int(i *int) int { if i != nil { @@ -202,40 +184,9 @@ func Int64(i *int64) int64 { return 0 } -// Int64Ptr returns a pointer to the passed int64. -func Int64Ptr(i int64) *int64 { - return &i -} - -// Float32 returns an int value for the passed int pointer. It returns 0.0 if the pointer is nil. -func Float32(i *float32) float32 { - if i != nil { - return *i - } - return 0.0 -} - -// Float32Ptr returns a pointer to the passed float32. -func Float32Ptr(i float32) *float32 { - return &i -} - -// ToFloat64 returns an int value for the passed int pointer. It returns 0.0 if the pointer is nil. -func Float64(i *float64) float64 { - if i != nil { - return *i - } - return 0.0 -} - -// Float64Ptr returns a pointer to the passed float64. -func Float64Ptr(i float64) *float64 { - return &i -} - // String returns a string value for the passed string pointer. It returns the empty string if the // pointer is nil. -func String(s *string) string { +func StringFromPtr(s *string) string { if s != nil { return *s }