diff --git a/api/v1alpha1/condition_consts.go b/api/v1alpha1/condition_consts.go index b90d2b4..4429c1c 100644 --- a/api/v1alpha1/condition_consts.go +++ b/api/v1alpha1/condition_consts.go @@ -106,3 +106,33 @@ const ( // is not prepared for VMService consumption. VirtualMachineImageV1Alpha1NotCompatibleReason = "VirtualMachineImageV1Alpha1NotCompatible" ) + +// Condition.Reason for Conditions related to VirtualMachinePublishRequest. +const ( + // VirtualMachinePublishRequestSourceVMNotFoundReason (Severity=Error) documents that the source VM is not found. + VirtualMachinePublishRequestSourceVMNotFoundReason = "SourceVMNotFound" + + // VirtualMachinePublishRequestSourceVMNotCreatedReason (Severity=Error) documents that the source VM + // hasn't been fully created yet. + VirtualMachinePublishRequestSourceVMNotCreatedReason = "SourceVMNotCreated" + + // VirtualMachinePublishRequestSourceVMUniqueIDNotReadyReason (Severity=Error) documents that the source VM + // has empty unique ID in its status. + VirtualMachinePublishRequestSourceVMUniqueIDNotReadyReason = "SourceVMUniqueIDNotReady" + + // VirtualMachinePublishRequestTargetLocationNotFoundReason (Severity=Error) documents that the target location + // content library is not found. + VirtualMachinePublishRequestTargetLocationNotFoundReason = "TargetContentLibraryNotFound" + + // VirtualMachinePublishRequestTargetItemAlreadyExistsReason (Severity=Error) documents that an item with the + // same target name already exists in the content library. + VirtualMachinePublishRequestTargetItemAlreadyExistsReason = "TargetItemAlreadyExists" + + // VirtualMachinePublishRequestUploadingReason (Severity=Info) documents that the VM publish work is still in progress. + // The target item is uploading to the content library. + VirtualMachinePublishRequestUploadingReason = "Uploading" + + // VirtualMachinePublishRequestUploadFailureReason (Severity=Error) documents that the VM publish work failed. + // The target item failed to be uploaded to the content library. + VirtualMachinePublishRequestUploadFailureReason = "UploadFailure" +) diff --git a/api/v1alpha1/virtualmachinepublishrequest_types.go b/api/v1alpha1/virtualmachinepublishrequest_types.go index 6b7fcfb..7e5a210 100644 --- a/api/v1alpha1/virtualmachinepublishrequest_types.go +++ b/api/v1alpha1/virtualmachinepublishrequest_types.go @@ -82,6 +82,12 @@ type VirtualMachinePublishRequestSource struct { type VirtualMachinePublishRequestTargetItem struct { // Name is the name of the published object. // + // If the spec.target.location.apiVersion equals + // imageregistry.vmware.com/v1alpha1 and the spec.target.location.kind + // equals ContentLibrary, then this should be the name that will + // show up in vCenter Content Library, not the custom resource name + // in the namespace. + // // If omitted then the controller will use spec.source.name + "-image". // // +optional @@ -126,21 +132,20 @@ type VirtualMachinePublishRequestTargetLocation struct { // typically a ContentLibrary resource. type VirtualMachinePublishRequestTarget struct { // Item contains information about the name of the object to which - // the VM is published, as well as whether or not to overwrite an - // existing object with the same name. + // the VM is published. // // Please note this value is optional and if omitted, the controller // will use spec.source.name + "-image" as the name of the published // item. // // +optional - Item VirtualMachinePublishRequestTargetItem `json:"item,omitempty"` + Item *VirtualMachinePublishRequestTargetItem `json:"item,omitempty"` // Location contains information about the location to which to publish // the VM. // // +optional - Location VirtualMachinePublishRequestTargetLocation `json:"location,omitempty"` + Location *VirtualMachinePublishRequestTargetLocation `json:"location,omitempty"` } // VirtualMachinePublishRequestSpec defines the desired state of a @@ -161,7 +166,7 @@ type VirtualMachinePublishRequestSpec struct { // a resource exists, then it is the source of the publication. // // +optional - Source VirtualMachinePublishRequestSource `json:"source,omitempty"` + Source *VirtualMachinePublishRequestSource `json:"source,omitempty"` // Target is the target of the publication request, ex. item // information and a ContentLibrary resource. @@ -179,7 +184,7 @@ type VirtualMachinePublishRequestSpec struct { // will be marked in error. // // +optional - Target VirtualMachinePublishRequestTarget `json:"target,omitempty"` + Target *VirtualMachinePublishRequestTarget `json:"target,omitempty"` // TTLSecondsAfterFinished is the time-to-live duration for how long this // resource will be allowed to exist once the publication operation @@ -215,6 +220,16 @@ type VirtualMachinePublishRequestStatus struct { // +optional StartTime metav1.Time `json:"startTime,omitempty"` + // Attempts represents the number of times the request has been attempted. + // + // +optional + Attempts int64 `json:"attempts,omitempty"` + + // LastAttemptTime represents the time when the latest request was sent. + // + // +optional + LastAttemptTime metav1.Time `json:"lastAttemptTime,omitempty"` + // ImageName is the name of the VirtualMachineImage resource that is // eventually realized in the same namespace as the VM and publication // request after the publication operation completes. @@ -340,7 +355,7 @@ func (vmpr *VirtualMachinePublishRequest) markCondition( } if reason == "" && status == corev1.ConditionTrue { reason = VirtualMachinePublishRequestConditionSuccess - } else { + } else if reason == "" { reason = string(status) } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4b5fb11..9343a6a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1353,8 +1353,16 @@ func (in *VirtualMachinePublishRequestSource) DeepCopy() *VirtualMachinePublishR // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualMachinePublishRequestSpec) DeepCopyInto(out *VirtualMachinePublishRequestSpec) { *out = *in - out.Source = in.Source - out.Target = in.Target + if in.Source != nil { + in, out := &in.Source, &out.Source + *out = new(VirtualMachinePublishRequestSource) + **out = **in + } + if in.Target != nil { + in, out := &in.Target, &out.Target + *out = new(VirtualMachinePublishRequestTarget) + (*in).DeepCopyInto(*out) + } if in.TTLSecondsAfterFinished != nil { in, out := &in.TTLSecondsAfterFinished, &out.TTLSecondsAfterFinished *out = new(int64) @@ -1377,6 +1385,7 @@ func (in *VirtualMachinePublishRequestStatus) DeepCopyInto(out *VirtualMachinePu *out = *in in.CompletionTime.DeepCopyInto(&out.CompletionTime) in.StartTime.DeepCopyInto(&out.StartTime) + in.LastAttemptTime.DeepCopyInto(&out.LastAttemptTime) if in.Conditions != nil { in, out := &in.Conditions, &out.Conditions *out = make([]Condition, len(*in)) @@ -1399,8 +1408,16 @@ func (in *VirtualMachinePublishRequestStatus) DeepCopy() *VirtualMachinePublishR // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VirtualMachinePublishRequestTarget) DeepCopyInto(out *VirtualMachinePublishRequestTarget) { *out = *in - out.Item = in.Item - out.Location = in.Location + if in.Item != nil { + in, out := &in.Item, &out.Item + *out = new(VirtualMachinePublishRequestTargetItem) + **out = **in + } + if in.Location != nil { + in, out := &in.Location, &out.Location + *out = new(VirtualMachinePublishRequestTargetLocation) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualMachinePublishRequestTarget.