1 // Copyright 2018 The prometheus-operator Authors
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19 "k8s.io/apimachinery/pkg/runtime"
20 "k8s.io/apimachinery/pkg/runtime/schema"
22 "github.com/coreos/prometheus-operator/pkg/apis/monitoring"
25 // SchemeGroupVersion is the group version used to register these objects
26 var SchemeGroupVersion = schema.GroupVersion{Group: monitoring.GroupName, Version: Version}
28 // Resource takes an unqualified resource and returns a Group qualified GroupResource
29 func Resource(resource string) schema.GroupResource {
30 return SchemeGroupVersion.WithResource(resource).GroupResource()
34 // localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
35 SchemeBuilder runtime.SchemeBuilder
36 localSchemeBuilder = &SchemeBuilder
37 AddToScheme = localSchemeBuilder.AddToScheme
41 // We only register manually written functions here. The registration of the
42 // generated functions takes place in the generated files. The separation
43 // makes the code compile even when the generated files are missing.
44 localSchemeBuilder.Register(addKnownTypes)
47 // Adds the list of known types to api.Scheme.
48 func addKnownTypes(scheme *runtime.Scheme) error {
49 scheme.AddKnownTypes(SchemeGroupVersion,
53 &ServiceMonitorList{},
57 &PrometheusRuleList{},
59 metav1.AddToGroupVersion(scheme, SchemeGroupVersion)