Skip to content
This repository was archived by the owner on Mar 27, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions api/v1alpha1/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have sufficient context to determine between this reason and the UniqueIDNotReady below? Once the VM is created, we have the MoID/UniqueID. What does "fully created" mean in the context here?


// 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"
)
29 changes: 22 additions & 7 deletions api/v1alpha1/virtualmachinepublishrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -340,7 +355,7 @@ func (vmpr *VirtualMachinePublishRequest) markCondition(
}
if reason == "" && status == corev1.ConditionTrue {
reason = VirtualMachinePublishRequestConditionSuccess
} else {
} else if reason == "" {
reason = string(status)
}

Expand Down
25 changes: 21 additions & 4 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.