Example #1
0
func (cmd *Push) updateApp(app models.Application, appParams models.AppParams) (updatedApp models.Application) {
	cmd.ui.Say("Updating app %s in org %s / space %s as %s...",
		terminal.EntityNameColor(app.Name),
		terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
		terminal.EntityNameColor(cmd.config.SpaceFields().Name),
		terminal.EntityNameColor(cmd.config.Username()),
	)

	if appParams.EnvironmentVars != nil {
		for key, val := range app.EnvironmentVars {
			if _, ok := (*appParams.EnvironmentVars)[key]; !ok {
				(*appParams.EnvironmentVars)[key] = val
			}
		}
	}

	var apiErr errors.Error
	updatedApp, apiErr = cmd.appRepo.Update(app.Guid, appParams)
	if apiErr != nil {
		cmd.ui.Failed(apiErr.Error())
		return
	}

	cmd.ui.Ok()
	cmd.ui.Say("")

	return
}
Example #2
0
func (cmd MarketplaceServices) Run(c *cli.Context) {
	var (
		serviceOfferings models.ServiceOfferings
		apiErr           errors.Error
	)

	if cmd.config.HasSpace() {
		cmd.ui.Say("Getting services from marketplace in org %s / space %s as %s...",
			terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
			terminal.EntityNameColor(cmd.config.SpaceFields().Name),
			terminal.EntityNameColor(cmd.config.Username()),
		)
		serviceOfferings, apiErr = cmd.serviceRepo.GetServiceOfferingsForSpace(cmd.config.SpaceFields().Guid)
	} else if !cmd.config.IsLoggedIn() {
		cmd.ui.Say("Getting all services from marketplace...")
		serviceOfferings, apiErr = cmd.serviceRepo.GetAllServiceOfferings()
	} else {
		cmd.ui.Failed("Cannot list marketplace services without a targetted space")
	}

	if apiErr != nil {
		cmd.ui.Failed(apiErr.Error())
		return
	}

	cmd.ui.Ok()
	cmd.ui.Say("")

	if len(serviceOfferings) == 0 {
		cmd.ui.Say("No service offerings found")
		return
	}

	table := [][]string{
		[]string{"service", "plans", "description"},
	}

	sort.Sort(serviceOfferings)
	for _, offering := range serviceOfferings {
		planNames := ""

		for _, plan := range offering.Plans {
			if plan.Name == "" {
				continue
			}
			planNames = planNames + ", " + plan.Name
		}

		planNames = strings.TrimPrefix(planNames, ", ")

		table = append(table, []string{
			offering.Label,
			planNames,
			offering.Description,
		})
	}

	cmd.ui.DisplayTable(table)
	return
}
Example #3
0
func (req *buildpackApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.buildpack, apiErr = req.buildpackRepo.FindByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #4
0
func (req *serviceInstanceApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.serviceInstance, apiErr = req.serviceRepo.FindInstanceByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #5
0
func (req *organizationApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.org, apiErr = req.orgRepo.FindByName(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #6
0
func (req *domainApiRequirement) Execute() bool {
	var apiErr errors.Error
	req.domain, apiErr = req.domainRepo.FindByNameInOrg(req.name, req.config.OrganizationFields().Guid)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #7
0
func (req *applicationApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.application, apiErr = req.appRepo.Read(req.name)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #8
0
func (req *userApiRequirement) Execute() (success bool) {
	var apiErr errors.Error
	req.user, apiErr = req.userRepo.FindByUsername(req.username)

	if apiErr != nil {
		req.ui.Failed(apiErr.Error())
		return false
	}

	return true
}
Example #9
0
func (cmd *Push) domain(c *cli.Context, domainName string) (domain models.DomainFields) {
	var apiErr errors.Error

	if domainName != "" {
		domain, apiErr = cmd.domainRepo.FindByNameInOrg(domainName, cmd.config.OrganizationFields().Guid)
		if apiErr != nil {
			cmd.ui.Failed(apiErr.Error())
		}
		return
	}

	domain, err := cmd.findDefaultDomain()

	if err != nil {
		cmd.ui.Failed(err.Error())
	}

	if domain.Guid == "" {
		cmd.ui.Failed("No default domain exists")
	}

	return
}