mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +00:00
943c3a1929
* use failurePolicy to block or allow requests, on policy errors Signed-off-by: Jim Bugwadia <jim@nirmata.com> * add warnings Signed-off-by: Jim Bugwadia <jim@nirmata.com> * codegen Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix linter issues Signed-off-by: Jim Bugwadia <jim@nirmata.com> * add unit tests Signed-off-by: Jim Bugwadia <jim@nirmata.com> * handle network errors Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix linter issues Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix test Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix title conversion Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix path in generated file Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix test Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix fake metrics Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix tests Signed-off-by: Jim Bugwadia <jim@nirmata.com> * add check for klog flag initialization Signed-off-by: Jim Bugwadia <jim@nirmata.com> * check for flag reinitialization Signed-off-by: Jim Bugwadia <jim@nirmata.com> * check for flag reinitialization Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix spelling Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix flag init Signed-off-by: Jim Bugwadia <jim@nirmata.com>
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/apply"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/jp"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/test"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/version"
|
|
"github.com/spf13/cobra"
|
|
"k8s.io/klog/v2"
|
|
"k8s.io/klog/v2/klogr"
|
|
log "sigs.k8s.io/controller-runtime/pkg/log"
|
|
)
|
|
|
|
// CLI ...
|
|
func main() {
|
|
cli := &cobra.Command{
|
|
Use: "kyverno",
|
|
Short: "Kubernetes Native Policy Management",
|
|
}
|
|
|
|
configurelog(cli)
|
|
|
|
commands := []*cobra.Command{
|
|
version.Command(),
|
|
apply.Command(),
|
|
test.Command(),
|
|
jp.Command(),
|
|
}
|
|
|
|
cli.AddCommand(commands...)
|
|
|
|
if err := cli.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func configurelog(cli *cobra.Command) {
|
|
// clear flags initialized in static dependencies
|
|
if flag.CommandLine.Lookup("log_dir") != nil {
|
|
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
|
|
}
|
|
|
|
klog.InitFlags(nil)
|
|
cli.PersistentFlags().AddGoFlagSet(flag.CommandLine)
|
|
log.SetLogger(klogr.New())
|
|
|
|
_ = cli.PersistentFlags().MarkHidden("alsologtostderr")
|
|
_ = cli.PersistentFlags().MarkHidden("logtostderr")
|
|
_ = cli.PersistentFlags().MarkHidden("log_dir")
|
|
_ = cli.PersistentFlags().MarkHidden("log_backtrace_at")
|
|
_ = cli.PersistentFlags().MarkHidden("stderrthreshold")
|
|
_ = cli.PersistentFlags().MarkHidden("vmodule")
|
|
}
|