Beispiel #1
0
func createAction(context *cli.Context) {
	if !context.Args().Present() {
		println("You must specify a 'name' for the box you want to create.\nSee 'farmer create --help' for more info.")
		return
	}

	if context.String("repo") == "" {
		println("You must specify a 'repo' (Git repository Url) to clone code on the box.\nSee 'farmer create --help' for more info.")
		return
	}

	if context.String("pathspec") == "" {
		println("Warning: Box will clone 'master' branch of the provided repository.")
		return
	}

	stream := hub.Stream{}
	request := request.CreateRequest{
		Name:     context.Args().First(),
		RepoUrl:  context.String("repo"),
		Pathspec: context.String("pathspec"),
	}

	if err := api.Post("/boxes", &request, &stream); err != nil {
		println(err.Error())
		return
	}

	if err := stream.Consume(); err != nil {
		println("Could not consume the stream from Farmer server.")
		return
	}
}
Beispiel #2
0
func addDomainAction(context *cli.Context) {
	if !context.Args().Present() {
		println("You must specify a 'name' for the box you want to assign domain to.\nSee 'farmer domain_add --help' for more info.")
		return
	}

	if context.String("domain") == "" {
		println("You must specify a 'domain' URL.\nSee 'farmer domain_add --help' for more info.")
		return
	}

	request := request.Domain{
		Url:  context.String("domain"),
		Port: context.String("port"),
	}

	if err := api.Post("/boxes/"+context.Args().First()+"/domain", &request, nil); err != nil {
		println(err.Error())
		return
	}

	println("Domain " + context.String("domain") + " assigned to port " + context.String("port") + " of box " + context.Args().First() + ".")
}