Documentation
¶
Index ¶
- Constants
- Variables
- func AddComputeInstanceFlag(fs *pflag.FlagSet, instance *string, required bool)
- func AddPersistentFlags(fs *pflag.FlagSet)
- func AddProjectFlag(fs *pflag.FlagSet, project *string, required bool)
- func AddPubSubTopicFlag(fs *pflag.FlagSet, topic *string, required bool)
- func AddReasonFlag(fs *pflag.FlagSet, reason *string, required bool)
- func AddRegionFlag(fs *pflag.FlagSet, region *string, required bool)
- func AddServiceAccountEmailFlag(fs *pflag.FlagSet, serviceAccountEmail *string, required bool)
- func AddStorageBucketFlag(fs *pflag.FlagSet, bucket *string, required bool)
- func AddZoneFlag(fs *pflag.FlagSet, zone *string, required bool)
- func CheckRequired(flags *pflag.FlagSet) error
- type CmdConfig
Constants ¶
const (
RequiredAnnotation = "eiam_required_flag"
)
Flag annotation strings.
Variables ¶
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"} )
Flag names and shorthands.
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.
var (
YesOption = false
)
YesOption designates whether to prompt for confirmation or not.
Functions ¶
func AddComputeInstanceFlag ¶
AddComputeInstanceFlag adds the --instance/-i flag to the command.
func AddPersistentFlags ¶
AddPersistentFlags add persistent flags to the root command.
func AddProjectFlag ¶
AddProjectFlag adds the --project/-p flag to the command.
func AddPubSubTopicFlag ¶
AddPubSubTopicFlag adds the --topic/-t flag to the command.
func AddReasonFlag ¶
AddReasonFlag adds the --reason/-R flag.
func AddRegionFlag ¶
AddRegionFlag adds the --region/-r flag to the command.
func AddServiceAccountEmailFlag ¶
AddServiceAccountEmailFlag adds the --service-account-email/-s flag.
func AddStorageBucketFlag ¶
AddStorageBucketFlag adds the --bucket/-b flag to the command.
func AddZoneFlag ¶
AddZoneFlag adds the --zone/-z flag to the command.
func CheckRequired ¶
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.