cmd

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SentryOverrides = []SentryOverride{
	{
		EnvVar: "OUTOUT_AUTHORIZATION",
		Flag:   authorizationFlag,
		FlagHelper: func(cmd *cobra.Command) {
			cmd.Flags().String(authorizationFlag, "", `event ingester authorization secret (env: OUTPUT_AUTHORIZATION). If set, overrides the secret in the config file, and adds the secret to all Xatu outputs.`)
		},
		Setter: func(cmd *cobra.Command, overrides *sentry.Override) error {
			val := ""

			if cmd.Flags().Changed(authorizationFlag) {
				val = cmd.Flags().Lookup(authorizationFlag).Value.String()
			}

			if os.Getenv("AUTHORIZATION") != "" {
				val = os.Getenv("AUTHORIZATION")
			}

			if val == "" {
				return nil
			}

			overrides.XatuOutputAuth.Enabled = true
			overrides.XatuOutputAuth.Value = val

			return nil
		},
	},
	{
		EnvVar: "PRESET",
		Flag:   "preset",
		FlagHelper: func(cmd *cobra.Command) {
			cmd.Flags().String(presetFlag, "", `configuration preset (env: PRESET). If set, overrides the configuration preset in the config file. See README.md for more information.`)
		},
		Setter: func(cmd *cobra.Command, overrides *sentry.Override) error {
			val := ""

			if cmd.Flags().Changed(presetFlag) {
				val = cmd.Flags().Lookup(presetFlag).Value.String()
			}

			if os.Getenv("PRESET") != "" {
				val = os.Getenv("PRESET")
			}

			if val == "" {
				return nil
			}

			overrides.Preset.Enabled = true
			overrides.Preset.Value = val

			return nil
		},
	},
	{
		EnvVar: "BEACON_NODE_URL",
		Flag:   "beacon-node-url",
		FlagHelper: func(cmd *cobra.Command) {
			cmd.Flags().String(beaconNodeURLFlag, "", `beacon node URL (env: BEACON_NODE_URL). If set, overrides the beacon node URL in the config file.`)
		},
		Setter: func(cmd *cobra.Command, overrides *sentry.Override) error {
			val := ""

			if cmd.Flags().Changed(beaconNodeURLFlag) {
				val = cmd.Flags().Lookup(beaconNodeURLFlag).Value.String()
			}

			if os.Getenv("BEACON_NODE_URL") != "" {
				val = os.Getenv("BEACON_NODE_URL")
			}

			if val == "" {
				return nil
			}

			overrides.BeaconNodeURL.Enabled = true
			overrides.BeaconNodeURL.Value = val

			return nil
		},
	},
}

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.

Types

type SentryOverride added in v0.0.200

type SentryOverride struct {
	EnvVar     string
	Flag       string
	FlagHelper func(cmd *cobra.Command)
	Setter     func(cmd *cobra.Command, overrides *sentry.Override) error
}

Jump to

Keyboard shortcuts

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