本文整理匯總了Golang中github.com/nttlabs/cli/cf/terminal.EntityNameColor函數的典型用法代碼示例。如果您正苦於以下問題:Golang EntityNameColor函數的具體用法?Golang EntityNameColor怎麽用?Golang EntityNameColor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EntityNameColor函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (cmd *unbindFromRunningGroup) Run(context *cli.Context) {
name := context.Args()[0]
securityGroup, err := cmd.securityGroupRepo.Read(name)
switch (err).(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("Security group {{.security_group}} {{.error_message}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(name),
"error_message": terminal.WarningColor(T("does not exist.")),
}))
return
default:
cmd.ui.Failed(err.Error())
}
cmd.ui.Say(T("Unbinding security group {{.security_group}} from defaults for running as {{.username}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(securityGroup.Name),
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
err = cmd.runningGroupRepo.UnbindFromRunningSet(securityGroup.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
cmd.ui.Say("\n\n")
cmd.ui.Say(T("TIP: Changes will not apply to existing running applications until they are restarted."))
}
示例2: Run
func (cmd CreateUser) Run(c *cli.Context) {
username := c.Args()[0]
password := c.Args()[1]
cmd.ui.Say(T("Creating user {{.TargetUser}} as {{.CurrentUser}}...",
map[string]interface{}{
"TargetUser": terminal.EntityNameColor(username),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
err := cmd.userRepo.Create(username, password)
switch err.(type) {
case nil:
case *errors.ModelAlreadyExistsError:
cmd.ui.Warn("%s", err.Error())
default:
cmd.ui.Failed(T("Error creating user {{.TargetUser}}.\n{{.Error}}",
map[string]interface{}{
"TargetUser": terminal.EntityNameColor(username),
"Error": err.Error(),
}))
}
cmd.ui.Ok()
cmd.ui.Say(T("\nTIP: Assign roles with '{{.CurrentUser}} set-org-role' and '{{.CurrentUser}} set-space-role'", map[string]interface{}{"CurrentUser": cf.Name()}))
}
示例3: Run
func (cmd *UnsetEnv) Run(c *cli.Context) {
varName := c.Args()[1]
app := cmd.appReq.GetApplication()
cmd.ui.Say(T("Removing env variable {{.VarName}} from app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"VarName": terminal.EntityNameColor(varName),
"AppName": terminal.EntityNameColor(app.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username())}))
envParams := app.EnvironmentVars
if _, ok := envParams[varName]; !ok {
cmd.ui.Ok()
cmd.ui.Warn(T("Env variable {{.VarName}} was not set.", map[string]interface{}{"VarName": varName}))
return
}
delete(envParams, varName)
_, apiErr := cmd.appRepo.Update(app.Guid, models.AppParams{EnvironmentVars: &envParams})
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
cmd.ui.Say(T("TIP: Use '{{.Command}}' to ensure your env variable changes take effect",
map[string]interface{}{"Command": terminal.CommandColor(cf.Name() + " restage")}))
}
示例4: Run
func (cmd *UnbindService) Run(c *cli.Context) {
app := cmd.appReq.GetApplication()
instance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say(T("Unbinding app {{.AppName}} from service {{.ServiceName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"AppName": terminal.EntityNameColor(app.Name),
"ServiceName": terminal.EntityNameColor(instance.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
found, apiErr := cmd.serviceBindingRepo.Delete(instance, app.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
if !found {
cmd.ui.Warn(T("Binding between {{.InstanceName}} and {{.AppName}} did not exist",
map[string]interface{}{"InstanceName": instance.Name, "AppName": app.Name}))
}
}
示例5: Run
func (cmd *ShowService) Run(c *cli.Context) {
serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say("")
cmd.ui.Say(T("Service instance: {{.ServiceName}}", map[string]interface{}{"ServiceName": terminal.EntityNameColor(serviceInstance.Name)}))
if serviceInstance.IsUserProvided() {
cmd.ui.Say(T("Service: {{.ServiceDescription}}",
map[string]interface{}{
"ServiceDescription": terminal.EntityNameColor(T("user-provided")),
}))
} else {
cmd.ui.Say(T("Service: {{.ServiceDescription}}",
map[string]interface{}{
"ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Label),
}))
cmd.ui.Say(T("Plan: {{.ServicePlanName}}",
map[string]interface{}{
"ServicePlanName": terminal.EntityNameColor(serviceInstance.ServicePlan.Name),
}))
cmd.ui.Say(T("Description: {{.ServiceDescription}}", map[string]interface{}{"ServiceDescription": terminal.EntityNameColor(serviceInstance.ServiceOffering.Description)}))
cmd.ui.Say(T("Documentation url: {{.URL}}",
map[string]interface{}{
"URL": terminal.EntityNameColor(serviceInstance.ServiceOffering.DocumentationUrl),
}))
}
}
示例6: Run
func (cmd *UpdateService) Run(c *cli.Context) {
serviceInstanceName := c.Args()[0]
serviceInstance, err := cmd.serviceRepo.FindInstanceByName(serviceInstanceName)
if err != nil {
cmd.ui.Failed(err.Error())
return
}
planName := c.String("p")
if planName != "" {
cmd.ui.Say(T("Updating service instance {{.ServiceName}} as {{.UserName}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstanceName),
"UserName": terminal.EntityNameColor(cmd.config.Username()),
}))
err := cmd.updateServiceWithPlan(serviceInstance, planName)
switch err.(type) {
case nil:
cmd.ui.Ok()
default:
cmd.ui.Failed(err.Error())
}
} else {
cmd.ui.Ok()
cmd.ui.Say(T("No changes were made"))
}
}
示例7: Run
func (cmd UnsetSpaceQuota) Run(c *cli.Context) {
spaceName := c.Args()[0]
quotaName := c.Args()[1]
space, apiErr := cmd.spaceRepo.FindByName(spaceName)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
quota, apiErr := cmd.quotaRepo.FindByName(quotaName)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Say(T("Unassigning space quota {{.QuotaName}} from space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"QuotaName": terminal.EntityNameColor(quota.Name),
"SpaceName": terminal.EntityNameColor(space.Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
apiErr = cmd.quotaRepo.UnassignQuotaFromSpace(space.Guid, quota.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
示例8: Run
func (cmd *RenameService) Run(c *cli.Context) {
newName := c.Args()[1]
serviceInstance := cmd.serviceInstanceReq.GetServiceInstance()
cmd.ui.Say(T("Renaming service {{.ServiceName}} to {{.NewServiceName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstance.Name),
"NewServiceName": terminal.EntityNameColor(newName),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
err := cmd.serviceRepo.RenameService(serviceInstance, newName)
if err != nil {
if httpError, ok := err.(errors.HttpError); ok && httpError.ErrorCode() == errors.SERVICE_INSTANCE_NAME_TAKEN {
cmd.ui.Failed(T("{{.ErrorDescription}}\nTIP: Use '{{.CFServicesCommand}}' to view all services in this org and space.",
map[string]interface{}{
"ErrorDescription": httpError.Error(),
"CFServicesCommand": cf.Name() + " " + "services",
}))
} else {
cmd.ui.Failed(err.Error())
}
}
cmd.ui.Ok()
}
示例9: bindAppToServices
func (cmd *Push) bindAppToServices(services []string, app models.Application) {
for _, serviceName := range services {
serviceInstance, err := cmd.serviceRepo.FindInstanceByName(serviceName)
if err != nil {
cmd.ui.Failed(T("Could not find service {{.ServiceName}} to bind to {{.AppName}}",
map[string]interface{}{"ServiceName": serviceName, "AppName": app.Name}))
return
}
cmd.ui.Say(T("Binding service {{.ServiceName}} to app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstance.Name),
"AppName": terminal.EntityNameColor(app.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
err = cmd.serviceBinder.BindApplication(app, serviceInstance)
switch httpErr := err.(type) {
case errors.HttpError:
if httpErr.ErrorCode() == errors.APP_ALREADY_BOUND {
err = nil
}
}
if err != nil {
cmd.ui.Failed(T("Could not bind to service {{.ServiceName}}\nError: {{.Err}}",
map[string]interface{}{"ServiceName": serviceName, "Err": err.Error()}))
}
cmd.ui.Ok()
}
}
示例10: Run
func (cmd ListSpaces) Run(c *cli.Context) {
cmd.ui.Say(T("Getting spaces in org {{.TargetOrgName}} as {{.CurrentUser}}...\n",
map[string]interface{}{
"TargetOrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
foundSpaces := false
table := cmd.ui.Table([]string{T("name")})
apiErr := cmd.spaceRepo.ListSpaces(func(space models.Space) bool {
table.Add(space.Name)
foundSpaces = true
return true
})
table.Print()
if apiErr != nil {
cmd.ui.Failed(T("Failed fetching spaces.\n{{.ErrorDescription}}",
map[string]interface{}{
"ErrorDescription": apiErr.Error(),
}))
return
}
if !foundSpaces {
cmd.ui.Say(T("No spaces found"))
}
}
示例11: Run
func (cmd DeleteUser) Run(c *cli.Context) {
username := c.Args()[0]
force := c.Bool("f")
if !force && !cmd.ui.ConfirmDelete(T("user"), username) {
return
}
cmd.ui.Say(T("Deleting user {{.TargetUser}} as {{.CurrentUser}}...",
map[string]interface{}{
"TargetUser": terminal.EntityNameColor(username),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
user, apiErr := cmd.userRepo.FindByUsername(username)
switch apiErr.(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("User {{.TargetUser}} does not exist.", map[string]interface{}{"TargetUser": username}))
return
default:
cmd.ui.Failed(apiErr.Error())
return
}
apiErr = cmd.userRepo.Delete(user.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
示例12: Run
func (cmd CreateService) Run(c *cli.Context) {
serviceName := c.Args()[0]
planName := c.Args()[1]
serviceInstanceName := c.Args()[2]
cmd.ui.Say(T("Creating service {{.ServiceName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstanceName),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
err := cmd.CreateService(serviceName, planName, serviceInstanceName)
switch err.(type) {
case nil:
cmd.ui.Ok()
case *errors.ModelAlreadyExistsError:
cmd.ui.Ok()
cmd.ui.Warn(err.Error())
default:
cmd.ui.Failed(err.Error())
}
}
示例13: Run
func (cmd CreateOrg) Run(c *cli.Context) {
name := c.Args()[0]
cmd.ui.Say(T("Creating org {{.OrgName}} as {{.Username}}...",
map[string]interface{}{
"OrgName": terminal.EntityNameColor(name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
org := models.Organization{OrganizationFields: models.OrganizationFields{Name: name}}
quotaName := c.String("q")
if quotaName != "" {
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
cmd.ui.Failed(err.Error())
}
org.QuotaDefinition.Guid = quota.Guid
}
err := cmd.orgRepo.Create(org)
if err != nil {
if apiErr, ok := err.(errors.HttpError); ok && apiErr.ErrorCode() == errors.ORG_EXISTS {
cmd.ui.Ok()
cmd.ui.Warn(T("Org {{.OrgName}} already exists",
map[string]interface{}{"OrgName": name}))
return
} else {
cmd.ui.Failed(err.Error())
}
}
cmd.ui.Ok()
cmd.ui.Say(T("\nTIP: Use '{{.Command}}' to target new org",
map[string]interface{}{"Command": terminal.CommandColor(cf.Name() + " target -o " + name)}))
}
示例14: Run
func (cmd DeleteServiceBroker) Run(c *cli.Context) {
brokerName := c.Args()[0]
if !c.Bool("f") && !cmd.ui.ConfirmDelete(T("service-broker"), brokerName) {
return
}
cmd.ui.Say(T("Deleting service broker {{.Name}} as {{.Username}}...",
map[string]interface{}{
"Name": terminal.EntityNameColor(brokerName),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
broker, apiErr := cmd.repo.FindByName(brokerName)
switch apiErr.(type) {
case nil:
case *errors.ModelNotFoundError:
cmd.ui.Ok()
cmd.ui.Warn(T("Service Broker {{.Name}} does not exist.", map[string]interface{}{"Name": brokerName}))
return
default:
cmd.ui.Failed(apiErr.Error())
return
}
apiErr = cmd.repo.Delete(broker.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
return
}
示例15: Run
func (cmd *Env) Run(c *cli.Context) {
app, err := cmd.appRepo.Read(c.Args()[0])
if notFound, ok := err.(*errors.ModelNotFoundError); ok {
cmd.ui.Failed(notFound.Error())
}
cmd.ui.Say(T("Getting env variables for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"AppName": terminal.EntityNameColor(app.Name),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
env, err := cmd.appRepo.ReadEnv(app.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
cmd.ui.Say("")
cmd.displaySystemiAndAppProvidedEnvironment(env.System, env.Application)
cmd.ui.Say("")
cmd.displayUserProvidedEnvironment(env.Environment)
cmd.ui.Say("")
cmd.displayRunningEnvironment(env.Running)
cmd.ui.Say("")
cmd.displayStagingEnvironment(env.Staging)
cmd.ui.Say("")
}