Skip to content

Commit

Permalink
api: Update SSP API version to v1beta3
Browse files Browse the repository at this point in the history
The new API version removes feature gates and unused
parameters. It is directly compatible with the old version,
so a conversion webhook is not needed.

The stored version is still set to v1beta2, and ssp-operator
watches this old version. In a next release we may switch
to using the v1beta3 as stored version.

Signed-off-by: Andrej Krejcir <[email protected]>
  • Loading branch information
akrejcir committed Nov 14, 2024
1 parent 501bb28 commit 32a54f2
Show file tree
Hide file tree
Showing 21 changed files with 5,716 additions and 134 deletions.
14 changes: 14 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ layout: go.kubebuilder.io/v3
projectName: ssp-operator
repo: kubevirt.io/ssp-operator
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubevirt.io
group: ssp
kind: SSP
path: kubevirt.io/ssp-operator/api/v1beta3
version: v1beta3
webhooks:
# conversion: true
# defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
Expand Down
36 changes: 36 additions & 0 deletions api/v1beta3/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1beta3 contains API Schema definitions for the ssp v1beta3 API group
// +kubebuilder:object:generate=true
// +groupName=ssp.kubevirt.io
package v1beta3

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "ssp.kubevirt.io", Version: "v1beta3"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
121 changes: 121 additions & 0 deletions api/v1beta3/ssp_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta3

import (
ocpv1 "github.com/openshift/api/config/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cdiv1beta1 "kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1"
lifecycleapi "kubevirt.io/controller-lifecycle-operator-sdk/api"
)

const (
OperatorPausedAnnotation = "kubevirt.io/operator.paused"
)

type TemplateValidator struct {
// Replicas is the number of replicas of the template validator pod
//+kubebuilder:validation:Minimum=0
//+kubebuilder:default=2
Replicas *int32 `json:"replicas,omitempty"`

// Placement describes the node scheduling configuration
Placement *lifecycleapi.NodePlacement `json:"placement,omitempty"`
}

type CommonTemplates struct {
// Namespace is the k8s namespace where CommonTemplates should be installed
//+kubebuilder:validation:MaxLength=63
//+kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
Namespace string `json:"namespace"`

// DataImportCronTemplates defines a list of DataImportCrons managed by the SSP Operator.
DataImportCronTemplates []DataImportCronTemplate `json:"dataImportCronTemplates,omitempty"`
}

// SSPSpec defines the desired state of SSP
type SSPSpec struct {
// TemplateValidator is configuration of the template validator operand
TemplateValidator *TemplateValidator `json:"templateValidator,omitempty"`

// CommonTemplates is the configuration of the common templates operand
CommonTemplates CommonTemplates `json:"commonTemplates"`

// TLSSecurityProfile is a configuration for the TLS.
TLSSecurityProfile *ocpv1.TLSSecurityProfile `json:"tlsSecurityProfile,omitempty"`

// TokenGenerationService configures the service for generating tokens to access VNC for a VM.
TokenGenerationService *TokenGenerationService `json:"tokenGenerationService,omitempty"`
}

// DataImportCronTemplate defines the template type for DataImportCrons.
// It requires metadata.name to be specified while leaving namespace as optional.
type DataImportCronTemplate struct {
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec cdiv1beta1.DataImportCronSpec `json:"spec"`
}

// AsDataImportCron converts the DataImportCronTemplate to a cdiv1beta1.DataImportCron
func (t *DataImportCronTemplate) AsDataImportCron() cdiv1beta1.DataImportCron {
return cdiv1beta1.DataImportCron{
ObjectMeta: t.ObjectMeta,
Spec: t.Spec,
}
}

// TokenGenerationService configures the service for generating tokens to access VNC for a VM.
type TokenGenerationService struct {
Enabled bool `json:"enabled,omitempty"`
}

// SSPStatus defines the observed state of SSP
type SSPStatus struct {
lifecycleapi.Status `json:",inline"`

// Paused is true when the operator notices paused annotation.
Paused bool `json:"paused,omitempty"`

// ObservedGeneration is the latest generation observed by the operator.
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

// SSP is the Schema for the ssps API
type SSP struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SSPSpec `json:"spec,omitempty"`
Status SSPStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&SSP{}, &SSPList{})
}
210 changes: 210 additions & 0 deletions api/v1beta3/zz_generated.deepcopy.go

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

Loading

0 comments on commit 32a54f2

Please sign in to comment.