本文整理匯總了Golang中cf/terminal.EntityNameColor函數的典型用法代碼示例。如果您正苦於以下問題:Golang EntityNameColor函數的具體用法?Golang EntityNameColor怎麽用?Golang EntityNameColor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EntityNameColor函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (cmd *BindService) Run(c *cli.Context) {
app := cmd.appReq.GetApplication()
serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say("Binding service %s to app %s in org %s / space %s as %s...",
terminal.EntityNameColor(serviceInstance.Name),
terminal.EntityNameColor(app.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apiResponse := cmd.BindApplication(app, serviceInstance)
if apiResponse.IsNotSuccessful() && apiResponse.ErrorCode != AppAlreadyBoundErrorCode {
cmd.ui.Failed(apiResponse.Message)
}
cmd.ui.Ok()
if apiResponse.ErrorCode == AppAlreadyBoundErrorCode {
cmd.ui.Warn("App %s is already bound to %s.", app.Name, serviceInstance.Name)
return
}
cmd.ui.Say("TIP: Use '%s push' to ensure your env variable changes take effect", cf.Name())
}
示例2: Run
func (cmd *Events) Run(c *cli.Context) {
app := cmd.appReq.GetApplication()
cmd.ui.Say("Getting events for app %s in org %s / space %s as %s...\n",
terminal.EntityNameColor(app.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
table := cmd.ui.Table([]string{"time", "event", "description"})
events, apiErr := cmd.eventsRepo.RecentEvents(app.Guid, 50)
if apiErr != nil {
cmd.ui.Failed("Failed fetching events.\n%s", apiErr.Error())
return
}
for _, event := range events {
table.Print([][]string{{
event.Timestamp.Local().Format(TIMESTAMP_FORMAT),
event.Name,
event.Description,
}})
}
if len(events) == 0 {
cmd.ui.Say("No events for app %s", terminal.EntityNameColor(app.Name))
return
}
}
示例3: Run
func (cmd *Files) Run(c *cli.Context) {
app := cmd.appReq.GetApplication()
cmd.ui.Say("Getting files for 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()),
)
path := "/"
if len(c.Args()) > 1 {
path = c.Args()[1]
}
list, apiResponse := cmd.appFilesRepo.ListFiles(app.Guid, path)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
cmd.ui.Say("")
cmd.ui.Say("%s", list)
}
示例4: Run
func (cmd UpdateServiceBroker) Run(c *cli.Context) {
serviceBroker, apiResponse := cmd.repo.FindByName(c.Args()[0])
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Say("Updating service broker %s as %s...",
terminal.EntityNameColor(serviceBroker.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
serviceBroker.Username = c.Args()[1]
serviceBroker.Password = c.Args()[2]
serviceBroker.Url = c.Args()[3]
apiResponse = cmd.repo.Update(serviceBroker)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
}
示例5: Run
func (cmd *OrgUsers) Run(c *cli.Context) {
org := cmd.orgReq.GetOrganization()
all := c.Bool("a")
cmd.ui.Say("Getting users in org %s as %s...",
terminal.EntityNameColor(org.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
roles := orgRoles
if all {
roles = []string{models.ORG_USER}
}
for _, role := range roles {
displayName := orgRoleToDisplayName[role]
users, apiErr := cmd.userRepo.ListUsersInOrgForRole(org.Guid, role)
cmd.ui.Say("")
cmd.ui.Say("%s", terminal.HeaderColor(displayName))
for _, user := range users {
cmd.ui.Say(" %s", user.Username)
}
if apiErr != nil {
cmd.ui.Failed("Failed fetching org-users for role %s.\n%s", apiErr.Error(), displayName)
return
}
}
}
示例6: Run
func (cmd *UnsetSpaceRole) Run(c *cli.Context) {
spaceName := c.Args()[2]
role := models.UserInputToSpaceRole[c.Args()[3]]
user := cmd.userReq.GetUser()
org := cmd.orgReq.GetOrganization()
space, apiResponse := cmd.spaceRepo.FindByNameInOrg(spaceName, org.Guid)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Say("Removing role %s from user %s in org %s / space %s as %s...",
terminal.EntityNameColor(role),
terminal.EntityNameColor(user.Username),
terminal.EntityNameColor(org.Name),
terminal.EntityNameColor(space.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apiResponse = cmd.userRepo.UnsetSpaceRole(user.Guid, space.Guid, role)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
}
示例7: Run
func (cmd *BindService) Run(c *cli.Context) {
app := cmd.appReq.GetApplication()
instance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say("Binding service %s to app %s in org %s / space %s as %s...",
terminal.EntityNameColor(instance.Name),
terminal.EntityNameColor(app.Name),
terminal.EntityNameColor(cmd.config.Organization.Name),
terminal.EntityNameColor(cmd.config.Space.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apiResponse := cmd.serviceBindingRepo.Create(instance, app)
if apiResponse.IsNotSuccessful() && apiResponse.ErrorCode != "90003" {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
if apiResponse.ErrorCode == "90003" {
cmd.ui.Warn("App %s is already bound to %s.", app.Name, instance.Name)
return
}
cmd.ui.Say("TIP: Use 'cf push' to ensure your env variable changes take effect")
}
示例8: Run
func (cmd *MapRoute) Run(c *cli.Context) {
hostName := c.String("n")
domain := cmd.domainReq.GetDomain()
app := cmd.appReq.GetApplication()
route, apiResponse := cmd.routeCreator.CreateRoute(hostName, domain.DomainFields, cmd.config.SpaceFields)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed("Error resolving route:\n%s", apiResponse.Message)
}
cmd.ui.Say("Adding route %s to app %s in org %s / space %s as %s...",
terminal.EntityNameColor(route.URL()),
terminal.EntityNameColor(app.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields.Name),
terminal.EntityNameColor(cmd.config.SpaceFields.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apiResponse = cmd.routeRepo.Bind(route.Guid, app.Guid)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
}
示例9: Run
func (cmd ListStacks) Run(c *cli.Context) {
cmd.ui.Say("Getting stacks in org %s / space %s as %s...",
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
stacks, apiResponse := cmd.stacksRepo.FindAll()
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed(apiResponse.Message)
return
}
cmd.ui.Ok()
cmd.ui.Say("")
table := [][]string{
[]string{"name", "description"},
}
for _, stack := range stacks {
table = append(table, []string{
stack.Name,
stack.Description,
})
}
cmd.ui.DisplayTable(table)
}
示例10: Run
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
}
示例11: ApplicationStop
func (cmd *Stop) ApplicationStop(app models.Application) (updatedApp models.Application, err error) {
if app.State == "stopped" {
updatedApp = app
cmd.ui.Say(terminal.WarningColor("App " + app.Name + " is already stopped"))
return
}
cmd.ui.Say("Stopping 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()),
)
state := "STOPPED"
updatedApp, apiErr := cmd.appRepo.Update(app.Guid, models.AppParams{State: &state})
if apiErr != nil {
err = errors.New(apiErr.Error())
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
return
}
示例12: Run
func (cmd *UnmapRoute) Run(c *cli.Context) {
hostName := c.String("n")
domain := cmd.domainReq.GetDomain()
app := cmd.appReq.GetApplication()
route, apiErr := cmd.routeRepo.FindByHostAndDomain(hostName, domain.Name)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
}
cmd.ui.Say("Removing route %s from app %s in org %s / space %s as %s...",
terminal.EntityNameColor(route.URL()),
terminal.EntityNameColor(app.Name),
terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
terminal.EntityNameColor(cmd.config.SpaceFields().Name),
terminal.EntityNameColor(cmd.config.Username()),
)
apiErr = cmd.routeRepo.Unbind(route.Guid, app.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
示例13: Run
func (cmd *ListDomains) Run(c *cli.Context) {
org := cmd.orgReq.GetOrganizationFields()
cmd.ui.Say("Getting domains in org %s as %s...",
terminal.EntityNameColor(org.Name),
terminal.EntityNameColor(cmd.config.Username()),
)
noDomains := true
table := cmd.ui.Table([]string{"name ", "status"})
apiResponse := cmd.domainRepo.ListSharedDomains(domainsCallback(table, &noDomains))
if apiResponse.IsNotSuccessful() && !apiResponse.IsNotFound() {
cmd.ui.Failed("Failed fetching shared domains.\n%s", apiResponse.Message)
return
}
apiResponse = cmd.domainRepo.ListDomainsForOrg(org.Guid, domainsCallback(table, &noDomains))
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed("Failed fetching private domains.\n%s", apiResponse.Message)
return
}
if noDomains {
cmd.ui.Say("No domains found")
}
}
示例14: Run
func (cmd *UpdateBuildpack) Run(c *cli.Context) {
buildpack := cmd.buildpackReq.GetBuildpack()
cmd.ui.Say("Updating buildpack %s...", terminal.EntityNameColor(buildpack.Name))
updateBuildpack := false
if c.String("i") != "" {
val := c.Int("i")
buildpack.Position = &val
updateBuildpack = true
}
if updateBuildpack {
buildpack, apiResponse := cmd.buildpackRepo.Update(buildpack)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed("Error updating buildpack %s\n%s", terminal.EntityNameColor(buildpack.Name), apiResponse.Message)
return
}
}
dir := c.String("p")
if dir != "" {
apiResponse := cmd.buildpackBitsRepo.UploadBuildpack(buildpack, dir)
if apiResponse.IsNotSuccessful() {
cmd.ui.Failed("Error uploading buildpack %s\n%s", terminal.EntityNameColor(buildpack.Name), apiResponse.Message)
return
}
}
cmd.ui.Ok()
}
示例15: Run
func (cmd *DeleteSpace) Run(c *cli.Context) {
space := cmd.spaceReq.GetSpace()
force := c.Bool("f")
if !force {
response := strings.ToLower(cmd.ui.Ask(
"Really delete space %s and everything associated with it?%s",
term.EntityNameColor(space.Name),
term.PromptColor(">"),
))
if response != "y" && response != "yes" {
return
}
}
cmd.ui.Say("Deleting space %s...", term.EntityNameColor(space.Name))
err := cmd.spaceRepo.Delete(space)
if err != nil {
cmd.ui.Failed(err.Error())
return
}
cmd.ui.Ok()
return
}