options

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequiredAnnotation = "eiam_required_flag"
)

Flag annotation strings.

Variables

View Source
var (
	// FormatFlag controls the output format for a command.
	FormatFlag = flagName{"format", "f"}

	// ProjectFlag sets the GCP project to use for a command.
	ProjectFlag = flagName{"project", "p"}

	// ReasonFlag enforces that a rationale be given for a command.
	ReasonFlag = flagName{"reason", "R"}

	// RegionFlag sets the GCP region to use for a command.
	RegionFlag = flagName{"region", "r"}

	// ServiceAccountEmailFlag sets the service account to use for a command.
	ServiceAccountEmailFlag = flagName{"service-account-email", "s"}

	// YesFlag is a boolean that when set to true ignores non-required user prompts.
	YesFlag = flagName{"yes", "y"}

	// ZoneFlag sets the GCP zone to use for a command.
	ZoneFlag = flagName{"zone", "z"}

	// TokenDurationFlag sets the token duration for a command.
	TokenDurationFlag = flagName{"duration", "d"}
)

Flag names and shorthands.

View Source
var (
	// ComputeInstanceFlag sets the compute instance to use for a command.
	ComputeInstanceFlag = flagName{"instance", "i"}

	// PubSubTopicFlag sets the Pub/Sub topic to use for a command.
	PubSubTopicFlag = flagName{"topic", "t"}

	// StorageBucketFlag sets the GCS bucket to use for a command.
	StorageBucketFlag = flagName{"bucket", "b"}
)

Flag names and shorthands.

View Source
var (
	YesOption = false
)

YesOption designates whether to prompt for confirmation or not.

Functions

func AddComputeInstanceFlag

func AddComputeInstanceFlag(fs *pflag.FlagSet, instance *string, required bool)

AddComputeInstanceFlag adds the --instance/-i flag to the command.

func AddPersistentFlags

func AddPersistentFlags(fs *pflag.FlagSet)

AddPersistentFlags add persistent flags to the root command.

func AddProjectFlag

func AddProjectFlag(fs *pflag.FlagSet, project *string, required bool)

AddProjectFlag adds the --project/-p flag to the command.

func AddPubSubTopicFlag

func AddPubSubTopicFlag(fs *pflag.FlagSet, topic *string, required bool)

AddPubSubTopicFlag adds the --topic/-t flag to the command.

func AddReasonFlag

func AddReasonFlag(fs *pflag.FlagSet, reason *string, required bool)

AddReasonFlag adds the --reason/-R flag.

func AddRegionFlag

func AddRegionFlag(fs *pflag.FlagSet, region *string, required bool)

AddRegionFlag adds the --region/-r flag to the command.

func AddServiceAccountEmailFlag

func AddServiceAccountEmailFlag(fs *pflag.FlagSet, serviceAccountEmail *string, required bool)

AddServiceAccountEmailFlag adds the --service-account-email/-s flag.

func AddStorageBucketFlag

func AddStorageBucketFlag(fs *pflag.FlagSet, bucket *string, required bool)

AddStorageBucketFlag adds the --bucket/-b flag to the command.

func AddTokenDurationFlag added in v0.0.22

func AddTokenDurationFlag(fs *pflag.FlagSet, tokenDuration *time.Duration, required bool)

AddTokenDurationFlag adds the --duration flag.

func AddZoneFlag

func AddZoneFlag(fs *pflag.FlagSet, zone *string, required bool)

AddZoneFlag adds the --zone/-z flag to the command.

func CheckRequired

func CheckRequired(flags *pflag.FlagSet) error

CheckRequired ensures that a command's required flags have been set. The only way to iterate over every flag in a pflag.FlagSet is with the VisitAll command. VisitAll takes a function as a parameter and calls that function on each flag in the flag set. This input function does not allow you to return errors; therefore, CheckRequired creates an error channel for it to send any errors that it encounters to then returns them.

func CheckTokenDuration added in v0.0.22

func CheckTokenDuration(tokenDuration time.Duration) error

CheckTokenDuration ensures that the token duration is not excessively long.

func FixupServiceAccountEmail

func FixupServiceAccountEmail(project string, serviceAccountEmail *string)

FixupServiceAccountEmail ensures that the service account email is set. This is done after flags have been parsed so that we can choose the service account associated with the selected project.

Types

type CmdConfig

type CmdConfig struct {
	ComputeInstance     string
	Project             string
	PubSubTopic         string
	Reason              string
	Region              string
	ServiceAccountEmail string
	StorageBucket       string
	Zone                string
	TokenDuration       time.Duration
}

CmdConfig holds the values passed to a command.

Jump to

Keyboard shortcuts

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