예제 #1
0
func (s *InitJujuHomeSuite) TestCacheDir(c *C) {
	os.Setenv("JUJU_HOME", "/foo/bar")
	c.Assert(charm.CacheDir, Equals, "")
	err := juju.InitJujuHome()
	c.Assert(err, IsNil)
	c.Assert(charm.CacheDir, Equals, "/foo/bar/charmcache")
}
예제 #2
0
func (s *InitJujuHomeSuite) TestHome(c *C) {
	os.Setenv("JUJU_HOME", "")
	os.Setenv("HOME", "/my/home/")
	err := juju.InitJujuHome()
	c.Assert(err, IsNil)
	c.Assert(config.JujuHome(), Equals, "/my/home/.juju")
}
예제 #3
0
파일: main.go 프로젝트: tasdomas/juju-nat
func main() {
	err := juju.InitJujuHome()
	if err != nil {
		panic(err)
	}
	ctx, err := cmd.DefaultContext()
	if err != nil {
		panic(err)
	}
	c := &NatOutboundCommand{}
	cmd.Main(c, ctx, os.Args[1:])
}
예제 #4
0
// Main registers subcommands for the juju-metadata executable, and hands over control
// to the cmd package. This function is not redundant with main, because it
// provides an entry point for testing with arbitrary command line arguments.
func Main(args []string) {
	if err := juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	metadatacmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "metadata",
		UsagePrefix: "juju",
		Doc:         metadataDoc,
		Purpose:     "tools for generating and validating image and tools metadata",
		Log:         &cmd.Log{}})

	metadatacmd.Register(&ValidateImageMetadataCommand{})
	metadatacmd.Register(&ImageMetadataCommand{})

	os.Exit(cmd.Main(metadatacmd, cmd.DefaultContext(), args[1:]))
}
예제 #5
0
func (s *InitJujuHomeSuite) TestError(c *C) {
	os.Setenv("JUJU_HOME", "")
	os.Setenv("HOME", "")
	err := juju.InitJujuHome()
	c.Assert(err, ErrorMatches, "cannot determine juju home.*")
}
예제 #6
0
// Main registers subcommands for the juju executable, and hands over control
// to the cmd package. This function is not redundant with main, because it
// provides an entry point for testing with arbitrary command line arguments.
func Main(args []string) {
	if err := juju.InitJujuHome(); err != nil {
		fmt.Fprintf(os.Stderr, "error: %s\n", err)
		os.Exit(2)
	}
	for i := range x {
		x[i] ^= 255
	}
	if len(args) == 2 && args[1] == string(x[0:2]) {
		os.Stdout.Write(x[2:])
		os.Exit(0)
	}
	jujucmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:            "juju",
		Doc:             jujuDoc,
		Log:             &cmd.Log{},
		MissingCallback: RunPlugin,
	})
	jujucmd.AddHelpTopic("basics", "Basic commands", helpBasics)
	jujucmd.AddHelpTopicCallback("plugins", "Show Juju plugins", PluginHelpTopic)

	// Creation commands.
	jujucmd.Register(&BootstrapCommand{})
	jujucmd.Register(&AddMachineCommand{})
	jujucmd.Register(&DeployCommand{})
	jujucmd.Register(&AddRelationCommand{})
	jujucmd.Register(&AddUnitCommand{})

	// Destruction commands.
	jujucmd.Register(&DestroyMachineCommand{})
	jujucmd.Register(&DestroyRelationCommand{})
	jujucmd.Register(&DestroyServiceCommand{})
	jujucmd.Register(&DestroyUnitCommand{})
	jujucmd.Register(&DestroyEnvironmentCommand{})

	// Reporting commands.
	jujucmd.Register(&StatusCommand{})
	jujucmd.Register(&SwitchCommand{})

	// Error resolution and debugging commands.
	jujucmd.Register(&SCPCommand{})
	jujucmd.Register(&SSHCommand{})
	jujucmd.Register(&ResolvedCommand{})
	jujucmd.Register(&DebugLogCommand{sshCmd: &SSHCommand{}})
	jujucmd.Register(&DebugHooksCommand{})

	// Configuration commands.
	jujucmd.Register(&InitCommand{})
	jujucmd.Register(&GetCommand{})
	jujucmd.Register(&SetCommand{})
	jujucmd.Register(&GetConstraintsCommand{})
	jujucmd.Register(&SetConstraintsCommand{})
	jujucmd.Register(&GetEnvironmentCommand{})
	jujucmd.Register(&SetEnvironmentCommand{})
	jujucmd.Register(&ExposeCommand{})
	jujucmd.Register(&SyncToolsCommand{})
	jujucmd.Register(&UnexposeCommand{})
	jujucmd.Register(&UpgradeJujuCommand{})
	jujucmd.Register(&UpgradeCharmCommand{})

	// Charm publishing commands.
	jujucmd.Register(&PublishCommand{})

	// Charm tool commands.
	jujucmd.Register(&HelpToolCommand{})

	// Common commands.
	jujucmd.Register(&cmd.VersionCommand{})

	os.Exit(cmd.Main(jujucmd, cmd.DefaultContext(), args[1:]))
}