mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #68233 from luxas/ccm_cleanup
Automatic merge from submit-queue (batch tested with PRs 68171, 67945, 68233). If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. Move the CloudControllerManagerConfiguration to an API group in `cmd/` **What this PR does / why we need it**: This PR is the last piece of https://github.com/kubernetes/kubernetes/issues/67233. It moves the `CloudControllerManagerConfiguration` to its own `cloudcontrollermanager.config.k8s.io` config API group, but unlike the other components this API group is "private" (only available in `k8s.io/kubernetes`, which limits consumer base), as it's located entirely in `cmd/` vs a staging repo. This decision was made for now as we're not sure what the story for the ccm loading ComponentConfig files is, and probably a "real" file-loading ccm will never exist in core, only helper libraries. Eventually the ccm will only be a library in any case, and implementors will/can use the base types the ccm library API group provides. It's probably good to note that there is no practical implication of this change as the ccm **cannot** read ComponentConfig files. Hencec the code move isn't user-facing. With this change, we're able to remove `pkg/apis/componentconfig`, as this was the last consumer. That is hence done in this PR as well (so the move is easily visible in git, vs first one "big add" then a "big remove"). The only piece of code that was used was the flag helper structs, so I moved them to `pkg/util/flag` that I think makes sense for now. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: ref: kubernetes/community#2354 **Special notes for your reviewer**: This PR builds on top of (first two commits, marked as `Co-authored by: @stewart-yu`) https://github.com/kubernetes/kubernetes/pull/67689 **Release note**: ```release-note NONE ``` /assign @liggitt @sttts @thockin @stewart-yu
This commit is contained in:
		@@ -165,9 +165,9 @@ API rule violation: names_match,k8s.io/kube-controller-manager/config/v1alpha1,V
 | 
			
		||||
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,ResolverConfig
 | 
			
		||||
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesMasqueradeBit
 | 
			
		||||
API rule violation: names_match,k8s.io/kubelet/config/v1beta1,KubeletConfiguration,IPTablesDropBit
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,CloudControllerManagerConfiguration,Generic
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,CloudControllerManagerConfiguration,KubeCloudShared
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,CloudControllerManagerConfiguration,ServiceController
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1,CloudControllerManagerConfiguration,NodeStatusUpdateFrequency
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1,CloudControllerManagerConfiguration,Generic
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1,CloudControllerManagerConfiguration,KubeCloudShared
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1,CloudControllerManagerConfiguration,ServiceController
 | 
			
		||||
API rule violation: names_match,k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1,CloudControllerManagerConfiguration,NodeStatusUpdateFrequency
 | 
			
		||||
API rule violation: names_match,k8s.io/metrics/pkg/apis/custom_metrics/v1beta1,MetricValue,WindowSeconds
 | 
			
		||||
