Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Fast Deploy Part Deux (Experimental) #851

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ linters-settings:
pkg: github.com/vmware-tanzu/vm-operator/pkg/config
- alias: pkgctx
pkg: github.com/vmware-tanzu/vm-operator/pkg/context
- alias: pkgerr
pkg: github.com/vmware-tanzu/vm-operator/pkg/pkgerr
- alias: ctxop
pkg: github.com/vmware-tanzu/vm-operator/pkg/context/operation
- alias: pkgmgr
Expand All @@ -90,6 +92,10 @@ linters-settings:
pkg: github.com/vmware-tanzu/vm-operator/pkg/util
- alias: proberctx
pkg: github.com/vmware-tanzu/vm-operator/pkg/prober/context
- alias: dsutil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/datastore
- alias: clsutil
pkg: github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/library

depguard:
rules:
Expand Down
12 changes: 10 additions & 2 deletions api/v1alpha3/virtualmachineimage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ type VirtualMachineImageStatus struct {
Type string `json:"type,omitempty"`
}

func (i VirtualMachineImageStatus) GetConditions() []metav1.Condition {
return i.Conditions
}

func (i *VirtualMachineImageStatus) SetConditions(conditions []metav1.Condition) {
i.Conditions = conditions
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,shortName=vmi;vmimage
// +kubebuilder:storageversion
Expand All @@ -273,7 +281,7 @@ type VirtualMachineImage struct {
Status VirtualMachineImageStatus `json:"status,omitempty"`
}

func (i *VirtualMachineImage) GetConditions() []metav1.Condition {
func (i VirtualMachineImage) GetConditions() []metav1.Condition {
return i.Status.Conditions
}

Expand Down Expand Up @@ -311,7 +319,7 @@ type ClusterVirtualMachineImage struct {
Status VirtualMachineImageStatus `json:"status,omitempty"`
}

func (i *ClusterVirtualMachineImage) GetConditions() []metav1.Condition {
func (i ClusterVirtualMachineImage) GetConditions() []metav1.Condition {
return i.Status.Conditions
}

Expand Down
202 changes: 202 additions & 0 deletions api/v1alpha3/virtualmachineimagecache_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// // © Broadcom. All Rights Reserved.
// The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
// SPDX-License-Identifier: Apache-2.0

package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// VirtualMachineImageCacheConditionProviderReady indicates the underlying
// provider is fully synced, including its disks being available locally on
// some datastore.
VirtualMachineImageCacheConditionProviderReady = "VirtualMachineImageCacheProviderReady"

// VirtualMachineImageCacheConditionDisksReady indicates the disks are
// cached in a given location.
VirtualMachineImageCacheConditionDisksReady = "VirtualMachineImageCacheDisksReady"

// VirtualMachineImageCacheConditionOVFReady indicates the OVF is cached.
VirtualMachineImageCacheConditionOVFReady = "VirtualMachineImageCacheOVFReady"
)

type VirtualMachineImageCacheObjectRef struct {
// Kind is a string value representing the REST resource this object
// represents.
// Servers may infer this from the endpoint the client submits requests to.
// Cannot be updated.
// In CamelCase.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
Kind string `json:"kind"`

// +optional

// Namespace refers to a namespace.
// This field will be empty if Kind refers to a cluster-scoped resource.
Namespace string `json:"namespace,omitempty"`

// Name refers to a unique resource.
// More info: http://kubernetes.io/docs/user-guide/identifiers#names
Name string `json:"name"`
}

type VirtualMachineImageCacheLocationSpec struct {
// DatacenterID describes the ID of the datacenter to which the image should
// be cached.
DatacenterID string `json:"datacenterID"`

// DatastoreID describes the ID of the datastore to which the image should
// be cached.
DatastoreID string `json:"datastoreID"`
}

// VirtualMachineImageCacheSpec defines the desired state of
// VirtualMachineImageCache.
type VirtualMachineImageCacheSpec struct {
// ProviderID describes the ID of the provider item to which the image
// corresponds.
// If the provider is Content Library, the ID refers to a Content Library
// item.
ProviderID string `json:"providerID"`

// ProviderVersion describes the version of the provider item to which the
// image corresponds.
// The provider is Content Library, the version is the content version.
ProviderVersion string `json:"providerVersion"`

// +optional
// +listType=map
// +listMapKey=datacenterID
// +listMapKey=datastoreID

// Locations describes the locations where the image should be cached.
Locations []VirtualMachineImageCacheLocationSpec `json:"locations,omitempty"`
}

func (s *VirtualMachineImageCacheSpec) SetLocation(dcID, dsID string) {
for i := range s.Locations {
l := s.Locations[i]
if l.DatacenterID == dcID && l.DatastoreID == dsID {
return
}
}
s.Locations = append(s.Locations, VirtualMachineImageCacheLocationSpec{
DatacenterID: dcID,
DatastoreID: dsID,
})
}

type VirtualMachineImageCacheLocationStatus struct {

// DatacenterID describes the ID of the datacenter to which the image should
// be cached.
DatacenterID string `json:"datacenterID"`

// DatastoreID describes the ID of the datastore to which the image should
// be cached.
DatastoreID string `json:"datastoreID"`

// +optional

// Files describes the paths to the image's cached files on this datastore.
Files []string `json:"files,omitempty"`

// +optional

// Conditions describes any conditions associated with this cache location.
//
// Generally this should just include the ReadyType condition.
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

func (i VirtualMachineImageCacheLocationStatus) GetConditions() []metav1.Condition {
return i.Conditions
}

func (i *VirtualMachineImageCacheLocationStatus) SetConditions(conditions []metav1.Condition) {
i.Conditions = conditions
}

type VirtualMachineImageCacheOVFStatus struct {

// +optional

// ConfigMapName describes the name of the ConfigMap resource that contains
// the image's OVF envelope encoded as YAML. The data is located in the
// ConfigMap key "value".
ConfigMapName string `json:"configMapName,omitempty"`

// +optional

// ProviderVersion describes the observed provider version at which the OVF
// is cached.
// The provider is Content Library, the version is the content version.
ProviderVersion string `json:"providerVersion,omitempty"`
}

// VirtualMachineImageCacheStatus defines the observed state of
// VirtualMachineImageCache.
type VirtualMachineImageCacheStatus struct {

// +optional
// +listType=map
// +listMapKey=datacenterID
// +listMapKey=datastoreID

// Locations describe the observed locations where the image is cached.
Locations []VirtualMachineImageCacheLocationStatus `json:"locations,omitempty"`

// +optional

// OVF describes the observed status of the cached OVF content.
OVF *VirtualMachineImageCacheOVFStatus `json:"ovf,omitempty"`

// +optional

// Conditions describes any conditions associated with this cached image.
//
// Generally this should just include the ReadyType condition, which will
// only be True if all of the cached locations also have True ReadyType
// condition.
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

func (i VirtualMachineImageCache) GetConditions() []metav1.Condition {
return i.Status.Conditions
}

func (i *VirtualMachineImageCache) SetConditions(conditions []metav1.Condition) {
i.Status.Conditions = conditions
}

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Namespaced,shortName=vmic;vmicache;vmimagecache
// +kubebuilder:storageversion
// +kubebuilder:subresource:status

// VirtualMachineImageCache is the schema for the
// virtualmachineimagecaches API.
type VirtualMachineImageCache struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec VirtualMachineImageCacheSpec `json:"spec,omitempty"`
Status VirtualMachineImageCacheStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// VirtualMachineImageCacheList contains a list of VirtualMachineImageCache.
type VirtualMachineImageCacheList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VirtualMachineImageCache `json:"items"`
}

func init() {
objectTypes = append(objectTypes,
&VirtualMachineImageCache{},
&VirtualMachineImageCacheList{})
}
Loading
Loading