Exemple #1
0
// registerCommands registers commands in the specified registry.
func registerCommands(r commandRegistry, ctx *cmd.Context) {
	// Creation commands.
	r.Register(newBootstrapCommand())
	r.Register(newDeployCommand())
	r.Register(newAddRelationCommand())

	// Destruction commands.
	r.Register(newRemoveRelationCommand())
	r.Register(newRemoveServiceCommand())
	r.Register(newRemoveUnitCommand())
	r.Register(newDestroyEnvironmentCommand())

	// Reporting commands.
	r.Register(status.NewStatusCommand())
	r.Register(newSwitchCommand())
	r.Register(newEndpointCommand())
	r.Register(newAPIInfoCommand())
	r.Register(status.NewStatusHistoryCommand())

	// Error resolution and debugging commands.
	r.Register(newRunCommand())
	r.Register(newSCPCommand())
	r.Register(newSSHCommand())
	r.Register(newResolvedCommand())
	r.Register(newDebugLogCommand())
	r.Register(newDebugHooksCommand())

	// Configuration commands.
	r.Register(newInitCommand())
	r.RegisterDeprecated(common.NewGetConstraintsCommand(),
		twoDotOhDeprecation("environment get-constraints or service get-constraints"))
	r.RegisterDeprecated(common.NewSetConstraintsCommand(),
		twoDotOhDeprecation("environment set-constraints or service set-constraints"))
	r.Register(newExposeCommand())
	r.Register(newSyncToolsCommand())
	r.Register(newUnexposeCommand())
	r.Register(newUpgradeJujuCommand())
	r.Register(newUpgradeCharmCommand())

	// Charm publishing commands.
	r.Register(newPublishCommand())

	// Charm tool commands.
	r.Register(newHelpToolCommand())

	// Manage backups.
	r.Register(backups.NewSuperCommand())

	// Manage authorized ssh keys.
	r.Register(newAuthorizedKeysCommand())

	// Manage users and access
	r.Register(user.NewSuperCommand())

	// Manage cached images
	r.Register(cachedimages.NewSuperCommand())

	// Manage machines
	r.Register(machine.NewSuperCommand())
	r.RegisterSuperAlias("add-machine", "machine", "add", twoDotOhDeprecation("machine add"))
	r.RegisterSuperAlias("remove-machine", "machine", "remove", twoDotOhDeprecation("machine remove"))
	r.RegisterSuperAlias("destroy-machine", "machine", "remove", twoDotOhDeprecation("machine remove"))
	r.RegisterSuperAlias("terminate-machine", "machine", "remove", twoDotOhDeprecation("machine remove"))

	// Mangage environment
	r.Register(environment.NewSuperCommand())
	r.RegisterSuperAlias("get-environment", "environment", "get", twoDotOhDeprecation("environment get"))
	r.RegisterSuperAlias("get-env", "environment", "get", twoDotOhDeprecation("environment get"))
	r.RegisterSuperAlias("set-environment", "environment", "set", twoDotOhDeprecation("environment set"))
	r.RegisterSuperAlias("set-env", "environment", "set", twoDotOhDeprecation("environment set"))
	r.RegisterSuperAlias("unset-environment", "environment", "unset", twoDotOhDeprecation("environment unset"))
	r.RegisterSuperAlias("unset-env", "environment", "unset", twoDotOhDeprecation("environment unset"))
	r.RegisterSuperAlias("retry-provisioning", "environment", "retry-provisioning", twoDotOhDeprecation("environment retry-provisioning"))

	// Manage and control actions
	r.Register(action.NewSuperCommand())

	// Manage state server availability
	r.Register(newEnsureAvailabilityCommand())

	// Manage and control services
	r.Register(service.NewSuperCommand())
	r.RegisterSuperAlias("add-unit", "service", "add-unit", twoDotOhDeprecation("service add-unit"))
	r.RegisterSuperAlias("get", "service", "get", twoDotOhDeprecation("service get"))
	r.RegisterSuperAlias("set", "service", "set", twoDotOhDeprecation("service set"))
	r.RegisterSuperAlias("unset", "service", "unset", twoDotOhDeprecation("service unset"))

	// Operation protection commands
	r.Register(block.NewSuperBlockCommand())
	r.Register(block.NewUnblockCommand())

	// Manage storage
	r.Register(storage.NewSuperCommand())

	// Manage spaces
	r.Register(space.NewSuperCommand())

	// Manage subnets
	r.Register(subnet.NewSuperCommand())

	// Manage systems
	if featureflag.Enabled(feature.JES) {
		r.Register(system.NewSuperCommand())
		r.RegisterSuperAlias("systems", "system", "list", nil)

		// Add top level aliases of the same name as the subcommands.
		r.RegisterSuperAlias("environments", "system", "environments", nil)
		r.RegisterSuperAlias("login", "system", "login", nil)
		r.RegisterSuperAlias("create-environment", "system", "create-environment", nil)
		r.RegisterSuperAlias("create-env", "system", "create-env", nil)
	}
}
Exemple #2
0
// registerCommands registers commands in the specified registry.
func registerCommands(r commandRegistry, ctx *cmd.Context) {
	// Creation commands.
	r.Register(newBootstrapCommand())
	r.Register(newDeployCommand())
	r.Register(newAddRelationCommand())

	// Destruction commands.
	r.Register(newRemoveRelationCommand())
	r.Register(newRemoveServiceCommand())
	r.Register(newRemoveUnitCommand())

	// Reporting commands.
	r.Register(status.NewStatusCommand())
	r.Register(newSwitchCommand())
	r.Register(newEndpointCommand())
	r.Register(newAPIInfoCommand())
	r.Register(status.NewStatusHistoryCommand())

	// Error resolution and debugging commands.
	r.Register(newRunCommand())
	r.Register(newSCPCommand())
	r.Register(newSSHCommand())
	r.Register(newResolvedCommand())
	r.Register(newDebugLogCommand())
	r.Register(newDebugHooksCommand())

	// Configuration commands.
	r.Register(newInitCommand())
	r.Register(common.NewGetConstraintsCommand())
	r.Register(common.NewSetConstraintsCommand())
	r.Register(newExposeCommand())
	r.Register(newSyncToolsCommand())
	r.Register(newUnexposeCommand())
	r.Register(newUpgradeJujuCommand(nil))
	r.Register(newUpgradeCharmCommand())

	// Charm publishing commands.
	r.Register(newPublishCommand())

	// Charm tool commands.
	r.Register(newHelpToolCommand())

	// Manage backups.
	r.Register(backups.NewSuperCommand())

	// Manage authorized ssh keys.
	r.Register(newAuthorizedKeysCommand())

	// Manage users and access
	r.Register(user.NewAddCommand())
	r.Register(user.NewChangePasswordCommand())
	r.Register(user.NewCredentialsCommand())
	r.Register(user.NewShowUserCommand())
	r.Register(user.NewListCommand())
	r.Register(user.NewEnableCommand())
	r.Register(user.NewDisableCommand())

	// Manage cached images
	r.Register(cachedimages.NewSuperCommand())

	// Manage machines
	r.Register(machine.NewSuperCommand())
	r.RegisterSuperAlias("add-machine", "machine", "add", nil)
	r.RegisterSuperAlias("remove-machine", "machine", "remove", nil)
	r.RegisterSuperAlias("destroy-machine", "machine", "remove", nil)
	r.RegisterSuperAlias("terminate-machine", "machine", "remove", nil)

	// Mangage environment
	r.Register(environment.NewGetCommand())
	r.Register(environment.NewSetCommand())
	r.Register(environment.NewUnsetCommand())
	r.Register(environment.NewRetryProvisioningCommand())
	r.Register(environment.NewDestroyCommand())

	r.Register(environment.NewShareCommand())
	r.Register(environment.NewUnshareCommand())
	r.Register(environment.NewUsersCommand())

	// Manage and control actions
	r.Register(action.NewSuperCommand())

	// Manage state server availability
	r.Register(newEnsureAvailabilityCommand())

	// Manage and control services
	r.Register(service.NewSuperCommand())
	r.RegisterSuperAlias("add-unit", "service", "add-unit", nil)
	r.RegisterSuperAlias("get", "service", "get", nil)
	r.RegisterSuperAlias("set", "service", "set", nil)
	r.RegisterSuperAlias("unset", "service", "unset", nil)

	// Operation protection commands
	r.Register(block.NewSuperBlockCommand())
	r.Register(block.NewUnblockCommand())

	// Manage storage
	r.Register(storage.NewSuperCommand())

	// Manage spaces
	r.Register(space.NewSuperCommand())

	// Manage subnets
	r.Register(subnet.NewSuperCommand())

	// Manage controllers
	r.Register(controller.NewCreateEnvironmentCommand())
	r.Register(controller.NewDestroyCommand())
	r.Register(controller.NewEnvironmentsCommand())
	r.Register(controller.NewKillCommand())
	r.Register(controller.NewListCommand())
	r.Register(controller.NewListBlocksCommand())
	r.Register(controller.NewLoginCommand())
	r.Register(controller.NewRemoveBlocksCommand())
	r.Register(controller.NewUseEnvironmentCommand())

	// Commands registered elsewhere.
	for _, newCommand := range registeredCommands {
		command := newCommand()
		r.Register(command)
	}
	for _, newCommand := range registeredEnvCommands {
		command := newCommand()
		r.Register(envcmd.Wrap(command))
	}
}