Merge pull request #5813 from adamreese/ref/klog

ref(*): expose klog flags
pull/5815/head
Adam Reese 6 years ago committed by GitHub
commit 2a3b7b5395
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

2
Gopkg.lock generated

@ -1710,7 +1710,7 @@
"k8s.io/client-go/tools/clientcmd",
"k8s.io/client-go/tools/watch",
"k8s.io/client-go/util/homedir",
"k8s.io/kubernetes/pkg/api/legacyscheme",
"k8s.io/klog",
"k8s.io/kubernetes/pkg/controller/deployment/util",
"k8s.io/kubernetes/pkg/kubectl/cmd/testing",
"k8s.io/kubernetes/pkg/kubectl/cmd/util",

@ -17,13 +17,18 @@ limitations under the License.
package main // import "helm.sh/helm/cmd/helm"
import (
"flag"
"fmt"
"log"
"os"
"strings"
"sync"
// Import to initialize client auth plugins.
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog"
// Import to initialize client auth plugins.
_ "k8s.io/client-go/plugin/pkg/client/auth"
"helm.sh/helm/pkg/action"
@ -50,7 +55,16 @@ func logf(format string, v ...interface{}) {
}
}
func initKubeLogs() {
pflag.CommandLine.SetNormalizeFunc(wordSepNormalizeFunc)
gofs := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(gofs)
pflag.CommandLine.AddGoFlagSet(gofs)
pflag.CommandLine.Set("logtostderr", "true")
}
func main() {
initKubeLogs()
cmd := newRootCmd(newActionConfig(false), os.Stdout, os.Args[1:])
if err := cmd.Execute(); err != nil {
logf("%+v", err)
@ -111,3 +125,8 @@ func getNamespace() string {
}
return "default"
}
// wordSepNormalizeFunc changes all flags that contain "_" separators
func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(strings.ReplaceAll(name, "_", "-"))
}

@ -56,7 +56,7 @@ func newRollbackCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
}
f := cmd.Flags()
f.IntVarP(&client.Version, "version", "v", 0, "revision number to rollback to (default: rollback to previous release)")
f.IntVar(&client.Version, "version", 0, "revision number to rollback to (default: rollback to previous release)")
f.BoolVar(&client.DryRun, "dry-run", false, "simulate a rollback")
f.BoolVar(&client.Recreate, "recreate-pods", false, "performs pods restart for the resource if applicable")
f.BoolVar(&client.Force, "force", false, "force resource update through delete/recreate if needed")

@ -65,7 +65,7 @@ func newSearchCmd(out io.Writer) *cobra.Command {
f := cmd.Flags()
f.BoolVarP(&o.regexp, "regexp", "r", false, "use regular expressions for searching")
f.BoolVarP(&o.versions, "versions", "l", false, "show the long listing, with each version of each chart on its own line")
f.StringVarP(&o.version, "version", "v", "", "search using semantic versioning constraints")
f.StringVar(&o.version, "version", "", "search using semantic versioning constraints")
return cmd
}

@ -1,30 +0,0 @@
/*
Copyright The Helm 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 kube
import (
"flag"
"fmt"
"os"
)
func init() {
if level := os.Getenv("KUBE_LOG_LEVEL"); level != "" {
flag.Set("vmodule", fmt.Sprintf("loader=%[1]s,round_trippers=%[1]s,request=%[1]s", level))
flag.Set("logtostderr", "true")
}
}
Loading…
Cancel
Save