cmd

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: MPL-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ControllerCmd = &cobra.Command{
	Use:   "controller",
	Short: "Start the VCS Webhook handler.",
	Long:  ``,
	Run: func(cmd *cobra.Command, args []string) {
		ctx := context.Background()

		log.Info().
			Str("git-tag", pkg.GitTag).
			Str("git-commit", pkg.GitCommit).
			Msg("Starting KubeChecks")

		log.Info().Msg("parsing configuration")
		cfg, err := config.New()
		if err != nil {
			log.Fatal().Err(err).Msg("failed to parse configuration")
		}

		ctr, err := newContainer(ctx, cfg, true)
		if err != nil {
			log.Fatal().Err(err).Msg("failed to create container")
		}

		log.Info().Msg("initializing git settings")
		if err = initializeGit(ctr); err != nil {
			log.Fatal().Err(err).Msg("failed to initialize git settings")
		}

		if err = processLocations(ctx, ctr, cfg.PoliciesLocation); err != nil {
			log.Fatal().Err(err).Msg("failed to process policy locations")
		}
		if err = processLocations(ctx, ctr, cfg.SchemasLocations); err != nil {
			log.Fatal().Err(err).Msg("failed to process schema locations")
		}

		processors, err := getProcessors(ctr)
		if err != nil {
			log.Fatal().Err(err).Msg("failed to create processors")
		}

		t, err := initTelemetry(ctx, cfg)
		if err != nil {
			log.Panic().Err(err).Msg("Failed to initialize telemetry")
		}
		defer t.Shutdown()

		log.Info().Msgf("starting web server")
		startWebserver(ctx, ctr, processors)

		log.Info().Msgf("listening for requests")
		waitForShutdown()

		log.Info().Msg("shutting down gracefully")
		waitForPendingRequest()
	},
}

ControllerCmd represents the run command

View Source
var ErrCannotUseQueryWithFilePath = errors.New("relative and absolute file paths cannot have query parameters")
View Source
var RootCmd = &cobra.Command{
	Use:              "kubechecks",
	Short:            "Argo Git Hooks",
	Long:             `A Kubernetes controller and webhook server for integration of ArgoCD applications into CI`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {},
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ViperNameToEnv added in v1.0.8

func ViperNameToEnv(s string) string

Types

type DocOpt added in v1.0.8

type DocOpt[D any] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL