func (c *UpgradeJujuCommand) SetFlags(f *gnuflag.FlagSet) { c.EnvCommandBase.SetFlags(f) f.StringVar(&c.vers, "version", "", "upgrade to specific version") f.BoolVar(&c.Development, "dev", false, "allow development versions to be chosen") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools") f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied comma-separated series list") }
func (c *RelationGetCommand) SetFlags(f *gnuflag.FlagSet) { rV := newRelationIdValue(c.ctx, &c.RelationId) c.out.AddFlags(f, "smart", cmd.DefaultFormatters) f.Var(rV, "r", "specify a relation by id") f.Var(rV, "relation", "") }
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) { c.AgentConf.AddFlags(f) yamlBase64Var(f, &c.EnvConfig, "env-config", "", "initial environment configuration (yaml, base64 encoded)") f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "initial environment constraints (space-separated strings)") f.Var(&c.Hardware, "hardware", "hardware characteristics (space-separated strings)") f.StringVar(&c.InstanceId, "instance-id", "", "unique instance-id for bootstrap machine") }
func (c *RelationGetCommand) Init(f *gnuflag.FlagSet, args []string) error { // TODO FWER implement --format shell lp:1033511 c.out.AddFlags(f, "smart", cmd.DefaultFormatters) f.Var(newRelationIdValue(c.ctx, &c.RelationId), "r", "specify a relation by id") if err := f.Parse(true, args); err != nil { return err } if c.RelationId == -1 { return fmt.Errorf("no relation id specified") } args = f.Args() c.Key = "" if len(args) > 0 { if c.Key = args[0]; c.Key == "-" { c.Key = "" } args = args[1:] } if name, found := c.ctx.RemoteUnitName(); found { c.UnitName = name } if len(args) > 0 { c.UnitName = args[0] args = args[1:] } if c.UnitName == "" { return fmt.Errorf("no unit id specified") } return cmd.CheckEmpty(args) }
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) { c.EnvCommandBase.SetFlags(f) f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set environment constraints") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping") f.Var(seriesVar{&c.Series}, "series", "upload tools for supplied comma-separated series list") f.StringVar(&c.Source, "source", "", "local path to use as tools source") }
// SetFlags handles known option flags. func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(constraints.ConstraintsValue{Target: &c.constraints}, "constraints", "set environment constraints") f.BoolVar(&c.bootstrap, "b", false, "bootstrap a new state machine") f.StringVar(&c.filename, "file", "", "provide a file to be used as the backup.") f.StringVar(&c.backupId, "id", "", "provide the name of the backup to be restored.") }
func (c *upgradeJujuCommand) SetFlags(f *gnuflag.FlagSet) { f.StringVar(&c.vers, "version", "", "upgrade to specific version") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools") f.BoolVar(&c.DryRun, "dry-run", false, "don't change anything, just report what would change") f.BoolVar(&c.ResetPrevious, "reset-previous-upgrade", false, "clear the previous (incomplete) upgrade status (use with care)") f.BoolVar(&c.AssumeYes, "y", false, "answer 'yes' to confirmation prompts") f.BoolVar(&c.AssumeYes, "yes", false, "") f.Var(newSeriesValue(nil, &c.Series), "series", "upload tools for supplied comma-separated series list (OBSOLETE)") }
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) { c.AgentConf.AddFlags(f) yamlBase64Var(f, &c.EnvConfig, "env-config", "", "initial environment configuration (yaml, base64 encoded)") f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "initial environment constraints (space-separated strings)") f.Var(&c.Hardware, "hardware", "hardware characteristics (space-separated strings)") f.StringVar(&c.InstanceId, "instance-id", "", "unique instance-id for bootstrap machine") f.StringVar(&c.AdminUsername, "admin-user", "admin", "set the name for the juju admin user") f.StringVar(&c.ImageMetadataDir, "image-metadata", "", "custom image metadata source dir") }
func (c *upgradeCharmCommand) SetFlags(f *gnuflag.FlagSet) { f.BoolVar(&c.ForceUnits, "force-units", false, "upgrade all units immediately, even if in error state") f.StringVar((*string)(&c.Channel), "channel", "", "channel to use when getting the charm or bundle from the charm store") f.BoolVar(&c.ForceSeries, "force-series", false, "upgrade even if series of deployed services are not supported by the new charm") f.StringVar(&c.SwitchURL, "switch", "", "crossgrade to a different charm") f.StringVar(&c.CharmPath, "path", "", "upgrade to a charm located at path") f.IntVar(&c.Revision, "revision", -1, "explicit revision of current charm") f.Var(stringMap{&c.Resources}, "resource", "resource to be uploaded to the controller") }
// SetFlags handles known option flags. func (c *restoreCommand) SetFlags(f *gnuflag.FlagSet) { c.CommandBase.SetFlags(f) f.Var(constraints.ConstraintsValue{Target: &c.constraints}, "constraints", "set model constraints") f.BoolVar(&c.bootstrap, "b", false, "bootstrap a new state machine") f.StringVar(&c.filename, "file", "", "provide a file to be used as the backup.") f.StringVar(&c.backupId, "id", "", "provide the name of the backup to be restored.") f.BoolVar(&c.uploadTools, "upload-tools", false, "upload tools if bootstraping a new machine.") }
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) { c.UnitCommandBase.SetFlags(f) f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms") f.BoolVar(&c.BumpRevision, "u", false, "increment local charm directory revision (DEPRECATED)") f.BoolVar(&c.BumpRevision, "upgrade", false, "") f.Var(&c.Config, "config", "path to yaml-formatted service config") f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set service constraints") f.StringVar(&c.Networks, "networks", "", "bind the service to specific networks") f.StringVar(&c.RepoPath, "repository", os.Getenv(osenv.JujuRepositoryEnvKey), "local charm repository") }
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) { c.EnvCommandBase.SetFlags(f) c.UnitCommandBase.SetFlags(f) f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms") f.BoolVar(&c.BumpRevision, "u", false, "increment local charm directory revision") f.BoolVar(&c.BumpRevision, "upgrade", false, "") f.Var(&c.Config, "config", "path to yaml-formatted service config") f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set service constraints") f.StringVar(&c.RepoPath, "repository", os.Getenv("JUJU_REPOSITORY"), "local charm repository") }
func (c *EnsureAvailabilityCommand) SetFlags(f *gnuflag.FlagSet) { f.IntVar(&c.NumStateServers, "n", 0, "number of state servers to make available") f.StringVar(&c.Series, "series", "", "the charm series") f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "additional machine constraints") c.out.AddFlags(f, "simple", map[string]cmd.Formatter{ "yaml": cmd.FormatYaml, "json": cmd.FormatJson, "simple": formatSimple, }) }
// SetFlags implements Command.SetFlags. func (c *PoolListCommand) SetFlags(f *gnuflag.FlagSet) { c.StorageCommandBase.SetFlags(f) f.Var(cmd.NewAppendStringsValue(&c.Providers), "provider", "only show pools of these provider types") f.Var(cmd.NewAppendStringsValue(&c.Names), "name", "only show pools with these names") c.out.AddFlags(f, "yaml", map[string]cmd.Formatter{ "yaml": cmd.FormatYaml, "json": cmd.FormatJson, "tabular": formatPoolListTabular, }) }
func (c *enableHACommand) SetFlags(f *gnuflag.FlagSet) { f.IntVar(&c.NumControllers, "n", 0, "number of controllers to make available") f.StringVar(&c.Series, "series", "", "the charm series") f.StringVar(&c.PlacementSpec, "to", "", "the machine(s) to become controllers, bypasses constraints") f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "additional machine constraints") c.out.AddFlags(f, "simple", map[string]cmd.Formatter{ "yaml": cmd.FormatYaml, "json": cmd.FormatJson, "simple": formatSimple, }) }
func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set model constraints") f.Var(constraints.ConstraintsValue{Target: &c.BootstrapConstraints}, "bootstrap-constraints", "specify bootstrap machine constraints") f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "specify the series of the bootstrap machine") if featureflag.Enabled(feature.ImageMetadata) { f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "specify the image of the bootstrap machine") } f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping") f.StringVar(&c.MetadataSource, "metadata-source", "", "local path to use as tools and/or metadata source") f.StringVar(&c.Placement, "to", "", "a placement directive indicating an instance to bootstrap") f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "do not destroy the model if bootstrap fails") f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "upgrade to the latest patch release tools on first bootstrap") f.StringVar(&c.AgentVersionParam, "agent-version", "", "the version of tools to use for Juju agents") }
func (c *SetCommand) Init(f *gnuflag.FlagSet, args []string) error { addEnvironFlags(&c.EnvName, f) f.Var(&c.Config, "config", "path to yaml-formatted service config") if err := f.Parse(true, args); err != nil { return err } args = f.Args() if len(args) == 0 || len(strings.Split(args[0], "=")) > 1 { return errors.New("no service name specified") } if len(c.Config.Path) > 0 && len(args) > 1 { return errors.New("cannot specify --config when using key=value arguments") } c.ServiceName, c.Options = args[0], args[1:] return nil }
// SetFlags implements Command.SetFlags. func (c *listImagesCommand) SetFlags(f *gnuflag.FlagSet) { c.cloudImageMetadataCommandBase.SetFlags(f) f.StringVar(&c.Stream, "stream", "", "image metadata stream") f.StringVar(&c.Region, "region", "", "image metadata cloud region") f.Var(cmd.NewAppendStringsValue(&c.Series), "series", "only show cloud image metadata for these series") f.Var(cmd.NewAppendStringsValue(&c.Arches), "arch", "only show cloud image metadata for these architectures") f.StringVar(&c.VirtType, "virt-type", "", "image metadata virtualisation type") f.StringVar(&c.RootStorageType, "storage-type", "", "image metadata root storage type") c.out.AddFlags(f, "tabular", map[string]cmd.Formatter{ "yaml": cmd.FormatYaml, "json": cmd.FormatJson, "tabular": formatMetadataListTabular, }) }
func (c *RelationSetCommand) Init(f *gnuflag.FlagSet, args []string) error { f.Var(newRelationIdValue(c.ctx, &c.RelationId), "r", "specify a relation by id") if err := f.Parse(true, args); err != nil { return err } if c.RelationId == -1 { return fmt.Errorf("no relation id specified") } args = f.Args() if len(args) == 0 { return fmt.Errorf(`expected "key=value" parameters, got nothing`) } for _, kv := range args { parts := strings.SplitN(kv, "=", 2) if len(parts) != 2 || len(parts[0]) == 0 { return fmt.Errorf(`expected "key=value", got %q`, kv) } c.Settings[parts[0]] = parts[1] } return nil }
func (c *RunCommand) SetFlags(f *gnuflag.FlagSet) { c.out.AddFlags(f, "smart", cmd.DefaultFormatters) f.BoolVar(&c.all, "all", false, "run the commands on all the machines") f.DurationVar(&c.timeout, "timeout", 5*time.Minute, "how long to wait before the remote command is considered to have failed") f.Var(cmd.NewStringsValue(nil, &c.machines), "machine", "one or more machine ids") f.Var(cmd.NewStringsValue(nil, &c.services), "service", "one or more service names") f.Var(cmd.NewStringsValue(nil, &c.units), "unit", "one or more unit ids") }
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set environment constraints") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping") f.Var(newSeriesValue(nil, &c.Series), "upload-series", "upload tools for supplied comma-separated series list") f.Var(newSeriesValue(nil, &c.seriesOld), "series", "upload tools for supplied comma-separated series list (DEPRECATED, see --upload-series)") f.StringVar(&c.MetadataSource, "metadata-source", "", "local path to use as tools and/or metadata source") f.StringVar(&c.Placement, "to", "", "a placement directive indicating an instance to bootstrap") }
func (c *RelationSetCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(c.relationIdProxy, "r", "specify a relation by id") f.Var(c.relationIdProxy, "relation", "") c.settingsFile.SetStdin() f.Var(&c.settingsFile, "file", "file containing key-value pairs") f.StringVar(&c.formatFlag, "format", "", "deprecated format flag") }
func (c *BootstrapCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set environment constraints") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping") f.Var(newSeriesValue(nil, &c.Series), "upload-series", "upload tools for supplied comma-separated series list (OBSOLETE)") f.Var(newSeriesValue(nil, &c.seriesOld), "series", "see --upload-series (OBSOLETE)") f.StringVar(&c.MetadataSource, "metadata-source", "", "local path to use as tools and/or metadata source") f.StringVar(&c.Placement, "to", "", "a placement directive indicating an instance to bootstrap") f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "do not destroy the environment if bootstrap fails") f.BoolVar(&c.NoAutoUpgrade, "no-auto-upgrade", false, "do not upgrade to newer tools on first bootstrap") f.StringVar(&c.AgentVersionParam, "agent-version", "", "the version of tools to initially use for Juju agents") }
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) { // Keep above charmOnlyFlags and bundleOnlyFlags lists updated when adding // new flags. c.UnitCommandBase.SetFlags(f) f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms") f.StringVar((*string)(&c.Channel), "channel", "", "channel to use when getting the charm or bundle from the charm store") f.Var(&c.Config, "config", "path to yaml-formatted service config") f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set service constraints") f.StringVar(&c.Series, "series", "", "the series on which to deploy") f.BoolVar(&c.Force, "force", false, "allow a charm to be deployed to a machine running an unsupported series") f.Var(storageFlag{&c.Storage, &c.BundleStorage}, "storage", "charm storage constraints") f.Var(stringMap{&c.Resources}, "resource", "resource to be uploaded to the controller") f.StringVar(&c.BindToSpaces, "bind", "", "Configure service endpoint bindings to spaces") for _, step := range c.Steps { step.SetFlags(f) } c.flagSet = f }
func (c *DeployCommand) SetFlags(f *gnuflag.FlagSet) { // Keep above charmOnlyFlags and bundleOnlyFlags lists updated when adding // new flags. c.UnitCommandBase.SetFlags(f) f.IntVar(&c.NumUnits, "n", 1, "number of service units to deploy for principal charms") f.BoolVar(&c.BumpRevision, "u", false, "increment local charm directory revision (DEPRECATED)") f.BoolVar(&c.BumpRevision, "upgrade", false, "") f.Var(&c.Config, "config", "path to yaml-formatted service config") f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set service constraints") f.StringVar(&c.Networks, "networks", "", "deprecated and ignored: use space constraints instead.") f.StringVar(&c.RepoPath, "repository", os.Getenv(osenv.JujuRepositoryEnvKey), "local charm repository") f.StringVar(&c.Series, "series", "", "the series on which to deploy") f.BoolVar(&c.Force, "force", false, "allow a charm to be deployed to a machine running an unsupported series") f.Var(storageFlag{&c.Storage, &c.BundleStorage}, "storage", "charm storage constraints") f.Var(stringMap{&c.Resources}, "resource", "resource to be uploaded to the controller") f.StringVar(&c.BindToSpaces, "bind", "", "Configure service endpoint bindings to spaces") for _, step := range c.Steps { step.SetFlags(f) } c.flagSet = f }
func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "Set model constraints") f.Var(constraints.ConstraintsValue{Target: &c.BootstrapConstraints}, "bootstrap-constraints", "Specify bootstrap machine constraints") f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "Specify the series of the bootstrap machine") if featureflag.Enabled(feature.ImageMetadata) { f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "Specify the image of the bootstrap machine") } f.BoolVar(&c.UploadTools, "upload-tools", false, "Upload local version of tools before bootstrapping") f.StringVar(&c.MetadataSource, "metadata-source", "", "Local path to use as tools and/or metadata source") f.StringVar(&c.Placement, "to", "", "Placement directive indicating an instance to bootstrap") f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "Do not destroy the model if bootstrap fails") f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "Upgrade to the latest patch release tools on first bootstrap") f.StringVar(&c.AgentVersionParam, "agent-version", "", "Version of tools to use for Juju agents") f.StringVar(&c.CredentialName, "credential", "", "Credentials to use when bootstrapping") f.Var(&c.config, "config", "Specify a controller configuration file, or one or more configuration\n options\n (--config config.yaml [--config key=value ...])") f.StringVar(&c.hostedModelName, "d", defaultHostedModelName, "Name of the default hosted model for the controller") f.StringVar(&c.hostedModelName, "default-model", defaultHostedModelName, "Name of the default hosted model for the controller") f.BoolVar(&c.noGUI, "no-gui", false, "Do not install the Juju GUI in the controller when bootstrapping") }
func (c *UpgradeJujuCommand) SetFlags(f *gnuflag.FlagSet) { f.StringVar(&c.vers, "version", "", "upgrade to specific version") f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools") f.BoolVar(&c.DryRun, "dry-run", false, "don't change anything, just report what would change") f.Var(newSeriesValue(nil, &c.Series), "series", "upload tools for supplied comma-separated series list (OBSOLETE)") }
// yamlBase64Var sets up a gnuflag flag analogous to the FlagSet.*Var methods. func yamlBase64Var(fs *gnuflag.FlagSet, target *map[string]interface{}, name string, value string, usage string) { fs.Var((*yamlBase64Value)(target), name, usage) }
func (c *createModelCommand) SetFlags(f *gnuflag.FlagSet) { f.StringVar(&c.Owner, "owner", "", "the owner of the new model if not the current user") f.StringVar(&c.CredentialSpec, "credential", "", "the name of the cloud and credentials the new model uses to create cloud resources") f.Var(&c.Config, "config", "specify a controller config file, or one or more controller configuration options (--config config.yaml [--config k=v ...])") }
func (c *SetCommand) SetFlags(f *gnuflag.FlagSet) { f.Var(&c.SettingsYAML, "config", "path to yaml-formatted service config") }