...

Source file src/kubevirt.io/api/snapshot/v1beta1/register.go

Documentation: kubevirt.io/api/snapshot/v1beta1

     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 2020 Red Hat, Inc.
    17   *
    18   */
    19  
    20  package v1beta1
    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/snapshot"
    28  )
    29  
    30  // SchemeGroupVersion is group version used to register these objects
    31  var SchemeGroupVersion = schema.GroupVersion{Group: snapshot.GroupName, Version: "v1beta1"}
    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  )
    49  
    50  // Adds the list of known types to Scheme.
    51  func addKnownTypes(scheme *runtime.Scheme) error {
    52  	scheme.AddKnownTypes(SchemeGroupVersion,
    53  		&VirtualMachineSnapshot{},
    54  		&VirtualMachineSnapshotList{},
    55  		&VirtualMachineSnapshotContent{},
    56  		&VirtualMachineSnapshotContentList{},
    57  		&VirtualMachineRestore{},
    58  		&VirtualMachineRestoreList{},
    59  	)
    60  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    61  	return nil
    62  }
    63  

View as plain text