1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/cmd/cli/kubectl-kyverno/main.go

39 lines
759 B
Go
Raw Normal View History

2020-03-06 03:00:18 +05:30
package main
import (
"flag"
"fmt"
"os"
2020-03-06 03:00:18 +05:30
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands"
"github.com/kyverno/kyverno/pkg/logging"
"github.com/spf13/cobra"
)
2020-03-06 03:00:18 +05:30
func main() {
if err := run(); err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}
}
func run() error {
cmd := commands.RootCommand()
if err := configureLogs(cmd); err != nil {
return fmt.Errorf("Failed to setup logging (%w)", err)
}
if err := cmd.Execute(); err != nil {
return fmt.Errorf("Failed to execute command (%w)", err)
}
return nil
}
func configureLogs(cli *cobra.Command) error {
logging.InitFlags(nil)
if err := logging.Setup(logging.TextFormat, 0); err != nil {
return err
}
cli.PersistentFlags().AddGoFlagSet(flag.CommandLine)
return nil
}