mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
dc71610df7
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
39 lines
812 B
Go
39 lines
812 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/experimental"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/log"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func main() {
|
|
cmd, err := setup()
|
|
if err != nil {
|
|
fmt.Println("Error:", err)
|
|
os.Exit(1)
|
|
}
|
|
if err := cmd.Execute(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func setup() (*cobra.Command, error) {
|
|
cmd := commands.RootCommand(experimental.IsEnabled())
|
|
if err := configureLogs(cmd); err != nil {
|
|
return nil, fmt.Errorf("Failed to setup logging (%w)", err)
|
|
}
|
|
return cmd, nil
|
|
}
|
|
|
|
func configureLogs(cli *cobra.Command) error {
|
|
if err := log.Configure(); err != nil {
|
|
return err
|
|
}
|
|
cli.PersistentFlags().AddGoFlagSet(flag.CommandLine)
|
|
return nil
|
|
}
|