Skip to content

Commit

Permalink
Make provider setting 'vddkInitImage' a const
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Jan 4, 2024
1 parent a2ec605 commit 671c2cb
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions pkg/apis/forklift/v1beta1/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const (
Token = "token"
)

// Provider settings.
const (
VDDK = "vddkInitImage"
)

// Defines the desired state of Provider.
type ProviderSpec struct {
// Provider type.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/plan/adapter/vsphere/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ func (r *Builder) DataVolumes(vmRef ref.Ref, secret *core.Secret, _ *core.Config
URL: url,
SecretRef: secret.Name,
Thumbprint: thumbprint,
InitImageURL: r.Source.Provider.Spec.Settings["vddkInitImage"],
InitImageURL: r.Source.Provider.Spec.Settings[api.VDDK],
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ func (r *KubeVirt) guestConversionPod(vm *plan.VMStatus, vmVolumes []cnv.Volume,
}
// VDDK image
var initContainers []core.Container
if vddkImage, found := r.Source.Provider.Spec.Settings["vddkInitImage"]; found {
if vddkImage, found := r.Source.Provider.Spec.Settings[api.VDDK]; found {
initContainers = append(initContainers, core.Container{
Name: "vddk-side-car",
Image: vddkImage,
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/plan/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ func (r *Reconciler) validateVddkImage(plan *api.Plan) (err error) {
return nil
}

if _, found := source.Spec.Settings["vddkInitImage"]; !found {
if _, found := source.Spec.Settings[api.VDDK]; !found {
plan.Status.SetCondition(vddkNotConfigured)
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (admitter *PlanAdmitter) validateVDDK() error {
return nil
}

if _, found := admitter.sourceProvider.Spec.Settings["vddkInitImage"]; !found {
if _, found := admitter.sourceProvider.Spec.Settings[api.VDDK]; !found {
err := liberr.New("VDDK image is necessary for this type of migration")
log.Error(err, "VDDK image required for this type of migration")
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (admitter *ProviderAdmitter) validateVDDK() error {
return nil
}

if _, found := admitter.provider.Spec.Settings["vddkInitImage"]; found {
if _, found := admitter.provider.Spec.Settings[api.VDDK]; found {
log.Info("VDDK image found, passing")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion tests/suit/vsphere_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var _ = Describe("[level:component]Migration tests for vSphere provider", func()
_, err = utils.WaitForProviderReadyWithTimeout(f.CrClient, namespace, utils.TargetProviderName, 30*time.Second)
Expect(err).ToNot(HaveOccurred())
By("Create vSphere provider")
pr := utils.NewProvider(vsphereProviderName, forkliftv1.VSphere, namespace, map[string]string{}, map[string]string{"vddkInitImage": "quay.io/kubev2v/vddk-test-vmdk"}, "https://vcsim.konveyor-forklift:8989/sdk", s)
pr := utils.NewProvider(vsphereProviderName, forkliftv1.VSphere, namespace, map[string]string{}, map[string]string{forkliftv1.VDDK: "quay.io/kubev2v/vddk-test-vmdk"}, "https://vcsim.konveyor-forklift:8989/sdk", s)
err = utils.CreateProviderFromDefinition(f.CrClient, pr)
Expect(err).ToNot(HaveOccurred())
provider, err := utils.WaitForProviderReadyWithTimeout(f.CrClient, namespace, vsphereProviderName, 30*time.Second)
Expand Down

0 comments on commit 671c2cb

Please sign in to comment.