Skip to content

Commit

Permalink
Azure: go lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jhixson74 committed Mar 14, 2024
1 parent 329318d commit 8e6ef5d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/asset/machines/azure/azuremachines.go
Expand Up @@ -45,7 +45,7 @@ func GenerateMachines(platform *azure.Platform, pool *types.MachinePool, userDat
return nil, fmt.Errorf("failed to create machineapi.TagSpecifications from UserTags: %w", err)
}

image := &capz.Image{}
var image *capz.Image
osImage := mpool.OSImage
galleryName := strings.ReplaceAll(clusterID, "-", "_")

Expand Down
13 changes: 6 additions & 7 deletions pkg/infrastructure/azure/compute.go
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/sirupsen/logrus"
)

// CreateImageGalleryInput contains the input paramters for creating a image
// CreateImageGalleryInput contains the input parameters for creating a image
// gallery.
type CreateImageGalleryInput struct {
SubscriptionID string
Expand All @@ -34,7 +34,7 @@ type CreateImageGalleryOutput struct {
Gallery *armcompute.Gallery
}

// CreateImageGallery creates a image gallery
// CreateImageGallery creates a image gallery.
func CreateImageGallery(ctx context.Context, in *CreateImageGalleryInput) (*CreateImageGalleryOutput, error) {
computeClientFactory, err := armcompute.NewClientFactory(
in.SubscriptionID,
Expand Down Expand Up @@ -79,7 +79,7 @@ func CreateImageGallery(ctx context.Context, in *CreateImageGalleryInput) (*Crea
}, nil
}

// CreateGalleryImageInput contains the input paramters for creating a gallery
// CreateGalleryImageInput contains the input parameters for creating a gallery
// image.
type CreateGalleryImageInput struct {
ResourceGroupName string
Expand All @@ -104,7 +104,7 @@ type CreateGalleryImageOutput struct {
GalleryImage *armcompute.GalleryImage
}

// CreateGalleryImage creates a gallery image
// CreateGalleryImage creates a gallery image.
func CreateGalleryImage(ctx context.Context, in *CreateGalleryImageInput) (*CreateGalleryImageOutput, error) {
galleryImagesClient := in.ComputeClientFactory.NewGalleryImagesClient()

Expand Down Expand Up @@ -143,10 +143,9 @@ func CreateGalleryImage(ctx context.Context, in *CreateGalleryImageInput) (*Crea
return &CreateGalleryImageOutput{
GalleryImage: to.Ptr(galleryImage),
}, nil

}

// CreateGalleryImageVersionInput contains the input paramters for creating a
// CreateGalleryImageVersionInput contains the input parameters for creating a
// gallery image version.
type CreateGalleryImageVersionInput struct {
ResourceGroupName string
Expand All @@ -167,7 +166,7 @@ type CreateGalleryImageVersionOutput struct {
GalleryImageVersion *armcompute.GalleryImageVersion
}

// CreateGalleryImageVersion creates a gallery image version
// CreateGalleryImageVersion creates a gallery image version.
func CreateGalleryImageVersion(ctx context.Context, in *CreateGalleryImageVersionInput) (*CreateGalleryImageVersionOutput, error) {
galleryImageVersionsClient := in.ComputeClientFactory.NewGalleryImageVersionsClient()

Expand Down
8 changes: 3 additions & 5 deletions pkg/infrastructure/azure/storage.go
Expand Up @@ -230,12 +230,12 @@ func doUploadPagesFromURL(ctx context.Context, pageBlobClient *pageblob.Client,
// Azure only allows 4MB chunks, See
// https://docs.microsoft.com/rest/api/storageservices/put-page-from-url
pageSize := int64(1024 * 1024 * 4)
leftOverBytes := int64(imageLength % pageSize)
leftOverBytes := imageLength % pageSize
offset := int64(0)
pages := int64(0)

if imageLength > pageSize {
pages = int64(imageLength / pageSize)
pages = imageLength / pageSize
if imageLength%pageSize > 0 {
pages++
}
Expand All @@ -254,10 +254,9 @@ func doUploadPagesFromURL(ctx context.Context, pageBlobClient *pageblob.Client,
threadGroups++
}

//var mutex sync.Mutex
var wg sync.WaitGroup
var threadError error
var res error = nil
var res error

pagesLeft := pages
for threadGroup := int64(0); threadGroup < threadGroups; threadGroup++ {
Expand All @@ -275,7 +274,6 @@ func doUploadPagesFromURL(ctx context.Context, pageBlobClient *pageblob.Client,
if offset+pageSize >= imageLength && leftOverBytes > 0 {
pageSize = leftOverBytes
leftOverBytes = 0

} else if offset > imageLength {
break
}
Expand Down

0 comments on commit 8e6ef5d

Please sign in to comment.