API rule violation: names_match,k8s.io/metrics/pkg/apis/external_metrics/v1beta1,ExternalMetricValue,WindowSeconds
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [
 | 
			
		||||
        ":package-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config:all-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/config:all-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/options:all-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/testing:all-srcs",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,38 +1,23 @@
 | 
			
		||||
package(default_visibility = ["//visibility:public"])
 | 
			
		||||
 | 
			
		||||
load(
 | 
			
		||||
    "@io_bazel_rules_go//go:def.bzl",
 | 
			
		||||
    "go_library",
 | 
			
		||||
    "go_test",
 | 
			
		||||
)
 | 
			
		||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
 | 
			
		||||
 | 
			
		||||
go_library(
 | 
			
		||||
    name = "go_default_library",
 | 
			
		||||
    srcs = [
 | 
			
		||||
        "doc.go",
 | 
			
		||||
        "helpers.go",
 | 
			
		||||
        "register.go",
 | 
			
		||||
        "types.go",
 | 
			
		||||
        "zz_generated.deepcopy.go",
 | 
			
		||||
    ],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/pkg/apis/componentconfig",
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config",
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/controller/apis/config:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/api/core/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_test(
 | 
			
		||||
    name = "go_default_test",
 | 
			
		||||
    srcs = ["helpers_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "package-srcs",
 | 
			
		||||
    srcs = glob(["**"]),
 | 
			
		||||
@@ -44,9 +29,9 @@ filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [
 | 
			
		||||
        ":package-srcs",
 | 
			
		||||
        "//pkg/apis/componentconfig/fuzzer:all-srcs",
 | 
			
		||||
        "//pkg/apis/componentconfig/install:all-srcs",
 | 
			
		||||
        "//pkg/apis/componentconfig/v1alpha1:all-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config/scheme:all-srcs",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config/v1alpha1:all-srcs",
 | 
			
		||||
    ],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
)
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -15,5 +15,6 @@ limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// +k8s:deepcopy-gen=package
 | 
			
		||||
// +groupName=cloudcontrollermanager.config.k8s.io
 | 
			
		||||
 | 
			
		||||
package componentconfig // import "k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
package config // import "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config"
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package componentconfig
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
@@ -22,31 +22,22 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GroupName is the group name use in this package
 | 
			
		||||
const GroupName = "componentconfig"
 | 
			
		||||
const GroupName = "cloudcontrollermanager.config.k8s.io"
 | 
			
		||||
 | 
			
		||||
// SchemeGroupVersion is group version used to register these objects
 | 
			
		||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	SchemeBuilder      runtime.SchemeBuilder
 | 
			
		||||
	localSchemeBuilder = &SchemeBuilder
 | 
			
		||||
	AddToScheme        = localSchemeBuilder.AddToScheme
 | 
			
		||||
	// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
 | 
			
		||||
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
			
		||||
	// AddToScheme is a global function that registers this API group & version to a scheme
 | 
			
		||||
	AddToScheme = SchemeBuilder.AddToScheme
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	// We only register manually written functions here. The registration of the
 | 
			
		||||
	// generated functions takes place in the generated files. The separation
 | 
			
		||||
	// makes the code compile even when the generated files are missing.
 | 
			
		||||
	localSchemeBuilder.Register(addKnownTypes)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Kind takes an unqualified kind and returns a Group qualified GroupKind
 | 
			
		||||
func Kind(kind string) schema.GroupKind {
 | 
			
		||||
	return SchemeGroupVersion.WithKind(kind).GroupKind()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// addKnownTypes registers known types to the given scheme
 | 
			
		||||
func addKnownTypes(scheme *runtime.Scheme) error {
 | 
			
		||||
	// TODO: All structs in this package are about to be moved out,
 | 
			
		||||
	// so nothing should be registered here as this API group is going to be removed soon.
 | 
			
		||||
	scheme.AddKnownTypes(SchemeGroupVersion,
 | 
			
		||||
		&CloudControllerManagerConfiguration{},
 | 
			
		||||
	)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										29
									
								
								cmd/cloud-controller-manager/app/apis/config/scheme/BUILD
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								cmd/cloud-controller-manager/app/apis/config/scheme/BUILD
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
 | 
			
		||||
 | 
			
		||||
go_library(
 | 
			
		||||
    name = "go_default_library",
 | 
			
		||||
    srcs = ["scheme.go"],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/scheme",
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config/v1alpha1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "package-srcs",
 | 
			
		||||
    srcs = glob(["**"]),
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [":package-srcs"],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
)
 | 
			
		||||
@@ -0,0 +1,44 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package scheme
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime/serializer"
 | 
			
		||||
	utilruntime "k8s.io/apimachinery/pkg/util/runtime"
 | 
			
		||||
	"k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config"
 | 
			
		||||
	"k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	// Scheme defines methods for serializing and deserializing API objects.
 | 
			
		||||
	Scheme = runtime.NewScheme()
 | 
			
		||||
	// Codecs provides methods for retrieving codecs and serializers for specific
 | 
			
		||||
	// versions and content types.
 | 
			
		||||
	Codecs = serializer.NewCodecFactory(Scheme)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	AddToScheme(Scheme)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddToScheme adds the types of this group into the given scheme.
 | 
			
		||||
func AddToScheme(scheme *runtime.Scheme) {
 | 
			
		||||
	utilruntime.Must(config.AddToScheme(scheme))
 | 
			
		||||
	utilruntime.Must(v1alpha1.AddToScheme(scheme))
 | 
			
		||||
	utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package componentconfig
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
@@ -23,6 +23,7 @@ import (
 | 
			
		||||
 | 
			
		||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
 | 
			
		||||
 | 
			
		||||
// CloudControllerManagerConfiguration contains elements describing cloud-controller manager.
 | 
			
		||||
type CloudControllerManagerConfiguration struct {
 | 
			
		||||
	metav1.TypeMeta
 | 
			
		||||
 | 
			
		||||
@@ -35,6 +36,7 @@ type CloudControllerManagerConfiguration struct {
 | 
			
		||||
	// ServiceControllerConfiguration holds configuration for ServiceController
 | 
			
		||||
	// related features.
 | 
			
		||||
	ServiceController kubectrlmgrconfig.ServiceControllerConfiguration
 | 
			
		||||
 | 
			
		||||
	// NodeStatusUpdateFrequency is the frequency at which the controller updates nodes' status
 | 
			
		||||
	NodeStatusUpdateFrequency metav1.Duration
 | 
			
		||||
}
 | 
			
		||||
@@ -1,10 +1,4 @@
 | 
			
		||||
package(default_visibility = ["//visibility:public"])
 | 
			
		||||
 | 
			
		||||
load(
 | 
			
		||||
    "@io_bazel_rules_go//go:def.bzl",
 | 
			
		||||
    "go_library",
 | 
			
		||||
    "go_test",
 | 
			
		||||
)
 | 
			
		||||
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
 | 
			
		||||
 | 
			
		||||
go_library(
 | 
			
		||||
    name = "go_default_library",
 | 
			
		||||
@@ -17,9 +11,10 @@ go_library(
 | 
			
		||||
        "zz_generated.deepcopy.go",
 | 
			
		||||
        "zz_generated.defaults.go",
 | 
			
		||||
    ],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1",
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config:go_default_library",
 | 
			
		||||
        "//pkg/controller/apis/config/v1alpha1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library",
 | 
			
		||||
@@ -29,6 +24,17 @@ go_library(
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_test(
 | 
			
		||||
    name = "go_default_test",
 | 
			
		||||
    srcs = ["defaults_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//staging/src/k8s.io/api/core/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "package-srcs",
 | 
			
		||||
    srcs = glob(["**"]),
 | 
			
		||||
@@ -40,11 +46,5 @@ filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [":package-srcs"],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_test(
 | 
			
		||||
    name = "go_default_test",
 | 
			
		||||
    srcs = ["defaults_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = ["//pkg/apis/componentconfig:go_default_library"],
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
)
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -20,11 +20,11 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	kruntime "k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	kubectrlmgrconfigv1alpha1 "k8s.io/kubernetes/pkg/controller/apis/config/v1alpha1"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func addDefaultingFuncs(scheme *kruntime.Scheme) error {
 | 
			
		||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
 | 
			
		||||
	return RegisterDefaults(scheme)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -33,6 +33,7 @@ func SetDefaults_CloudControllerManagerConfiguration(obj *CloudControllerManager
 | 
			
		||||
	if obj.NodeStatusUpdateFrequency == zero {
 | 
			
		||||
		obj.NodeStatusUpdateFrequency = metav1.Duration{Duration: 5 * time.Minute}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// These defaults override the recommended defaults from the apimachineryconfigv1alpha1 package that are applied automatically
 | 
			
		||||
	// These client-connection defaults are specific to the cloud-controller-manager
 | 
			
		||||
	if obj.Generic.ClientConnection.QPS == 0 {
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2017 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -21,13 +21,15 @@ import (
 | 
			
		||||
	"reflect"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	componentconfig "k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	"k8s.io/api/core/v1"
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestCloudControllerDefaultsRoundTrip(t *testing.T) {
 | 
			
		||||
func TestCloudControllerManagerDefaultsRoundTrip(t *testing.T) {
 | 
			
		||||
	ks1 := &CloudControllerManagerConfiguration{}
 | 
			
		||||
	SetDefaults_CloudControllerManagerConfiguration(ks1)
 | 
			
		||||
	cm, err := componentconfig.ConvertObjToConfigMap("CloudControllerManagerConfiguration", ks1)
 | 
			
		||||
	cm, err := convertObjToConfigMap("CloudControllerManagerConfiguration", ks1)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Errorf("unexpected ConvertObjToConfigMap error %v", err)
 | 
			
		||||
	}
 | 
			
		||||
@@ -41,3 +43,21 @@ func TestCloudControllerDefaultsRoundTrip(t *testing.T) {
 | 
			
		||||
		t.Errorf("Expected:\n%#v\n\nGot:\n%#v", ks1, ks2)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// convertObjToConfigMap converts an object to a ConfigMap.
 | 
			
		||||
// This is specifically meant for ComponentConfigs.
 | 
			
		||||
func convertObjToConfigMap(name string, obj runtime.Object) (*v1.ConfigMap, error) {
 | 
			
		||||
	eJSONBytes, err := json.Marshal(obj)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	cm := &v1.ConfigMap{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
			Name: name,
 | 
			
		||||
		},
 | 
			
		||||
		Data: map[string]string{
 | 
			
		||||
			name: string(eJSONBytes[:]),
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	return cm, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -20,11 +20,10 @@ limitations under the License.
 | 
			
		||||
// call.
 | 
			
		||||
 | 
			
		||||
// +k8s:deepcopy-gen=package
 | 
			
		||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/componentconfig
 | 
			
		||||
// +k8s:conversion-gen=k8s.io/apimachinery/pkg/apis/config/v1alpha1
 | 
			
		||||
// +k8s:conversion-gen=k8s.io/apiserver/pkg/apis/config/v1alpha1
 | 
			
		||||
// +k8s:conversion-gen=k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config
 | 
			
		||||
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/controller/apis/config/v1alpha1
 | 
			
		||||
// +k8s:openapi-gen=true
 | 
			
		||||
// +k8s:defaulter-gen=TypeMeta
 | 
			
		||||
// +groupName=cloudcontrollermanager.config.k8s.io
 | 
			
		||||
 | 
			
		||||
package v1alpha1 // import "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
 | 
			
		||||
package v1alpha1 // import "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1"
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -22,14 +22,18 @@ import (
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GroupName is the group name use in this package
 | 
			
		||||
const GroupName = "componentconfig"
 | 
			
		||||
const GroupName = "cloudcontrollermanager.config.k8s.io"
 | 
			
		||||
 | 
			
		||||
// SchemeGroupVersion is group version used to register these objects
 | 
			
		||||
var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	SchemeBuilder      runtime.SchemeBuilder
 | 
			
		||||
	// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
 | 
			
		||||
	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
 | 
			
		||||
	// localSchemeBuilder ïs a pointer to SchemeBuilder instance. Using localSchemeBuilder
 | 
			
		||||
	// defaulting and conversion init funcs are registered as well.
 | 
			
		||||
	localSchemeBuilder = &SchemeBuilder
 | 
			
		||||
	// AddToScheme is a global function that registers this API group & version to a schema
 | 
			
		||||
	AddToScheme = localSchemeBuilder.AddToScheme
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -37,11 +41,13 @@ func init() {
 | 
			
		||||
	// We only register manually written functions here. The registration of the
 | 
			
		||||
	// generated functions takes place in the generated files. The separation
 | 
			
		||||
	// makes the code compile even when the generated files are missing.
 | 
			
		||||
	localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
 | 
			
		||||
	localSchemeBuilder.Register(addDefaultingFuncs)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// addKnownTypes registers known types to the given scheme
 | 
			
		||||
func addKnownTypes(scheme *runtime.Scheme) error {
 | 
			
		||||
	// TODO: All structs in this package are about to be moved out,
 | 
			
		||||
	// so nothing should be registered here as this API group is going to be removed soon.
 | 
			
		||||
	scheme.AddKnownTypes(SchemeGroupVersion,
 | 
			
		||||
		&CloudControllerManagerConfiguration{},
 | 
			
		||||
	)
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 The Kubernetes Authors.
 | 
			
		||||
Copyright 2018 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
@@ -23,7 +23,7 @@ package v1alpha1
 | 
			
		||||
import (
 | 
			
		||||
	conversion "k8s.io/apimachinery/pkg/conversion"
 | 
			
		||||
	runtime "k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	componentconfig "k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	config "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config"
 | 
			
		||||
	configv1alpha1 "k8s.io/kubernetes/pkg/controller/apis/config/v1alpha1"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -34,20 +34,20 @@ func init() {
 | 
			
		||||
// RegisterConversions adds conversion functions to the given scheme.
 | 
			
		||||
// Public to allow building arbitrary schemes.
 | 
			
		||||
func RegisterConversions(s *runtime.Scheme) error {
 | 
			
		||||
	if err := s.AddGeneratedConversionFunc((*CloudControllerManagerConfiguration)(nil), (*componentconfig.CloudControllerManagerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
			
		||||
		return Convert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig_CloudControllerManagerConfiguration(a.(*CloudControllerManagerConfiguration), b.(*componentconfig.CloudControllerManagerConfiguration), scope)
 | 
			
		||||
	if err := s.AddGeneratedConversionFunc((*CloudControllerManagerConfiguration)(nil), (*config.CloudControllerManagerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
			
		||||
		return Convert_v1alpha1_CloudControllerManagerConfiguration_To_config_CloudControllerManagerConfiguration(a.(*CloudControllerManagerConfiguration), b.(*config.CloudControllerManagerConfiguration), scope)
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := s.AddGeneratedConversionFunc((*componentconfig.CloudControllerManagerConfiguration)(nil), (*CloudControllerManagerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
			
		||||
		return Convert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(a.(*componentconfig.CloudControllerManagerConfiguration), b.(*CloudControllerManagerConfiguration), scope)
 | 
			
		||||
	if err := s.AddGeneratedConversionFunc((*config.CloudControllerManagerConfiguration)(nil), (*CloudControllerManagerConfiguration)(nil), func(a, b interface{}, scope conversion.Scope) error {
 | 
			
		||||
		return Convert_config_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(a.(*config.CloudControllerManagerConfiguration), b.(*CloudControllerManagerConfiguration), scope)
 | 
			
		||||
	}); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func autoConvert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig_CloudControllerManagerConfiguration(in *CloudControllerManagerConfiguration, out *componentconfig.CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
func autoConvert_v1alpha1_CloudControllerManagerConfiguration_To_config_CloudControllerManagerConfiguration(in *CloudControllerManagerConfiguration, out *config.CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	if err := configv1alpha1.Convert_v1alpha1_GenericControllerManagerConfiguration_To_config_GenericControllerManagerConfiguration(&in.Generic, &out.Generic, s); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@@ -61,12 +61,12 @@ func autoConvert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Convert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig_CloudControllerManagerConfiguration is an autogenerated conversion function.
 | 
			
		||||
func Convert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig_CloudControllerManagerConfiguration(in *CloudControllerManagerConfiguration, out *componentconfig.CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	return autoConvert_v1alpha1_CloudControllerManagerConfiguration_To_componentconfig_CloudControllerManagerConfiguration(in, out, s)
 | 
			
		||||
// Convert_v1alpha1_CloudControllerManagerConfiguration_To_config_CloudControllerManagerConfiguration is an autogenerated conversion function.
 | 
			
		||||
func Convert_v1alpha1_CloudControllerManagerConfiguration_To_config_CloudControllerManagerConfiguration(in *CloudControllerManagerConfiguration, out *config.CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	return autoConvert_v1alpha1_CloudControllerManagerConfiguration_To_config_CloudControllerManagerConfiguration(in, out, s)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func autoConvert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in *componentconfig.CloudControllerManagerConfiguration, out *CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
func autoConvert_config_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in *config.CloudControllerManagerConfiguration, out *CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	if err := configv1alpha1.Convert_config_GenericControllerManagerConfiguration_To_v1alpha1_GenericControllerManagerConfiguration(&in.Generic, &out.Generic, s); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
@@ -80,7 +80,7 @@ func autoConvert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Convert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration is an autogenerated conversion function.
 | 
			
		||||
func Convert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in *componentconfig.CloudControllerManagerConfiguration, out *CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	return autoConvert_componentconfig_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in, out, s)
 | 
			
		||||
// Convert_config_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration is an autogenerated conversion function.
 | 
			
		||||
func Convert_config_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in *config.CloudControllerManagerConfiguration, out *CloudControllerManagerConfiguration, s conversion.Scope) error {
 | 
			
		||||
	return autoConvert_config_CloudControllerManagerConfiguration_To_v1alpha1_CloudControllerManagerConfiguration(in, out, s)
 | 
			
		||||
}
 | 
			
		||||
@@ -18,7 +18,7 @@ limitations under the License.
 | 
			
		||||
 | 
			
		||||
// Code generated by deepcopy-gen. DO NOT EDIT.
 | 
			
		||||
 | 
			
		||||
package componentconfig
 | 
			
		||||
package config
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	runtime "k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
@@ -52,66 +52,3 @@ func (in *CloudControllerManagerConfiguration) DeepCopyObject() runtime.Object {
 | 
			
		||||
	}
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
			
		||||
func (in *IPPortVar) DeepCopyInto(out *IPPortVar) {
 | 
			
		||||
	*out = *in
 | 
			
		||||
	if in.Val != nil {
 | 
			
		||||
		in, out := &in.Val, &out.Val
 | 
			
		||||
		*out = new(string)
 | 
			
		||||
		**out = **in
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPPortVar.
 | 
			
		||||
func (in *IPPortVar) DeepCopy() *IPPortVar {
 | 
			
		||||
	if in == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	out := new(IPPortVar)
 | 
			
		||||
	in.DeepCopyInto(out)
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
			
		||||
func (in *IPVar) DeepCopyInto(out *IPVar) {
 | 
			
		||||
	*out = *in
 | 
			
		||||
	if in.Val != nil {
 | 
			
		||||
		in, out := &in.Val, &out.Val
 | 
			
		||||
		*out = new(string)
 | 
			
		||||
		**out = **in
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPVar.
 | 
			
		||||
func (in *IPVar) DeepCopy() *IPVar {
 | 
			
		||||
	if in == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	out := new(IPVar)
 | 
			
		||||
	in.DeepCopyInto(out)
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 | 
			
		||||
func (in *PortRangeVar) DeepCopyInto(out *PortRangeVar) {
 | 
			
		||||
	*out = *in
 | 
			
		||||
	if in.Val != nil {
 | 
			
		||||
		in, out := &in.Val, &out.Val
 | 
			
		||||
		*out = new(string)
 | 
			
		||||
		**out = **in
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortRangeVar.
 | 
			
		||||
func (in *PortRangeVar) DeepCopy() *PortRangeVar {
 | 
			
		||||
	if in == nil {
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	out := new(PortRangeVar)
 | 
			
		||||
	in.DeepCopyInto(out)
 | 
			
		||||
	return out
 | 
			
		||||
}
 | 
			
		||||
@@ -6,7 +6,7 @@ go_library(
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/cloud-controller-manager/app/config",
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config:go_default_library",
 | 
			
		||||
        "//pkg/controller:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apiserver/pkg/server:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/client-go/informers:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -22,13 +22,13 @@ import (
 | 
			
		||||
	clientset "k8s.io/client-go/kubernetes"
 | 
			
		||||
	restclient "k8s.io/client-go/rest"
 | 
			
		||||
	"k8s.io/client-go/tools/record"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	ccmconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Config is the main context object for the cloud controller manager.
 | 
			
		||||
type Config struct {
 | 
			
		||||
	ComponentConfig componentconfig.CloudControllerManagerConfiguration
 | 
			
		||||
	ComponentConfig ccmconfig.CloudControllerManagerConfiguration
 | 
			
		||||
 | 
			
		||||
	SecureServing *apiserver.SecureServingInfo
 | 
			
		||||
	// LoopbackClientConfig is a config for a privileged loopback connection
 | 
			
		||||
 
 | 
			
		||||
@@ -11,17 +11,17 @@ go_library(
 | 
			
		||||
    srcs = ["options.go"],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/cloud-controller-manager/app/options",
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config/scheme:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/apis/config/v1alpha1:go_default_library",
 | 
			
		||||
        "//cmd/cloud-controller-manager/app/config:go_default_library",
 | 
			
		||||
        "//cmd/controller-manager/app/options:go_default_library",
 | 
			
		||||
        "//pkg/api/legacyscheme:go_default_library",
 | 
			
		||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
			
		||||
        "//pkg/apis/componentconfig/v1alpha1:go_default_library",
 | 
			
		||||
        "//pkg/controller:go_default_library",
 | 
			
		||||
        "//pkg/features:go_default_library",
 | 
			
		||||
        "//pkg/master/ports:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/api/core/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apiserver/pkg/server/options:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -22,9 +22,10 @@ import (
 | 
			
		||||
	"net"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
 | 
			
		||||
	"k8s.io/api/core/v1"
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	utilerrors "k8s.io/apimachinery/pkg/util/errors"
 | 
			
		||||
	apiserveroptions "k8s.io/apiserver/pkg/server/options"
 | 
			
		||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
			
		||||
@@ -35,17 +36,16 @@ import (
 | 
			
		||||
	restclient "k8s.io/client-go/rest"
 | 
			
		||||
	"k8s.io/client-go/tools/clientcmd"
 | 
			
		||||
	"k8s.io/client-go/tools/record"
 | 
			
		||||
	ccmconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config"
 | 
			
		||||
	ccmconfigscheme "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/scheme"
 | 
			
		||||
	ccmconfigv1alpha1 "k8s.io/kubernetes/cmd/cloud-controller-manager/app/apis/config/v1alpha1"
 | 
			
		||||
	cloudcontrollerconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/config"
 | 
			
		||||
	cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api/legacyscheme"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	componentconfigv1alpha1 "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/master/ports"
 | 
			
		||||
	// add the kubernetes feature gates
 | 
			
		||||
	_ "k8s.io/kubernetes/pkg/features"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -108,24 +108,13 @@ func NewCloudControllerManagerOptions() (*CloudControllerManagerOptions, error)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// NewDefaultComponentConfig returns cloud-controller manager configuration object.
 | 
			
		||||
func NewDefaultComponentConfig(insecurePort int32) (*componentconfig.CloudControllerManagerConfiguration, error) {
 | 
			
		||||
	// TODO: This code will be fixed up/improved when the ccm API types are moved to their own, real API group out of
 | 
			
		||||
	// pkg/apis/componentconfig to cmd/cloud-controller-manager/app/apis/
 | 
			
		||||
	scheme := runtime.NewScheme()
 | 
			
		||||
	if err := componentconfigv1alpha1.AddToScheme(scheme); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if err := componentconfig.AddToScheme(scheme); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	scheme.AddKnownTypes(componentconfigv1alpha1.SchemeGroupVersion, &componentconfigv1alpha1.CloudControllerManagerConfiguration{})
 | 
			
		||||
	scheme.AddKnownTypes(componentconfig.SchemeGroupVersion, &componentconfig.CloudControllerManagerConfiguration{})
 | 
			
		||||
func NewDefaultComponentConfig(insecurePort int32) (*ccmconfig.CloudControllerManagerConfiguration, error) {
 | 
			
		||||
	versioned := &ccmconfigv1alpha1.CloudControllerManagerConfiguration{}
 | 
			
		||||
	ccmconfigscheme.Scheme.Default(versioned)
 | 
			
		||||
 | 
			
		||||
	versioned := &componentconfigv1alpha1.CloudControllerManagerConfiguration{}
 | 
			
		||||
	internal := &componentconfig.CloudControllerManagerConfiguration{}
 | 
			
		||||
	scheme.Default(versioned)
 | 
			
		||||
	if err := scheme.Convert(versioned, internal, nil); err != nil {
 | 
			
		||||
		return internal, err
 | 
			
		||||
	internal := &ccmconfig.CloudControllerManagerConfiguration{}
 | 
			
		||||
	if err := ccmconfigscheme.Scheme.Convert(versioned, internal, nil); err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	internal.Generic.Port = insecurePort
 | 
			
		||||
	return internal, nil
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ go_library(
 | 
			
		||||
    ],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/kube-proxy/app",
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
			
		||||
        "//pkg/apis/core:go_default_library",
 | 
			
		||||
        "//pkg/kubelet/qos:go_default_library",
 | 
			
		||||
        "//pkg/master/ports:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -50,7 +50,6 @@ import (
 | 
			
		||||
	clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
 | 
			
		||||
	"k8s.io/client-go/tools/record"
 | 
			
		||||
	"k8s.io/kube-proxy/config/v1alpha1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	api "k8s.io/kubernetes/pkg/apis/core"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/kubelet/qos"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/master/ports"
 | 
			
		||||
@@ -131,16 +130,16 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
 | 
			
		||||
 | 
			
		||||
	// All flags below here are deprecated and will eventually be removed.
 | 
			
		||||
 | 
			
		||||
	fs.Var(componentconfig.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(utilflag.IPVar{Val: &o.config.BindAddress}, "bind-address", "The IP address for the proxy server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.StringVar(&o.master, "master", o.master, "The address of the Kubernetes API server (overrides any value in kubeconfig)")
 | 
			
		||||
	fs.Int32Var(&o.healthzPort, "healthz-port", o.healthzPort, "The port to bind the health check server. Use 0 to disable.")
 | 
			
		||||
	fs.Var(componentconfig.IPVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address and port for the health check server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(componentconfig.IPVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address and port for the metrics server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(utilflag.IPVar{Val: &o.config.HealthzBindAddress}, "healthz-bind-address", "The IP address and port for the health check server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(utilflag.IPVar{Val: &o.config.MetricsBindAddress}, "metrics-bind-address", "The IP address and port for the metrics server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Int32Var(o.config.OOMScoreAdj, "oom-score-adj", utilpointer.Int32PtrDerefOr(o.config.OOMScoreAdj, int32(qos.KubeProxyOOMScoreAdj)), "The oom-score-adj value for kube-proxy process. Values must be within the range [-1000, 1000]")
 | 
			
		||||
	fs.StringVar(&o.config.ResourceContainer, "resource-container", o.config.ResourceContainer, "Absolute name of the resource-only container to create and run the Kube-proxy in (Default: /kube-proxy).")
 | 
			
		||||
	fs.MarkDeprecated("resource-container", "This feature will be removed in a later release.")
 | 
			
		||||
	fs.StringVar(&o.config.ClientConnection.Kubeconfig, "kubeconfig", o.config.ClientConnection.Kubeconfig, "Path to kubeconfig file with authorization information (the master location is set by the master flag).")
 | 
			
		||||
	fs.Var(componentconfig.PortRangeVar{Val: &o.config.PortRange}, "proxy-port-range", "Range of host ports (beginPort-endPort, single port or beginPort+offset, inclusive) that may be consumed in order to proxy service traffic. If (unspecified, 0, or 0-0) then ports will be randomly chosen.")
 | 
			
		||||
	fs.Var(utilflag.PortRangeVar{Val: &o.config.PortRange}, "proxy-port-range", "Range of host ports (beginPort-endPort, single port or beginPort+offset, inclusive) that may be consumed in order to proxy service traffic. If (unspecified, 0, or 0-0) then ports will be randomly chosen.")
 | 
			
		||||
	fs.StringVar(&o.config.HostnameOverride, "hostname-override", o.config.HostnameOverride, "If non-empty, will use this string as identification instead of the actual hostname.")
 | 
			
		||||
	fs.Var(&o.config.Mode, "proxy-mode", "Which proxy mode to use: 'userspace' (older) or 'iptables' (faster) or 'ipvs' (experimental). If blank, use the best-available proxy (currently iptables).  If the iptables proxy is selected, regardless of how, but the system's kernel or iptables versions are insufficient, this always falls back to the userspace proxy.")
 | 
			
		||||
	fs.Int32Var(o.config.IPTables.MasqueradeBit, "iptables-masquerade-bit", utilpointer.Int32PtrDerefOr(o.config.IPTables.MasqueradeBit, 14), "If using the pure iptables proxy, the bit of the fwmark space to mark packets requiring SNAT with.  Must be within the range [0, 31].")
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ go_library(
 | 
			
		||||
    ],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/cmd/kubelet/app/options",
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/componentconfig:go_default_library",
 | 
			
		||||
        "//pkg/apis/core:go_default_library",
 | 
			
		||||
        "//pkg/credentialprovider/azure:go_default_library",
 | 
			
		||||
        "//pkg/credentialprovider/gcp:go_default_library",
 | 
			
		||||
@@ -30,6 +29,7 @@ go_library(
 | 
			
		||||
        "//pkg/kubelet/config:go_default_library",
 | 
			
		||||
        "//pkg/kubelet/types:go_default_library",
 | 
			
		||||
        "//pkg/master/ports:go_default_library",
 | 
			
		||||
        "//pkg/util/flag:go_default_library",
 | 
			
		||||
        "//pkg/util/taints:go_default_library",
 | 
			
		||||
        "//pkg/version/verflag:go_default_library",
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,6 @@ import (
 | 
			
		||||
	utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
			
		||||
	"k8s.io/apiserver/pkg/util/flag"
 | 
			
		||||
	"k8s.io/kubelet/config/v1beta1"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/componentconfig"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/core"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/features"
 | 
			
		||||
	kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
 | 
			
		||||
@@ -39,6 +38,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/kubelet/config"
 | 
			
		||||
	kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/master/ports"
 | 
			
		||||
	utilflag "k8s.io/kubernetes/pkg/util/flag"
 | 
			
		||||
	utiltaints "k8s.io/kubernetes/pkg/util/taints"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -447,7 +447,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
 | 
			
		||||
	fs.DurationVar(&c.HTTPCheckFrequency.Duration, "http-check-frequency", c.HTTPCheckFrequency.Duration, "Duration between checking http for new data")
 | 
			
		||||
	fs.StringVar(&c.StaticPodURL, "manifest-url", c.StaticPodURL, "URL for accessing additional Pod specifications to run")
 | 
			
		||||
	fs.Var(flag.NewColonSeparatedMultimapStringString(&c.StaticPodURLHeader), "manifest-url-header", "Comma-separated list of HTTP headers to use when accessing the url provided to --manifest-url. Multiple headers with the same name will be added in the same order provided. This flag can be repeatedly invoked. For example: `--manifest-url-header 'a:hello,b:again,c:world' --manifest-url-header 'b:beautiful'`")
 | 
			
		||||
	fs.Var(componentconfig.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(utilflag.IPVar{Val: &c.Address}, "address", "The IP address for the Kubelet to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Int32Var(&c.Port, "port", c.Port, "The port for the Kubelet to serve on.")
 | 
			
		||||
	fs.Int32Var(&c.ReadOnlyPort, "read-only-port", c.ReadOnlyPort, "The read-only port for the Kubelet to serve on with no authentication/authorization (set to 0 to disable)")
 | 
			
		||||
 | 
			
		||||
@@ -499,7 +499,7 @@ func AddKubeletConfigFlags(mainfs *pflag.FlagSet, c *kubeletconfig.KubeletConfig
 | 
			
		||||
	fs.BoolVar(&c.EnableDebuggingHandlers, "enable-debugging-handlers", c.EnableDebuggingHandlers, "Enables server endpoints for log collection and local running of containers and commands")
 | 
			
		||||
	fs.BoolVar(&c.EnableContentionProfiling, "contention-profiling", c.EnableContentionProfiling, "Enable lock contention profiling, if profiling is enabled")
 | 
			
		||||
	fs.Int32Var(&c.HealthzPort, "healthz-port", c.HealthzPort, "The port of the localhost healthz endpoint (set to 0 to disable)")
 | 
			
		||||
	fs.Var(componentconfig.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Var(utilflag.IPVar{Val: &c.HealthzBindAddress}, "healthz-bind-address", "The IP address for the healthz server to serve on (set to `0.0.0.0` for all IPv4 interfaces and `::` for all IPv6 interfaces)")
 | 
			
		||||
	fs.Int32Var(&c.OOMScoreAdj, "oom-score-adj", c.OOMScoreAdj, "The oom-score-adj value for kubelet process. Values must be within the range [-1000, 1000]")
 | 
			
		||||
	fs.StringVar(&c.ClusterDomain, "cluster-domain", c.ClusterDomain, "Domain for this cluster.  If set, kubelet will configure all containers to search this domain in addition to the host's search domains")
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
 | 
			
		||||
cluster/images/etcd-version-monitor
 | 
			
		||||
cmd/cloud-controller-manager/app/apis/config/v1alpha1
 | 
			
		||||
cmd/hyperkube
 | 
			
		||||
cmd/kube-apiserver/app
 | 
			
		||||
cmd/kube-controller-manager/app
 | 
			
		||||
@@ -55,8 +56,6 @@ pkg/apis/batch/validation
 | 
			
		||||
pkg/apis/certificates
 | 
			
		||||
pkg/apis/certificates/v1beta1
 | 
			
		||||
pkg/apis/certificates/validation
 | 
			
		||||
pkg/apis/componentconfig
 | 
			
		||||
pkg/apis/componentconfig/v1alpha1
 | 
			
		||||
pkg/apis/coordination
 | 
			
		||||
pkg/apis/coordination/v1beta1
 | 
			
		||||
pkg/apis/core
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,6 @@ filegroup(
 | 
			
		||||
        "//pkg/apis/autoscaling:all-srcs",
 | 
			
		||||
        "//pkg/apis/batch:all-srcs",
 | 
			
		||||
        "//pkg/apis/certificates:all-srcs",
 | 
			
		||||
        "//pkg/apis/componentconfig:all-srcs",
 | 
			
		||||
        "//pkg/apis/coordination:all-srcs",
 | 
			
		||||
        "//pkg/apis/core:all-srcs",
 | 
			
		||||
        "//pkg/apis/events:all-srcs",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +0,0 @@
 | 
			
		||||
approvers:
 | 
			
		||||
 - api-approvers
 | 
			
		||||
 - mikedanese
 | 
			
		||||
 - vishh
 | 
			
		||||
 - mtaufen
 | 
			
		||||
 - luxas
 | 
			
		||||
 - sttts
 | 
			
		||||
reviewers:
 | 
			
		||||
 - api-reviewers
 | 
			
		||||
 - thockin
 | 
			
		||||
 - lavalamp
 | 
			
		||||
 - smarterclayton
 | 
			
		||||
 - wojtek-t
 | 
			
		||||
 - deads2k
 | 
			
		||||
 - vishh
 | 
			
		||||
 - mikedanese
 | 
			
		||||
 - liggitt
 | 
			
		||||
 - luxas
 | 
			
		||||
@@ -1,26 +0,0 @@
 | 
			
		||||
package(default_visibility = ["//visibility:public"])
 | 
			
		||||
 | 
			
		||||
load(
 | 
			
		||||
    "@io_bazel_rules_go//go:def.bzl",
 | 
			
		||||
    "go_library",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_library(
 | 
			
		||||
    name = "go_default_library",
 | 
			
		||||
    srcs = ["fuzzer.go"],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/pkg/apis/componentconfig/fuzzer",
 | 
			
		||||
    deps = ["//staging/src/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "package-srcs",
 | 
			
		||||
    srcs = glob(["**"]),
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [":package-srcs"],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
)
 | 
			
		||||
@@ -1,29 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2017 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package fuzzer
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Funcs returns the fuzzer functions for the componentconfig api group.
 | 
			
		||||
// TODO: When the componentconfig types are split out to individual API groups
 | 
			
		||||
// we should re-enable the fuzzing and defaulting unit tests. Also add a
 | 
			
		||||
// TestTypeTags-kind of unit test like in `pkg/master`
 | 
			
		||||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
 | 
			
		||||
	return []interface{}{}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,157 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package componentconfig
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
	"k8s.io/api/core/v1"
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	utilnet "k8s.io/apimachinery/pkg/util/net"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// used for validating command line opts
 | 
			
		||||
// TODO(mikedanese): remove these when we remove command line flags
 | 
			
		||||
 | 
			
		||||
type IPVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPVar) Set(s string) error {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		v.Val = nil
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	if net.ParseIP(s) == nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid IP address", s)
 | 
			
		||||
	}
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into IPVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPVar) Type() string {
 | 
			
		||||
	return "ip"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPPortVar allows IP or IP:port formats.
 | 
			
		||||
type IPPortVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPPortVar) Set(s string) error {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		v.Val = nil
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into IPPortVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Both IP and IP:port are valid.
 | 
			
		||||
	// Attempt to parse into IP first.
 | 
			
		||||
	if net.ParseIP(s) != nil {
 | 
			
		||||
		*v.Val = s
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Can not parse into IP, now assume IP:port.
 | 
			
		||||
	host, port, err := net.SplitHostPort(s)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not in a valid format (ip or ip:port): %v", s, err)
 | 
			
		||||
	}
 | 
			
		||||
	if net.ParseIP(host) == nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid IP address", host)
 | 
			
		||||
	}
 | 
			
		||||
	if _, err := strconv.Atoi(port); err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid number", port)
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPPortVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v IPPortVar) Type() string {
 | 
			
		||||
	return "ipport"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type PortRangeVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v PortRangeVar) Set(s string) error {
 | 
			
		||||
	if _, err := utilnet.ParsePortRange(s); err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid port range: %v", s, err)
 | 
			
		||||
	}
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into PortRangeVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v PortRangeVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (v PortRangeVar) Type() string {
 | 
			
		||||
	return "port-range"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ConvertObjToConfigMap converts an object to a ConfigMap.
 | 
			
		||||
// This is specifically meant for ComponentConfigs.
 | 
			
		||||
func ConvertObjToConfigMap(name string, obj runtime.Object) (*v1.ConfigMap, error) {
 | 
			
		||||
	eJSONBytes, err := json.Marshal(obj)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	cm := &v1.ConfigMap{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
			Name: name,
 | 
			
		||||
		},
 | 
			
		||||
		Data: map[string]string{
 | 
			
		||||
			name: string(eJSONBytes[:]),
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	return cm, nil
 | 
			
		||||
}
 | 
			
		||||
@@ -1,14 +0,0 @@
 | 
			
		||||
package(default_visibility = ["//visibility:public"])
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "package-srcs",
 | 
			
		||||
    srcs = glob(["**"]),
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
filegroup(
 | 
			
		||||
    name = "all-srcs",
 | 
			
		||||
    srcs = [":package-srcs"],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
)
 | 
			
		||||
@@ -11,9 +11,9 @@ openapi_library(
 | 
			
		||||
    srcs = ["doc.go"],
 | 
			
		||||
    go_prefix = openapi_go_prefix,
 | 
			
		||||
    openapi_targets = [
 | 
			
		||||
        "cmd/cloud-controller-manager/app/apis/config/v1alpha1",
 | 
			
		||||
        "pkg/apis/abac/v0",
 | 
			
		||||
        "pkg/apis/abac/v1beta1",
 | 
			
		||||
        "pkg/apis/componentconfig/v1alpha1",
 | 
			
		||||
        "pkg/version",
 | 
			
		||||
    ],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package(default_visibility = ["//visibility:public"])
 | 
			
		||||
load(
 | 
			
		||||
    "@io_bazel_rules_go//go:def.bzl",
 | 
			
		||||
    "go_library",
 | 
			
		||||
    "go_test",
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_library(
 | 
			
		||||
@@ -10,6 +11,7 @@ go_library(
 | 
			
		||||
    srcs = ["flags.go"],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/pkg/util/flag",
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library",
 | 
			
		||||
        "//vendor/github.com/golang/glog:go_default_library",
 | 
			
		||||
        "//vendor/github.com/spf13/pflag:go_default_library",
 | 
			
		||||
    ],
 | 
			
		||||
@@ -27,3 +29,10 @@ filegroup(
 | 
			
		||||
    srcs = [":package-srcs"],
 | 
			
		||||
    tags = ["automanaged"],
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
go_test(
 | 
			
		||||
    name = "go_default_test",
 | 
			
		||||
    srcs = ["flags_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
 | 
			
		||||
)
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,14 @@ limitations under the License.
 | 
			
		||||
package flag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"net"
 | 
			
		||||
	"strconv"
 | 
			
		||||
 | 
			
		||||
	"github.com/golang/glog"
 | 
			
		||||
	"github.com/spf13/pflag"
 | 
			
		||||
 | 
			
		||||
	utilnet "k8s.io/apimachinery/pkg/util/net"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// PrintFlags logs the flags in the flagset
 | 
			
		||||
@@ -27,3 +33,129 @@ func PrintFlags(flags *pflag.FlagSet) {
 | 
			
		||||
		glog.V(1).Infof("FLAG: --%s=%q", flag.Name, flag.Value)
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO(mikedanese): remove these flag wrapper types when we remove command line flags
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	_ pflag.Value = &IPVar{}
 | 
			
		||||
	_ pflag.Value = &IPPortVar{}
 | 
			
		||||
	_ pflag.Value = &PortRangeVar{}
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// IPVar is used for validating a command line option that represents an IP. It implements the pflag.Value interface
 | 
			
		||||
type IPVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set sets the flag value
 | 
			
		||||
func (v IPVar) Set(s string) error {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		v.Val = nil
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
	if net.ParseIP(s) == nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid IP address", s)
 | 
			
		||||
	}
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into IPVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String returns the flag value
 | 
			
		||||
func (v IPVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type gets the flag type
 | 
			
		||||
func (v IPVar) Type() string {
 | 
			
		||||
	return "ip"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IPPortVar is used for validating a command line option that represents an IP and a port. It implements the pflag.Value interface
 | 
			
		||||
type IPPortVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set sets the flag value
 | 
			
		||||
func (v IPPortVar) Set(s string) error {
 | 
			
		||||
	if len(s) == 0 {
 | 
			
		||||
		v.Val = nil
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into IPPortVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Both IP and IP:port are valid.
 | 
			
		||||
	// Attempt to parse into IP first.
 | 
			
		||||
	if net.ParseIP(s) != nil {
 | 
			
		||||
		*v.Val = s
 | 
			
		||||
		return nil
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Can not parse into IP, now assume IP:port.
 | 
			
		||||
	host, port, err := net.SplitHostPort(s)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not in a valid format (ip or ip:port): %v", s, err)
 | 
			
		||||
	}
 | 
			
		||||
	if net.ParseIP(host) == nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid IP address", host)
 | 
			
		||||
	}
 | 
			
		||||
	if _, err := strconv.Atoi(port); err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid number", port)
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String returns the flag value
 | 
			
		||||
func (v IPPortVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type gets the flag type
 | 
			
		||||
func (v IPPortVar) Type() string {
 | 
			
		||||
	return "ipport"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// PortRangeVar is used for validating a command line option that represents a port range. It implements the pflag.Value interface
 | 
			
		||||
type PortRangeVar struct {
 | 
			
		||||
	Val *string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Set sets the flag value
 | 
			
		||||
func (v PortRangeVar) Set(s string) error {
 | 
			
		||||
	if _, err := utilnet.ParsePortRange(s); err != nil {
 | 
			
		||||
		return fmt.Errorf("%q is not a valid port range: %v", s, err)
 | 
			
		||||
	}
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		// it's okay to panic here since this is programmer error
 | 
			
		||||
		panic("the string pointer passed into PortRangeVar should not be nil")
 | 
			
		||||
	}
 | 
			
		||||
	*v.Val = s
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// String returns the flag value
 | 
			
		||||
func (v PortRangeVar) String() string {
 | 
			
		||||
	if v.Val == nil {
 | 
			
		||||
		return ""
 | 
			
		||||
	}
 | 
			
		||||
	return *v.Val
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Type gets the flag type
 | 
			
		||||
func (v PortRangeVar) Type() string {
 | 
			
		||||
	return "port-range"
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package componentconfig
 | 
			
		||||
package flag
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"strings"
 | 
			
		||||
@@ -113,10 +113,6 @@ var kindWhiteList = sets.NewString(
 | 
			
		||||
	"Eviction",
 | 
			
		||||
	// --
 | 
			
		||||
 | 
			
		||||
	// k8s.io/kubernetes/pkg/apis/componentconfig
 | 
			
		||||
	"KubeSchedulerConfiguration",
 | 
			
		||||
	// --
 | 
			
		||||
 | 
			
		||||
	// k8s.io/apimachinery/pkg/apis/meta
 | 
			
		||||
	"WatchEvent",
 | 
			
		||||
	"Status",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user