mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #77189 from xiaojingchen/fix-golint-failures
Fix golint failures in cmd/kube-controller-manager
This commit is contained in:
commit
aba8040669
@ -72,16 +72,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Jitter used when starting controller managers
|
// ControllerStartJitter is the Jitter used when starting controller managers
|
||||||
ControllerStartJitter = 1.0
|
ControllerStartJitter = 1.0
|
||||||
// ConfigzName is the name used for register kube-controller manager /configz, same with GroupName.
|
// ConfigzName is the name used for register kube-controller manager /configz, same with GroupName.
|
||||||
ConfigzName = "kubecontrollermanager.config.k8s.io"
|
ConfigzName = "kubecontrollermanager.config.k8s.io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ControllerLoopMode is the kube-controller-manager's mode of running controller loops that are cloud provider dependent
|
||||||
type ControllerLoopMode int
|
type ControllerLoopMode int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// IncludeCloudLoops means the kube-controller-manager include the controller loops that are cloud provider dependent
|
||||||
IncludeCloudLoops ControllerLoopMode = iota
|
IncludeCloudLoops ControllerLoopMode = iota
|
||||||
|
// ExternalLoops means the kube-controller-manager exclude the controller loops that are cloud provider dependent
|
||||||
ExternalLoops
|
ExternalLoops
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -284,6 +287,7 @@ func Run(c *config.CompletedConfig, stopCh <-chan struct{}) error {
|
|||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ControllerContext defines the context object for controller
|
||||||
type ControllerContext struct {
|
type ControllerContext struct {
|
||||||
// ClientBuilder will provide a client for this controller to use
|
// ClientBuilder will provide a client for this controller to use
|
||||||
ClientBuilder controller.ControllerClientBuilder
|
ClientBuilder controller.ControllerClientBuilder
|
||||||
@ -328,6 +332,7 @@ type ControllerContext struct {
|
|||||||
ResyncPeriod func() time.Duration
|
ResyncPeriod func() time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsControllerEnabled checks if the context's controllers enabled or not
|
||||||
func (c ControllerContext) IsControllerEnabled(name string) bool {
|
func (c ControllerContext) IsControllerEnabled(name string) bool {
|
||||||
return genericcontrollermanager.IsControllerEnabled(name, ControllersDisabledByDefault, c.ComponentConfig.Generic.Controllers)
|
return genericcontrollermanager.IsControllerEnabled(name, ControllersDisabledByDefault, c.ComponentConfig.Generic.Controllers)
|
||||||
}
|
}
|
||||||
@ -337,6 +342,7 @@ func (c ControllerContext) IsControllerEnabled(name string) bool {
|
|||||||
// The bool indicates whether the controller was enabled.
|
// The bool indicates whether the controller was enabled.
|
||||||
type InitFunc func(ctx ControllerContext) (debuggingHandler http.Handler, enabled bool, err error)
|
type InitFunc func(ctx ControllerContext) (debuggingHandler http.Handler, enabled bool, err error)
|
||||||
|
|
||||||
|
// KnownControllers returns all known controllers's name
|
||||||
func KnownControllers() []string {
|
func KnownControllers() []string {
|
||||||
ret := sets.StringKeySet(NewControllerInitializers(IncludeCloudLoops))
|
ret := sets.StringKeySet(NewControllerInitializers(IncludeCloudLoops))
|
||||||
|
|
||||||
@ -351,6 +357,7 @@ func KnownControllers() []string {
|
|||||||
return ret.List()
|
return ret.List()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ControllersDisabledByDefault is the set of controllers which is disabled by default
|
||||||
var ControllersDisabledByDefault = sets.NewString(
|
var ControllersDisabledByDefault = sets.NewString(
|
||||||
"bootstrapsigner",
|
"bootstrapsigner",
|
||||||
"tokencleaner",
|
"tokencleaner",
|
||||||
@ -405,6 +412,7 @@ func NewControllerInitializers(loopMode ControllerLoopMode) map[string]InitFunc
|
|||||||
return controllers
|
return controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAvailableResources gets the map which contains all available resources of the apiserver
|
||||||
// TODO: In general, any controller checking this needs to be dynamic so
|
// TODO: In general, any controller checking this needs to be dynamic so
|
||||||
// users don't have to restart their controller manager if they change the apiserver.
|
// users don't have to restart their controller manager if they change the apiserver.
|
||||||
// Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.
|
// Until we get there, the structure here needs to be exposed for the construction of a proper ControllerContext.
|
||||||
@ -484,6 +492,7 @@ func CreateControllerContext(s *config.CompletedConfig, rootClientBuilder, clien
|
|||||||
return ctx, nil
|
return ctx, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StartControllers starts a set of controllers with a specified ControllerContext
|
||||||
func StartControllers(ctx ControllerContext, startSATokenController InitFunc, controllers map[string]InitFunc, unsecuredMux *mux.PathRecorderMux) error {
|
func StartControllers(ctx ControllerContext, startSATokenController InitFunc, controllers map[string]InitFunc, unsecuredMux *mux.PathRecorderMux) error {
|
||||||
// Always start the SA token controller first using a full-power client, since it needs to mint tokens for the rest
|
// Always start the SA token controller first using a full-power client, since it needs to mint tokens for the rest
|
||||||
// If this fails, just return here and fail since other controllers won't be able to get credentials.
|
// If this fails, just return here and fail since other controllers won't be able to get credentials.
|
||||||
|
@ -14,12 +14,13 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Package app imports the API groups that the client will support
|
||||||
// TODO: Remove this file when namespace controller and garbage collector
|
// TODO: Remove this file when namespace controller and garbage collector
|
||||||
// stops using legacyscheme.Registry.RESTMapper()
|
// stops using legacyscheme.Registry.RESTMapper()
|
||||||
package app
|
package app
|
||||||
|
|
||||||
// These imports are the API groups the client will support.
|
|
||||||
import (
|
import (
|
||||||
|
// These imports are the API groups the client will support.
|
||||||
_ "k8s.io/kubernetes/pkg/apis/apps/install"
|
_ "k8s.io/kubernetes/pkg/apis/apps/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/authentication/install"
|
_ "k8s.io/kubernetes/pkg/apis/authentication/install"
|
||||||
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
_ "k8s.io/kubernetes/pkg/apis/authorization/install"
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
|
|
||||||
// Cloud providers
|
// Cloud providers
|
||||||
cloudprovider "k8s.io/cloud-provider"
|
cloudprovider "k8s.io/cloud-provider"
|
||||||
|
// ensure the cloud providers are installed
|
||||||
_ "k8s.io/kubernetes/pkg/cloudprovider/providers"
|
_ "k8s.io/kubernetes/pkg/cloudprovider/providers"
|
||||||
// Volume plugins
|
// Volume plugins
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
cmd/cloud-controller-manager/app/apis/config/v1alpha1
|
cmd/cloud-controller-manager/app/apis/config/v1alpha1
|
||||||
cmd/kube-apiserver/app
|
cmd/kube-apiserver/app
|
||||||
cmd/kube-controller-manager/app
|
|
||||||
cmd/kubeadm/app/apis/kubeadm/v1beta1
|
cmd/kubeadm/app/apis/kubeadm/v1beta1
|
||||||
cmd/kubeadm/app/apis/kubeadm/v1beta2
|
cmd/kubeadm/app/apis/kubeadm/v1beta2
|
||||||
pkg/apis/abac/latest
|
pkg/apis/abac/latest
|
||||||
|
@ -150,7 +150,7 @@ func exampleDeployment(name string) *appsv1.Deployment {
|
|||||||
|
|
||||||
func brokenWebhookConfig(name string) *admissionregistrationv1beta1.ValidatingWebhookConfiguration {
|
func brokenWebhookConfig(name string) *admissionregistrationv1beta1.ValidatingWebhookConfiguration {
|
||||||
var path string
|
var path string
|
||||||
var failurePolicy = admissionregistrationv1beta1.Fail
|
failurePolicy := admissionregistrationv1beta1.Fail
|
||||||
return &admissionregistrationv1beta1.ValidatingWebhookConfiguration{
|
return &admissionregistrationv1beta1.ValidatingWebhookConfiguration{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Loading…
Reference in New Issue
Block a user