示例#1
0
//Delete a location in a given region for the particular provider
func Delete(cmd *cli.Cmd) {
	provider := cmd.String(cli.StringArg{
		Name:      "PROVIDER",
		Desc:      "Cloud provider(i.e. amazon)",
		HideValue: true,
	})

	identifier := cmd.String(cli.StringArg{
		Name:      "IDENTIFIER",
		Desc:      "Cloud provider specific region/zone/etc identifier (i.e. us-east-1)",
		HideValue: true,
	})

	cmd.Action = func() {
		l := location.Location{
			Provider: *provider,
			Region:   *identifier,
		}

		//TODO determine if there are any applications in the location and prompt user to remove them
		errs := l.Delete()

		if len(errs) > 0 {
			log.Fatalf("Could not delete location: %s", errs)
		}

		fmt.Printf("Deleting location %s-%s", *provider, *identifier)
	}
}
示例#2
0
//List all available Locations and optionally apply a filter
func List(cmd *cli.Cmd) {
	provider := cmd.String(cli.StringOpt{
		Name:      "provider",
		Desc:      "Cloud provider(i.e. amazon)",
		HideValue: true,
	})

	identifier := cmd.String(cli.StringOpt{
		Name:      "identifier",
		Desc:      "Cloud provider specific region/zone/etc identifier (i.e. us-east-1)",
		HideValue: true,
	})

	cmd.Action = func() {
		l := location.Location{
			Provider: *provider,
			Region:   *identifier,
		}

		body, errs := l.Find()

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve locations: %s", errs[0])
		}

		locations := &[]location.Location{}
		err := json.Unmarshal([]byte(body), locations)

		if err != nil {
			log.Fatal(err)
		}

		PrintLocationBrief(*locations)
	}
}
示例#3
0
//Add a location in a given region for the particular provider
func Add(cmd *cli.Cmd) {
	provider := cmd.String(cli.StringArg{
		Name:      "PROVIDER",
		Desc:      "Cloud provider(i.e. amazon)",
		HideValue: true,
	})

	identifier := cmd.String(cli.StringArg{
		Name:      "IDENTIFIER",
		Desc:      "Cloud provider specific region/zone/etc identifier (i.e. us-east-1)",
		HideValue: true,
	})

	cmd.Action = func() {
		l := location.Location{
			Provider: *provider,
			Region:   *identifier,
		}

		body, errs := l.Create()

		if len(errs) > 0 {
			log.Fatalf("Could not add new location: %s", errs)
		}

		err := json.Unmarshal([]byte(body), &l)

		if err != nil {
			log.Fatal(err)
		}

		PrintLocationBrief([]location.Location{l})
	}
}