MCPcopy Index your code
hub / github.com/coder/coder / String

Method String

coderd/rbac/object.go:46–62  ·  view source on GitHub ↗

String is not perfect, but decent enough for human display

()

Source from the content-addressed store, hash-verified

44
45// String is not perfect, but decent enough for human display
46func (z Object) String() string {
47 var parts []string
48 if z.OrgID != "" {
49 parts = append(parts, fmt.Sprintf("org:%s", cstrings.Truncate(z.OrgID, 4)))
50 }
51 if z.Owner != "" {
52 parts = append(parts, fmt.Sprintf("owner:%s", cstrings.Truncate(z.Owner, 4)))
53 }
54 parts = append(parts, z.Type)
55 if z.ID != "" {
56 parts = append(parts, fmt.Sprintf("id:%s", cstrings.Truncate(z.ID, 4)))
57 }
58 if len(z.ACLGroupList) > 0 || len(z.ACLUserList) > 0 {
59 parts = append(parts, fmt.Sprintf("acl:%d", len(z.ACLUserList)+len(z.ACLGroupList)))
60 }
61 return strings.Join(parts, ".")
62}
63
64// ValidAction checks if the action is valid for the given object type.
65func (z Object) ValidAction(action policy.Action) error {

Calls

no outgoing calls