Skip to content

Commit

Permalink
Merge pull request #34587 from resouer/stringflag
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue

Merge string flag into util flag

Continuing my work on #15634

This refactoring is expected to be completely finished and then I will add a verify scripts in `hack`
  • Loading branch information
Kubernetes Submit Queue authored Oct 14, 2016
2 parents 9e3636a + eb81ef6 commit 9adbbf2
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
8 changes: 4 additions & 4 deletions cmd/kubelet/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/componentconfig"
"k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1"
"k8s.io/kubernetes/pkg/util"
utilconfig "k8s.io/kubernetes/pkg/util/config"
"k8s.io/kubernetes/pkg/util/flag"

"github.com/spf13/pflag"
)
Expand All @@ -41,12 +41,12 @@ const (
type KubeletServer struct {
componentconfig.KubeletConfiguration

KubeConfig util.StringFlag
KubeConfig flag.StringFlag
BootstrapKubeconfig string

// If true, an invalid KubeConfig will result in the Kubelet exiting with an error.
RequireKubeConfig bool
AuthPath util.StringFlag // Deprecated -- use KubeConfig instead
AuthPath flag.StringFlag // Deprecated -- use KubeConfig instead
APIServerList []string // Deprecated -- use KubeConfig instead

// Insert a probability of random errors during calls to the master.
Expand All @@ -67,7 +67,7 @@ func NewKubeletServer() *KubeletServer {
config := componentconfig.KubeletConfiguration{}
api.Scheme.Convert(&v1alpha1.KubeletConfiguration{}, &config, nil)
return &KubeletServer{
KubeConfig: util.NewStringFlag("/var/lib/kubelet/kubeconfig"),
KubeConfig: flag.NewStringFlag("/var/lib/kubelet/kubeconfig"),
RequireKubeConfig: false, // in 1.5, default to true
KubeletConfiguration: config,
}
Expand Down
15 changes: 7 additions & 8 deletions pkg/kubectl/cmd/config/create_authinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,20 @@ import (
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
)

type createAuthInfoOptions struct {
configAccess clientcmd.ConfigAccess
name string
authPath util.StringFlag
clientCertificate util.StringFlag
clientKey util.StringFlag
token util.StringFlag
username util.StringFlag
password util.StringFlag
authPath flag.StringFlag
clientCertificate flag.StringFlag
clientKey flag.StringFlag
token flag.StringFlag
username flag.StringFlag
password flag.StringFlag
embedCertData flag.Tristate
authProvider util.StringFlag
authProvider flag.StringFlag

authProviderArgs map[string]string
authProviderArgsToRemove []string
Expand Down
6 changes: 3 additions & 3 deletions pkg/kubectl/cmd/config/create_authinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"reflect"
"testing"

"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
)

func stringFlagFor(s string) util.StringFlag {
var f util.StringFlag
func stringFlagFor(s string) flag.StringFlag {
var f flag.StringFlag
f.Set(s)
return f
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/kubectl/cmd/config/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ import (

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
)

type createClusterOptions struct {
configAccess clientcmd.ConfigAccess
name string
server util.StringFlag
apiVersion util.StringFlag
server flag.StringFlag
apiVersion flag.StringFlag
insecureSkipTLSVerify flag.Tristate
certificateAuthority util.StringFlag
certificateAuthority flag.StringFlag
embedCAData flag.Tristate
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/kubectl/cmd/config/create_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import (

"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
clientcmdapi "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/flag"
)

type createContextOptions struct {
configAccess clientcmd.ConfigAccess
name string
cluster util.StringFlag
authInfo util.StringFlag
namespace util.StringFlag
cluster flag.StringFlag
authInfo flag.StringFlag
namespace flag.StringFlag
}

var (
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/string_flag.go → pkg/util/flag/string_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package flag

// StringFlag is a string flag compatible with flags and pflags that keeps track of whether it had a value supplied or not.
type StringFlag struct {
Expand Down

0 comments on commit 9adbbf2

Please sign in to comment.