k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/ee.apps.kubermatic/v1/register.go (about)

     1  /*
     2  Copyright 2023 The Kubermatic Kubernetes Platform contributors.
     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  
    17  package v1
    18  
    19  import (
    20  	"fmt"
    21  
    22  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  	"k8s.io/apimachinery/pkg/runtime"
    24  	"k8s.io/apimachinery/pkg/runtime/schema"
    25  	"k8s.io/client-go/kubernetes/scheme"
    26  )
    27  
    28  func init() {
    29  	if err := AddToScheme(scheme.Scheme); err != nil {
    30  		panic(fmt.Sprintf("failed to add kubermatic scheme: %v", err))
    31  	}
    32  }
    33  
    34  // GroupName is the group name use in this package.
    35  const GroupName = "ee.apps.kubermatic.k8c.io"
    36  const GroupVersion = "v1"
    37  
    38  var (
    39  	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
    40  	AddToScheme   = SchemeBuilder.AddToScheme
    41  
    42  	// SchemeGroupVersion is group version used to register these objects.
    43  	SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: GroupVersion}
    44  )
    45  
    46  // Resource takes an unqualified resource and returns a Group qualified GroupResource.
    47  func Resource(resource string) schema.GroupResource {
    48  	return SchemeGroupVersion.WithResource(resource).GroupResource()
    49  }
    50  
    51  // Adds the list of known types to api.Scheme.
    52  func addKnownTypes(scheme *runtime.Scheme) error {
    53  	scheme.AddKnownTypes(SchemeGroupVersion,
    54  		&ApplicationDefinition{},
    55  		&ApplicationDefinitionList{},
    56  		&ApplicationInstallation{},
    57  		&ApplicationInstallationList{},
    58  	)
    59  
    60  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    61  	return nil
    62  }