本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/terminal.EntityNameColor函數的典型用法代碼示例。如果您正苦於以下問題:Golang EntityNameColor函數的具體用法?Golang EntityNameColor怎麽用?Golang EntityNameColor使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EntityNameColor函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Execute
func (cmd *SetSpaceQuota) Execute(c flags.FlagContext) error {
spaceName := c.Args()[0]
quotaName := c.Args()[1]
cmd.ui.Say(T("Assigning space quota {{.QuotaName}} to space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
"QuotaName": terminal.EntityNameColor(quotaName),
"SpaceName": terminal.EntityNameColor(spaceName),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
space, err := cmd.spaceRepo.FindByName(spaceName)
if err != nil {
return err
}
if space.SpaceQuotaGUID != "" {
return errors.New(T("This space already has an assigned space quota."))
}
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
return err
}
err = cmd.quotaRepo.AssociateSpaceWithQuota(space.GUID, quota.GUID)
if err != nil {
return err
}
cmd.ui.Ok()
return nil
}
示例2: Execute
func (cmd *ListStacks) Execute(c flags.FlagContext) error {
cmd.ui.Say(T("Getting stacks in org {{.OrganizationName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{"OrganizationName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
stacks, err := cmd.stacksRepo.FindAll()
if err != nil {
return err
}
cmd.ui.Ok()
cmd.ui.Say("")
table := cmd.ui.Table([]string{T("name"), T("description")})
for _, stack := range stacks {
table.Add(stack.Name, stack.Description)
}
err = table.Print()
if err != nil {
return err
}
return nil
}
示例3: printUpdatingServiceInstanceMessage
func (cmd *UpdateService) printUpdatingServiceInstanceMessage(serviceInstanceName string) {
cmd.ui.Say(T("Updating service instance {{.ServiceName}} as {{.UserName}}...",
map[string]interface{}{
"ServiceName": terminal.EntityNameColor(serviceInstanceName),
"UserName": terminal.EntityNameColor(cmd.config.Username()),
}))
}
示例4: Execute
func (cmd *UnsetSpaceQuota) Execute(c flags.FlagContext) error {
spaceName := c.Args()[0]
quotaName := c.Args()[1]
space, err := cmd.spaceRepo.FindByName(spaceName)
if err != nil {
return err
}
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
return err
}
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())}))
err = cmd.quotaRepo.UnassignQuotaFromSpace(space.GUID, quota.GUID)
if err != nil {
return err
}
cmd.ui.Ok()
return nil
}
示例5: Execute
func (cmd *UpdateSecurityGroup) Execute(context flags.FlagContext) error {
name := context.Args()[0]
securityGroup, err := cmd.securityGroupRepo.Read(name)
if err != nil {
return err
}
pathToJSONFile := context.Args()[1]
rules, err := json.ParseJSONArray(pathToJSONFile)
if err != nil {
return err
}
cmd.ui.Say(T("Updating security group {{.security_group}} as {{.username}}",
map[string]interface{}{
"security_group": terminal.EntityNameColor(name),
"username": terminal.EntityNameColor(cmd.configRepo.Username()),
}))
err = cmd.securityGroupRepo.Update(securityGroup.GUID, rules)
if err != nil {
return err
}
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."))
return nil
}
示例6: Execute
func (cmd *RenameService) Execute(c flags.FlagContext) error {
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.ServiceInstanceNameTaken {
return errors.New(T("{{.ErrorDescription}}\nTIP: Use '{{.CFServicesCommand}}' to view all services in this org and space.",
map[string]interface{}{
"ErrorDescription": httpError.Error(),
"CFServicesCommand": cf.Name + " " + "services",
}))
}
return err
}
cmd.ui.Ok()
return nil
}
示例7: Execute
func (cmd API) Execute(c flags.FlagContext) error {
if c.Bool("unset") {
cmd.ui.Say(T("Unsetting api endpoint..."))
cmd.config.SetAPIEndpoint("")
cmd.ui.Ok()
cmd.ui.Say(T("\nNo api endpoint set."))
} else if len(c.Args()) == 0 {
if cmd.config.APIEndpoint() == "" {
cmd.ui.Say(fmt.Sprintf(T("No api endpoint set. Use '{{.Name}}' to set an endpoint",
map[string]interface{}{"Name": terminal.CommandColor(cf.Name + " api")})))
} else {
cmd.ui.Say(T("API endpoint: {{.APIEndpoint}} (API version: {{.APIVersion}})",
map[string]interface{}{"APIEndpoint": terminal.EntityNameColor(cmd.config.APIEndpoint()),
"APIVersion": terminal.EntityNameColor(cmd.config.APIVersion())}))
}
} else {
endpoint := c.Args()[0]
cmd.ui.Say(T("Setting api endpoint to {{.Endpoint}}...",
map[string]interface{}{"Endpoint": terminal.EntityNameColor(endpoint)}))
err := cmd.setAPIEndpoint(endpoint, c.Bool("skip-ssl-validation"), cmd.MetaData().Name)
if err != nil {
return err
}
cmd.ui.Ok()
cmd.ui.Say("")
cmd.ui.ShowConfiguration(cmd.config)
}
return nil
}
示例8: Execute
func (cmd *RestartAppInstance) Execute(fc flags.FlagContext) error {
app := cmd.appReq.GetApplication()
instance, err := strconv.Atoi(fc.Args()[1])
if err != nil {
return errors.New(T("Instance must be a non-negative integer"))
}
cmd.ui.Say(T("Restarting instance {{.Instance}} of application {{.AppName}} as {{.Username}}",
map[string]interface{}{
"Instance": instance,
"AppName": terminal.EntityNameColor(app.Name),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
err = cmd.appInstancesRepo.DeleteInstance(app.GUID, instance)
if err != nil {
return err
}
cmd.ui.Ok()
cmd.ui.Say("")
return nil
}
示例9: CreateRoute
func (cmd *CreateRoute) CreateRoute(hostName string, path string, port int, randomPort bool, domain models.DomainFields, space models.SpaceFields) (models.Route, error) {
cmd.ui.Say(T("Creating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"URL": terminal.EntityNameColor(domain.URLForHostAndPath(hostName, path, port)),
"OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(space.Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
route, err := cmd.routeRepo.CreateInSpace(hostName, path, domain.GUID, space.GUID, port, randomPort)
if err != nil {
var findErr error
route, findErr = cmd.routeRepo.Find(hostName, domain, path, port)
if findErr != nil {
return models.Route{}, err
}
if route.Space.GUID != space.GUID || route.Domain.GUID != domain.GUID {
return models.Route{}, err
}
cmd.ui.Ok()
cmd.ui.Warn(T("Route {{.URL}} already exists",
map[string]interface{}{"URL": route.URL()}))
return route, nil
}
cmd.ui.Ok()
if randomPort {
cmd.ui.Say("Route %s:%d has been created", route.Domain.Name, route.Port)
}
return route, nil
}
示例10: BindRoute
func (routeActor routeActor) BindRoute(app models.Application, route models.Route) error {
if !app.HasRoute(route) {
routeActor.ui.Say(T(
"Binding {{.URL}} to {{.AppName}}...",
map[string]interface{}{
"URL": terminal.EntityNameColor(route.URL()),
"AppName": terminal.EntityNameColor(app.Name),
}),
)
err := routeActor.routeRepo.Bind(route.GUID, app.GUID)
switch err := err.(type) {
case nil:
routeActor.ui.Ok()
routeActor.ui.Say("")
return nil
case errors.HTTPError:
if err.ErrorCode() == errors.InvalidRelation {
return errors.New(T(
"The route {{.URL}} is already in use.\nTIP: Change the hostname with -n HOSTNAME or use --random-route to generate a new route and then push again.",
map[string]interface{}{
"URL": route.URL(),
}),
)
}
}
return err
}
return nil
}
示例11: Execute
func (cmd *CreateUser) Execute(c flags.FlagContext) error {
username := c.Args()[0]
password := c.Args()[1]
cmd.ui.Say(T("Creating user {{.TargetUser}}...",
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:
return errors.New(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}))
return nil
}
示例12: Execute
func (cmd *MapRoute) Execute(c flags.FlagContext) error {
hostName := c.String("n")
path := c.String("path")
domain := cmd.domainReq.GetDomain()
app := cmd.appReq.GetApplication()
port := c.Int("port")
randomPort := c.Bool("random-port")
route, err := cmd.routeCreator.CreateRoute(hostName, path, port, randomPort, domain, cmd.config.SpaceFields())
if err != nil {
return errors.New(T("Error resolving route:\n{{.Err}}", map[string]interface{}{"Err": err.Error()}))
}
cmd.ui.Say(T("Adding route {{.URL}} to app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{
"URL": terminal.EntityNameColor(route.URL()),
"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.routeRepo.Bind(route.GUID, app.GUID)
if err != nil {
return err
}
cmd.ui.Ok()
return nil
}
示例13: findSpaceGUID
func (cmd *CopySource) findSpaceGUID(targetOrg, targetSpace string) (string, error) {
org, err := cmd.orgRepo.FindByName(targetOrg)
if err != nil {
return "", err
}
var space models.SpaceFields
var foundSpace bool
for _, s := range org.Spaces {
if s.Name == targetSpace {
space = s
foundSpace = true
}
}
if !foundSpace {
return "", fmt.Errorf(T("Could not find space {{.Space}} in organization {{.Org}}",
map[string]interface{}{
"Space": terminal.EntityNameColor(targetSpace),
"Org": terminal.EntityNameColor(targetOrg),
},
))
}
return space.GUID, nil
}
示例14: Execute
func (cmd *ListStack) Execute(c flags.FlagContext) error {
stackName := c.Args()[0]
stack, err := cmd.stacksRepo.FindByName(stackName)
if c.Bool("guid") {
cmd.ui.Say(stack.GUID)
} else {
if err != nil {
return err
}
cmd.ui.Say(T("Getting stack '{{.Stack}}' in org {{.OrganizationName}} / space {{.SpaceName}} as {{.Username}}...",
map[string]interface{}{"Stack": stackName,
"OrganizationName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
"Username": terminal.EntityNameColor(cmd.config.Username())}))
cmd.ui.Ok()
cmd.ui.Say("")
table := cmd.ui.Table([]string{T("name"), T("description")})
table.Add(stack.Name, stack.Description)
err = table.Print()
if err != nil {
return err
}
}
return nil
}
示例15: Execute
func (cmd *DeleteOrphanedRoutes) Execute(c flags.FlagContext) error {
force := c.Bool("f")
if !force {
response := cmd.ui.Confirm(T("Really delete orphaned routes?{{.Prompt}}",
map[string]interface{}{"Prompt": terminal.PromptColor(">")}))
if !response {
return nil
}
}
cmd.ui.Say(T("Getting routes as {{.Username}} ...\n",
map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())}))
err := cmd.routeRepo.ListRoutes(func(route models.Route) bool {
if len(route.Apps) == 0 {
cmd.ui.Say(T("Deleting route {{.Route}}...",
map[string]interface{}{"Route": terminal.EntityNameColor(route.URL())}))
apiErr := cmd.routeRepo.Delete(route.GUID)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return false
}
}
return true
})
if err != nil {
return errors.New(T("Failed fetching routes.\n{{.Err}}", map[string]interface{}{"Err": err.Error()}))
}
cmd.ui.Ok()
return nil
}