github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/cloud/pkg/apis/reliablesyncs/v1alpha1/register.go (about)

     1  // Copyright 2020 The KubeEdge Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package v1alpha1
    16  
    17  import (
    18  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    19  	"k8s.io/apimachinery/pkg/runtime"
    20  	"k8s.io/apimachinery/pkg/runtime/schema"
    21  )
    22  
    23  var (
    24  	SchemeBuilder      runtime.SchemeBuilder
    25  	localSchemeBuilder = &SchemeBuilder
    26  	AddToScheme        = localSchemeBuilder.AddToScheme
    27  )
    28  
    29  const (
    30  	// GroupName is the group name use in this package.
    31  	GroupName = "reliablesyncs.kubeedge.io"
    32  	// Version is the API version.
    33  	Version = "v1alpha1"
    34  )
    35  
    36  var (
    37  	// SchemeGroupVersion is the group version used to register these objects.
    38  	SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: Version}
    39  )
    40  
    41  func init() {
    42  	// We only register manually written functions here. The registration of the
    43  	// generated functions takes place in the generated files. The separation
    44  	// makes the code compile even when the generated files are missing.
    45  	localSchemeBuilder.Register(addKnownTypes)
    46  }
    47  
    48  // Resource takes an unqualified resource and returns a Group-qualified GroupResource.
    49  func Resource(resource string) schema.GroupResource {
    50  	return SchemeGroupVersion.WithResource(resource).GroupResource()
    51  }
    52  
    53  // addKnownTypes adds the set of types defined in this package to the supplied scheme.
    54  func addKnownTypes(scheme *runtime.Scheme) error {
    55  	scheme.AddKnownTypes(SchemeGroupVersion,
    56  		&ObjectSync{},
    57  		&ObjectSyncList{},
    58  		&ClusterObjectSync{},
    59  		&ClusterObjectSyncList{},
    60  	)
    61  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    62  	return nil
    63  }