...

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

Documentation: kubevirt.io/api/migrations/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 2020 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/migrations"
    28  )
    29  
    30  var (
    31  	// SchemeGroupVersion is group version used to register these objects
    32  	SchemeGroupVersion = schema.GroupVersion{Group: migrations.GroupName, Version: migrations.Version}
    33  
    34  	// Group Version
    35  	GroupVersion = schema.GroupVersion{Group: migrations.GroupName, Version: migrations.Version}
    36  
    37  	// GroupVersionKind
    38  	MigrationPolicyKind     = schema.GroupVersionKind{Group: migrations.GroupName, Version: migrations.Version, Kind: "MigrationPolicy"}
    39  	MigrationPolicyListKind = schema.GroupVersionKind{Group: migrations.GroupName, Version: migrations.Version, Kind: "MigrationPolicyList"}
    40  )
    41  
    42  // Kind takes an unqualified kind and returns back a Group qualified GroupKind
    43  func Kind(kind string) schema.GroupKind {
    44  	return SchemeGroupVersion.WithKind(kind).GroupKind()
    45  }
    46  
    47  // Resource takes an unqualified resource and returns a Group qualified GroupResource
    48  func Resource(resource string) schema.GroupResource {
    49  	return SchemeGroupVersion.WithResource(resource).GroupResource()
    50  }
    51  
    52  var (
    53  	// SchemeBuilder initializes a scheme builder
    54  	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
    55  	// AddToScheme is a global function that registers this API group & version to a scheme
    56  	AddToScheme = SchemeBuilder.AddToScheme
    57  )
    58  
    59  // Adds the list of known types to Scheme.
    60  func addKnownTypes(scheme *runtime.Scheme) error {
    61  	scheme.AddKnownTypes(SchemeGroupVersion,
    62  		&MigrationPolicy{},
    63  		&MigrationPolicyList{})
    64  
    65  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    66  	return nil
    67  }
    68  

View as plain text