Skip to content

Commit

Permalink
align the log level and add more info to log
Browse files Browse the repository at this point in the history
  • Loading branch information
weinong committed May 3, 2023
1 parent 77c5abf commit b8af9c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/converter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ func Convert(o Options, pathOptions *clientcmd.PathOptions) error {
clientConfig := o.configFlags.ToRawKubeConfigLoader()
var kubeconfigs []string

klog.V(5).Info(o.ToString())

if clientConfig.ConfigAccess() != nil {
if clientConfig.ConfigAccess().GetExplicitFile() != "" {
kubeconfigs = append(kubeconfigs, clientConfig.ConfigAccess().GetExplicitFile())
Expand All @@ -160,7 +162,7 @@ func Convert(o Options, pathOptions *clientcmd.PathOptions) error {
}
}

klog.V(7).Infof("Loading kubeconfig from %s", strings.Join(kubeconfigs, ":"))
klog.V(5).Infof("Loading kubeconfig from %s", strings.Join(kubeconfigs, ":"))

config, err := clientConfig.RawConfig()
if err != nil {
Expand All @@ -182,14 +184,14 @@ func Convert(o Options, pathOptions *clientcmd.PathOptions) error {
continue
}

klog.V(7).Infof("context: %q", name)
klog.V(5).Infof("context: %q", name)

// is it legacy aad auth or is it exec using kubelogin?
if !isExecUsingkubelogin(authInfo) && !isLegacyAzureAuth(authInfo) {
continue
}

klog.V(7).Info("converting...")
klog.V(5).Info("converting...")

argServerIDVal, argClientIDVal, argEnvironmentVal, argTenantIDVal, argTokenCacheDirVal, isLegacyConfigMode := getArgValues(o, authInfo)
exec := &api.ExecConfig{
Expand Down
6 changes: 6 additions & 0 deletions pkg/converter/options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package converter

import (
"fmt"

"github.com/Azure/kubelogin/pkg/token"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
Expand Down Expand Up @@ -42,6 +44,10 @@ func (o *Options) UpdateFromEnv() {
o.TokenOptions.UpdateFromEnv()
}

func (o *Options) ToString() string {
return fmt.Sprintf("Context: %s, %s", o.context, o.TokenOptions.ToString())
}

func (o *Options) isSet(name string) bool {
found := false
o.Flags.Visit(func(f *pflag.Flag) {
Expand Down

0 comments on commit b8af9c5

Please sign in to comment.