本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/terminal.EntityNameColor函数的典型用法代码示例。如果您正苦于以下问题:Golang EntityNameColor函数的具体用法?Golang EntityNameColor怎么用?Golang EntityNameColor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EntityNameColor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Run
func (cmd *DeleteSpace) Run(c *cli.Context) {
spaceName := c.Args()[0]
if !c.Bool("f") {
if !cmd.ui.ConfirmDelete(T("space"), spaceName) {
return
}
}
cmd.ui.Say(T("Deleting space {{.TargetSpace}} in org {{.TargetOrg}} as {{.CurrentUser}}...",
map[string]interface{}{
"TargetSpace": terminal.EntityNameColor(spaceName),
"TargetOrg": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
space := cmd.spaceReq.GetSpace()
apiErr := cmd.spaceRepo.Delete(space.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
if cmd.config.SpaceFields().Name == spaceName {
cmd.config.SetSpaceFields(models.SpaceFields{})
cmd.ui.Say(T("TIP: No space targeted, use '{{.CfTargetCommand}}' to target a space",
map[string]interface{}{"CfTargetCommand": cf.Name() + " target -s"}))
}
return
}
示例2: Execute
func (cmd *DeleteServiceBroker) Execute(c flags.FlagContext) error {
brokerName := c.Args()[0]
if !c.Bool("f") && !cmd.ui.ConfirmDelete(T("service-broker"), brokerName) {
return nil
}
cmd.ui.Say(T("Deleting service broker {{.Name}} as {{.Username}}...",
map[string]interface{}{
"Name": terminal.EntityNameColor(brokerName),
"Username": terminal.EntityNameColor(cmd.config.Username()),
}))
broker, err := cmd.repo.FindByName(brokerName)
switch err.(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 nil
default:
return err
}
err = cmd.repo.Delete(broker.GUID)
if err != nil {
return err
}
cmd.ui.Ok()
return nil
}
示例3: Execute
func (cmd *UnsetSpaceRole) Execute(c flags.FlagContext) {
spaceName := c.Args()[2]
role := models.UserInputToSpaceRole[c.Args()[3]]
user := cmd.userReq.GetUser()
org := cmd.orgReq.GetOrganization()
space, err := cmd.spaceRepo.FindByNameInOrg(spaceName, org.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Say(T("Removing role {{.Role}} from user {{.TargetUser}} in org {{.TargetOrg}} / space {{.TargetSpace}} as {{.CurrentUser}}...",
map[string]interface{}{
"Role": terminal.EntityNameColor(role),
"TargetUser": terminal.EntityNameColor(user.Username),
"TargetOrg": terminal.EntityNameColor(org.Name),
"TargetSpace": terminal.EntityNameColor(space.Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
if len(user.Guid) > 0 {
err = cmd.userRepo.UnsetSpaceRoleByGuid(user.Guid, space.Guid, role)
} else {
err = cmd.userRepo.UnsetSpaceRoleByUsername(user.Username, space.Guid, role)
}
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
示例4: updateApp
func (cmd *Push) updateApp(app models.Application, appParams models.AppParams) (updatedApp models.Application) {
cmd.ui.Say(T("Updating 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())}))
if appParams.EnvironmentVars != nil {
for key, val := range app.EnvironmentVars {
if _, ok := (*appParams.EnvironmentVars)[key]; !ok {
(*appParams.EnvironmentVars)[key] = val
}
}
}
var apiErr error
updatedApp, apiErr = cmd.appRepo.Update(app.Guid, appParams)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
}
cmd.ui.Ok()
cmd.ui.Say("")
return
}
示例5: Execute
func (cmd *UnsetSpaceRole) Execute(c flags.FlagContext) error {
spaceName := c.Args()[2]
roleStr := c.Args()[3]
role, err := models.RoleFromString(roleStr)
if err != nil {
return err
}
user := cmd.userReq.GetUser()
org := cmd.orgReq.GetOrganization()
space, err := cmd.spaceRepo.FindByNameInOrg(spaceName, org.GUID)
if err != nil {
return err
}
cmd.ui.Say(T("Removing role {{.Role}} from user {{.TargetUser}} in org {{.TargetOrg}} / space {{.TargetSpace}} as {{.CurrentUser}}...",
map[string]interface{}{
"Role": terminal.EntityNameColor(roleStr),
"TargetUser": terminal.EntityNameColor(user.Username),
"TargetOrg": terminal.EntityNameColor(org.Name),
"TargetSpace": terminal.EntityNameColor(space.Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
if len(user.GUID) > 0 {
err = cmd.userRepo.UnsetSpaceRoleByGUID(user.GUID, space.GUID, role)
} else {
err = cmd.userRepo.UnsetSpaceRoleByUsername(user.Username, space.GUID, role)
}
if err != nil {
return err
}
cmd.ui.Ok()
return nil
}
示例6: Run
func (cmd UpdateServiceBroker) Run(c *cli.Context) {
serviceBroker, apiErr := cmd.repo.FindByName(c.Args()[0])
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
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]
apiErr = cmd.repo.Update(serviceBroker)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return
}
cmd.ui.Ok()
}
示例7: Execute
func (cmd Api) Execute(c flags.FlagContext) {
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)}))
cmd.setAPIEndpoint(endpoint, c.Bool("skip-ssl-validation"), cmd.MetaData().Name)
cmd.ui.Ok()
cmd.ui.Say("")
cmd.ui.ShowConfiguration(cmd.config)
}
}
示例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: Execute
func (cmd *DeleteOrphanedRoutes) Execute(c flags.FlagContext) {
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
}
}
cmd.ui.Say(T("Getting routes as {{.Username}} ...\n",
map[string]interface{}{"Username": terminal.EntityNameColor(cmd.config.Username())}))
apiErr := 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.Host + "." + route.Domain.Name)}))
apiErr := cmd.routeRepo.Delete(route.Guid)
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
return false
}
}
return true
})
if apiErr != nil {
cmd.ui.Failed(T("Failed fetching routes.\n{{.Err}}", map[string]interface{}{"Err": apiErr.Error()}))
return
}
cmd.ui.Ok()
}
示例10: 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}))
}
}
示例11: printer
func (cmd *SpaceUsers) printer(org models.Organization, space models.Space, username string) userprint.UserPrinter {
var roles = []models.Role{models.RoleSpaceManager, models.RoleSpaceDeveloper, models.RoleSpaceAuditor}
if cmd.pluginCall {
return userprint.NewSpaceUsersPluginPrinter(
cmd.pluginModel,
cmd.userLister(),
roles,
)
}
cmd.ui.Say(T("Getting users in org {{.TargetOrg}} / space {{.TargetSpace}} as {{.CurrentUser}}",
map[string]interface{}{
"TargetOrg": terminal.EntityNameColor(org.Name),
"TargetSpace": terminal.EntityNameColor(space.Name),
"CurrentUser": terminal.EntityNameColor(username),
}))
return &userprint.SpaceUsersUIPrinter{
UI: cmd.ui,
UserLister: cmd.userLister(),
Roles: roles,
RoleDisplayNames: map[models.Role]string{
models.RoleSpaceManager: T("SPACE MANAGER"),
models.RoleSpaceDeveloper: T("SPACE DEVELOPER"),
models.RoleSpaceAuditor: T("SPACE AUDITOR"),
},
}
}
示例12: Run
func (cmd SetSpaceQuota) Run(context *cli.Context) {
spaceName := context.Args()[0]
quotaName := context.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 {
cmd.ui.Failed(err.Error())
}
if space.SpaceQuotaGuid != "" {
cmd.ui.Failed(T("This space already has an assigned space quota."))
}
quota, err := cmd.quotaRepo.FindByName(quotaName)
if err != nil {
cmd.ui.Failed(err.Error())
}
err = cmd.quotaRepo.AssociateSpaceWithQuota(space.Guid, quota.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}
示例13: Execute
func (cmd *SetOrgRole) Execute(c flags.FlagContext) {
user := cmd.userReq.GetUser()
org := cmd.orgReq.GetOrganization()
role := models.UserInputToOrgRole[c.Args()[2]]
setRolesByUsername, err := cmd.flagRepo.FindByName("set_roles_by_username")
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Say(T("Assigning role {{.Role}} to user {{.TargetUser}} in org {{.TargetOrg}} as {{.CurrentUser}}...",
map[string]interface{}{
"Role": terminal.EntityNameColor(role),
"TargetUser": terminal.EntityNameColor(user.Username),
"TargetOrg": terminal.EntityNameColor(org.Name),
"CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
}))
var apiErr error
if cmd.config.IsMinApiVersion("2.37.0") && setRolesByUsername.Enabled {
apiErr = cmd.userRepo.SetOrgRoleByUsername(user.Username, org.Guid, role)
} else {
apiErr = cmd.userRepo.SetOrgRole(user.Guid, org.Guid, role)
}
if apiErr != nil {
cmd.ui.Failed(apiErr.Error())
}
cmd.ui.Ok()
}
示例14: CreateRoute
func (cmd *CreateRoute) CreateRoute(hostName string, path string, 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)),
"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)
if err != nil {
var findErr error
route, findErr = cmd.routeRepo.Find(hostName, domain, path)
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()
return route, nil
}
示例15: Run
func (cmd *removeFromRunningGroup) 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("Removing 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.RemoveFromRunningSet(securityGroup.Guid)
if err != nil {
cmd.ui.Failed(err.Error())
}
cmd.ui.Ok()
}