k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kube-controller-manager/app/config/config.go (about) 1 /* 2 Copyright 2018 The Kubernetes Authors. 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 config 18 19 import ( 20 apiserver "k8s.io/apiserver/pkg/server" 21 clientset "k8s.io/client-go/kubernetes" 22 restclient "k8s.io/client-go/rest" 23 "k8s.io/client-go/tools/record" 24 kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config" 25 ) 26 27 // Config is the main context object for the controller manager. 28 type Config struct { 29 ComponentConfig kubectrlmgrconfig.KubeControllerManagerConfiguration 30 31 SecureServing *apiserver.SecureServingInfo 32 // LoopbackClientConfig is a config for a privileged loopback connection 33 LoopbackClientConfig *restclient.Config 34 35 Authentication apiserver.AuthenticationInfo 36 Authorization apiserver.AuthorizationInfo 37 38 // the general kube client 39 Client *clientset.Clientset 40 41 // the rest config for the master 42 Kubeconfig *restclient.Config 43 44 EventBroadcaster record.EventBroadcaster 45 EventRecorder record.EventRecorder 46 } 47 48 type completedConfig struct { 49 *Config 50 } 51 52 // CompletedConfig same as Config, just to swap private object. 53 type CompletedConfig struct { 54 // Embed a private pointer that cannot be instantiated outside of this package. 55 *completedConfig 56 } 57 58 // Complete fills in any fields not set that are required to have valid data. It's mutating the receiver. 59 func (c *Config) Complete() *CompletedConfig { 60 cc := completedConfig{c} 61 62 apiserver.AuthorizeClientBearerToken(c.LoopbackClientConfig, &c.Authentication, &c.Authorization) 63 64 return &CompletedConfig{&cc} 65 }