k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/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 = "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 &Addon{}, 55 &AddonList{}, 56 &AddonConfig{}, 57 &AddonConfigList{}, 58 &AdmissionPlugin{}, 59 &AdmissionPluginList{}, 60 &Alertmanager{}, 61 &AlertmanagerList{}, 62 &Cluster{}, 63 &ClusterList{}, 64 &ClusterTemplate{}, 65 &ClusterTemplateList{}, 66 &ClusterTemplateInstance{}, 67 &ClusterTemplateInstanceList{}, 68 &DashboardConfiguration{}, 69 &DashboardConfigurationList{}, 70 &Datacenter{}, 71 &DatacenterList{}, 72 &GrafanaOrg{}, 73 &GrafanaOrgList{}, 74 &IPAMAllocation{}, 75 &IPAMAllocationList{}, 76 &IPAMPool{}, 77 &IPAMPoolList{}, 78 &KubermaticConfiguration{}, 79 &KubermaticConfigurationList{}, 80 &MLAClusterConfiguration{}, 81 &MLAClusterConfigurationList{}, 82 &MLARuleGroup{}, 83 &MLARuleGroupList{}, 84 &Preset{}, 85 &PresetList{}, 86 &SSHKeyBinding{}, 87 &SSHKeyBindingList{}, 88 &User{}, 89 &UserList{}, 90 &UserSSHKey{}, 91 &UserSSHKeyList{}, 92 ) 93 94 // make EE-only types available to have them be included in the code generation 95 scheme.AddKnownTypes(SchemeGroupVersion, 96 &AllowedRegistry{}, 97 &AllowedRegistryList{}, 98 &Constraint{}, 99 &ConstraintList{}, 100 &ConstraintTemplate{}, 101 &ConstraintTemplateList{}, 102 &EtcdBackupConfig{}, 103 &EtcdBackupConfigList{}, 104 &EtcdRestore{}, 105 &EtcdRestoreList{}, 106 &ExternalCluster{}, 107 &ExternalClusterList{}, 108 &ResourceQuota{}, 109 &ResourceQuotaList{}, 110 ) 111 112 metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 113 return nil 114 }