Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Büringer <[email protected]>
  • Loading branch information
rikatz and sbueringer authored Aug 11, 2023
1 parent 950f4f0 commit b06efe2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/services/govmomi/vcenter/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func Clone(ctx *context.VMContext, bootstrapData []byte, format bootstrapv1.Form

var hubs []pbmTypes.PbmPlacementHub

// If there's a datastore request, it should be the only one requested from Storage Policy
// If there's a Datastore configured, it should be the only one for which we check if it matches the requirements of the Storage Policy
if datastoreRef != nil {
hubs = append(hubs, pbmTypes.PbmPlacementHub{
HubType: datastoreRef.Type,
Expand All @@ -235,7 +235,7 @@ func Clone(ctx *context.VMContext, bootstrapData []byte, format bootstrapv1.Form
dsGetter := object.NewComputeResource(ctx.Session.Client.Client, cluster.Reference())
datastores, err := dsGetter.Datastores(ctx)
if err != nil {
return errors.Wrapf(err, "unable to list datastores from requested pool")
return errors.Wrapf(err, "unable to list datastores from owning cluster of requested resourcepool")
}
for _, ds := range datastores {
hubs = append(hubs, pbmTypes.PbmPlacementHub{
Expand All @@ -256,8 +256,9 @@ func Clone(ctx *context.VMContext, bootstrapData []byte, format bootstrapv1.Form
return fmt.Errorf("no compatible datastores found for storage policy: %s", ctx.VSphereVM.Spec.StoragePolicyName)
}

// If datastoreRef is nil here means that the user didn't specified a datastore with storage policy
// so we should select one for the user
// If datastoreRef is nil here it means that the user didn't specify a Datastore. So we should

Check failure on line 259 in pkg/services/govmomi/vcenter/clone.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default (gci)
// select one of the datastores of the owning cluster of the resource pool that matched the
// requirements of the storage policy.
if datastoreRef == nil {
r := rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec
ds := result.CompatibleDatastores()[r.Intn(len(result.CompatibleDatastores()))]
Expand Down

0 comments on commit b06efe2

Please sign in to comment.