MCPcopy
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/user/unset_org_role.go:73–102  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

71}
72
73func (cmd *UnsetOrgRole) Execute(c flags.FlagContext) error {
74 user := cmd.userReq.GetUser()
75 org := cmd.orgReq.GetOrganization()
76 roleStr := c.Args()[2]
77 role, err := models.RoleFromString(roleStr)
78 if err != nil {
79 return err
80 }
81
82 cmd.ui.Say(T("Removing role {{.Role}} from user {{.TargetUser}} in org {{.TargetOrg}} as {{.CurrentUser}}...",
83 map[string]interface{}{
84 "Role": terminal.EntityNameColor(roleStr),
85 "TargetUser": terminal.EntityNameColor(c.Args()[0]),
86 "TargetOrg": terminal.EntityNameColor(c.Args()[1]),
87 "CurrentUser": terminal.EntityNameColor(cmd.config.Username()),
88 }))
89
90 if len(user.GUID) > 0 {
91 err = cmd.userRepo.UnsetOrgRoleByGUID(user.GUID, org.GUID, role)
92 } else {
93 err = cmd.userRepo.UnsetOrgRoleByUsername(user.Username, org.GUID, role)
94 }
95
96 if err != nil {
97 return err
98 }
99
100 cmd.ui.Ok()
101 return nil
102}

Callers

nothing calls this directly

Calls 10

RoleFromStringFunction · 0.92
EntityNameColorFunction · 0.92
GetUserMethod · 0.65
GetOrganizationMethod · 0.65
ArgsMethod · 0.65
SayMethod · 0.65
UsernameMethod · 0.65
UnsetOrgRoleByGUIDMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected