...

Source file src/kubevirt.io/api/instancetype/v1alpha1/register.go

Documentation: kubevirt.io/api/instancetype/v1alpha1

     1  /*
     2   * This file is part of the KubeVirt project
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *
     8   *     http://www.apache.org/licenses/LICENSE-2.0
     9   *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   *
    16   * Copyright 2021 Red Hat, Inc.
    17   *
    18   */
    19  
    20  package v1alpha1
    21  
    22  import (
    23  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    24  	"k8s.io/apimachinery/pkg/runtime"
    25  	"k8s.io/apimachinery/pkg/runtime/schema"
    26  
    27  	"kubevirt.io/api/instancetype"
    28  )
    29  
    30  // SchemeGroupVersion is group version used to register these objects
    31  var SchemeGroupVersion = schema.GroupVersion{Group: instancetype.GroupName, Version: "v1alpha1"}
    32  
    33  // Kind takes an unqualified kind and returns back a Group qualified GroupKind
    34  func Kind(kind string) schema.GroupKind {
    35  	return SchemeGroupVersion.WithKind(kind).GroupKind()
    36  }
    37  
    38  // Resource takes an unqualified resource and returns a Group qualified GroupResource
    39  func Resource(resource string) schema.GroupResource {
    40  	return SchemeGroupVersion.WithResource(resource).GroupResource()
    41  }
    42  
    43  var (
    44  	// SchemeBuilder initializes a scheme builder
    45  	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
    46  	// AddToScheme is a global function that registers this API group & version to a scheme
    47  	AddToScheme = SchemeBuilder.AddToScheme
    48  	// required by conversion-gen
    49  	localSchemeBuilder = &SchemeBuilder
    50  )
    51  
    52  // Adds the list of known types to Scheme.
    53  func addKnownTypes(scheme *runtime.Scheme) error {
    54  	scheme.AddKnownTypes(SchemeGroupVersion,
    55  		&VirtualMachineInstancetype{},
    56  		&VirtualMachineInstancetypeList{},
    57  		&VirtualMachineClusterInstancetype{},
    58  		&VirtualMachineClusterInstancetypeList{},
    59  		&VirtualMachinePreference{},
    60  		&VirtualMachinePreferenceList{},
    61  		&VirtualMachineClusterPreference{},
    62  		&VirtualMachineClusterPreferenceList{},
    63  	)
    64  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    65  	return nil
    66  }
    67  

View as plain text