Example #1
0
File: push.go Project: nsnt/cli
func (cmd *Push) domain(c *cli.Context, domainName string) (domain cf.Domain) {
	var apiResponse net.ApiResponse

	if domainName != "" {
		domain, apiResponse = cmd.domainRepo.FindByNameInCurrentSpace(domainName)
		if apiResponse.IsNotSuccessful() {
			cmd.ui.Failed(apiResponse.Message)
		}
		return
	}

	apiResponse = cmd.domainRepo.ListSharedDomains(api.ListDomainsCallback(func(domains []cf.Domain) bool {
		domain = domains[0]
		return false
	}))

	if apiResponse.IsNotSuccessful() {
		cmd.ui.Failed(apiResponse.Message)
	}

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

	return
}
Example #2
0
func domainsCallback(status string, table terminal.Table, noDomains *bool) api.ListDomainsCallback {
	return api.ListDomainsCallback(func(domains []cf.Domain) bool {
		rows := [][]string{}
		for _, domain := range domains {
			rows = append(rows, []string{domain.Name, status})
		}
		table.Print(rows)
		*noDomains = false
		return true
	})
}