Standardize static group -> group naming (#236)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-07-31 17:46:04 -04:00
1 parent 3204e54dc2
commit 322b13ae98
6 files changed
+63 -67

No files matched your search

+1 -1
View File
@@ -80,7 +80,7 @@ func (g *Group) GetScope(ctx context.Context, r db.Reader) (*Scope, error) {
}
// ResourceType returns the type of the Group.
func (*Group) ResourceType() resource.Type { return resource.StaticGroup }
func (*Group) ResourceType() resource.Type { return resource.Group }
// Actions returns the available actions for Group
func (*Group) Actions() map[string]action.Type {
+1 -1
View File
@@ -438,7 +438,7 @@ func TestGroup_ResourceType(t *testing.T) {
assert := assert.New(t)
r := &Group{}
ty := r.ResourceType()
assert.Equal(ty, resource.StaticGroup)
assert.Equal(ty, resource.Group)
}
func TestGroup_GetScope(t *testing.T) {
+1 -1
View File
@@ -299,7 +299,7 @@ func (g Grant) validateType() error {
case resource.Unknown,
resource.All,
resource.Role,
resource.StaticGroup,
resource.Group,
resource.User,
resource.AuthMethod,
resource.HostCatalog,
+6 -6
View File
@@ -160,10 +160,10 @@ func Test_MarshallingAndCloning(t *testing.T) {
scope: Scope{
Type: scope.Project,
},
typ: resource.StaticGroup,
typ: resource.Group,
},
jsonOutput: `{"id":"baz","type":"static-group"}`,
canonicalString: `id=baz;type=static-group`,
jsonOutput: `{"id":"baz","type":"group"}`,
canonicalString: `id=baz;type=group`,
},
{
name: "everything",
@@ -172,15 +172,15 @@ func Test_MarshallingAndCloning(t *testing.T) {
scope: Scope{
Type: scope.Project,
},
typ: resource.StaticGroup,
typ: resource.Group,
actions: map[action.Type]bool{
action.Create: true,
action.Read: true,
},
actionsBeingParsed: []string{"create", "read"},
},
jsonOutput: `{"actions":["create","read"],"id":"baz","type":"static-group"}`,
canonicalString: `id=baz;type=static-group;actions=create,read`,
jsonOutput: `{"actions":["create","read"],"id":"baz","type":"group"}`,
canonicalString: `id=baz;type=group;actions=create,read`,
},
}
+46 -50
View File
@@ -4,30 +4,27 @@ package resource
type Type int
const (
Unknown Type = 0
Scope Type = 1
User Type = 2
StaticGroup Type = 3
Role Type = 4
Org Type = 5
StaticGroupMember Type = 6
StaticGroupUserMember Type = 7
AssignedRole Type = 8
AssignedUserRole Type = 9
AssignedStaticGroupRole Type = 10
RoleGrant Type = 11
AuthMethod Type = 12
Project Type = 13
All Type = 14
HostCatalog Type = 15
HostSet Type = 16
Host Type = 17
Target Type = 18
Global Type = 19
// TODO: remove this after demo
Group Type = 20
AuthToken Type = 21
Unknown Type = 0
Scope Type = 1
User Type = 2
Group Type = 3
Role Type = 4
Org Type = 5
GroupMember Type = 6
GroupUserMember Type = 7
AssignedRole Type = 8
AssignedUserRole Type = 9
AssignedGroupRole Type = 10
RoleGrant Type = 11
AuthMethod Type = 12
Project Type = 13
All Type = 14
HostCatalog Type = 15
HostSet Type = 16
Host Type = 17
Target Type = 18
Global Type = 19
AuthToken Type = 20
)
func (r Type) String() string {
@@ -35,14 +32,14 @@ func (r Type) String() string {
"unknown",
"scope",
"user",
"static-group",
"group",
"role",
"org",
"static-group-member",
"static-group-user-member",
"group-member",
"group-user-member",
"assigned-role",
"assigned-user-role",
"assigned-static-group-role",
"assigned-group-role",
"role-grant",
"auth-method",
"project",
@@ -52,31 +49,30 @@ func (r Type) String() string {
"host",
"target",
"global",
"group",
"auth-token",
}[r]
}
var Map = map[string]Type{
Scope.String(): Scope,
User.String(): User,
StaticGroup.String(): StaticGroup,
Role.String(): Role,
Org.String(): Org,
StaticGroupMember.String(): StaticGroupMember,
StaticGroupUserMember.String(): StaticGroupUserMember,
AssignedRole.String(): AssignedRole,
AssignedUserRole.String(): AssignedUserRole,
AssignedStaticGroupRole.String(): AssignedStaticGroupRole,
RoleGrant.String(): RoleGrant,
AuthMethod.String(): AuthMethod,
Project.String(): Project,
All.String(): All,
HostCatalog.String(): HostCatalog,
HostSet.String(): HostSet,
Host.String(): Host,
Target.String(): Target,
Global.String(): Global,
Group.String(): Group,
AuthToken.String(): AuthToken,
Scope.String(): Scope,
User.String(): User,
Group.String(): Group,
Role.String(): Role,
Org.String(): Org,
GroupMember.String(): GroupMember,
GroupUserMember.String(): GroupUserMember,
AssignedRole.String(): AssignedRole,
AssignedUserRole.String(): AssignedUserRole,
AssignedGroupRole.String(): AssignedGroupRole,
RoleGrant.String(): RoleGrant,
AuthMethod.String(): AuthMethod,
Project.String(): Project,
All.String(): All,
HostCatalog.String(): HostCatalog,
HostSet.String(): HostSet,
Host.String(): Host,
Target.String(): Target,
Global.String(): Global,
Group.String(): Group,
AuthToken.String(): AuthToken,
}
+8 -8
View File
@@ -25,8 +25,8 @@ func Test_Resource(t *testing.T) {
want: User,
},
{
typeString: "static-group",
want: StaticGroup,
typeString: "group",
want: Group,
},
{
typeString: "role",
@@ -37,12 +37,12 @@ func Test_Resource(t *testing.T) {
want: Org,
},
{
typeString: "static-group-member",
want: StaticGroupMember,
typeString: "group-member",
want: GroupMember,
},
{
typeString: "static-group-user-member",
want: StaticGroupUserMember,
typeString: "group-user-member",
want: GroupUserMember,
},
{
typeString: "assigned-role",
@@ -53,8 +53,8 @@ func Test_Resource(t *testing.T) {
want: AssignedUserRole,
},
{
typeString: "assigned-static-group-role",
want: AssignedStaticGroupRole,
typeString: "assigned-group-role",
want: AssignedGroupRole,
},
{
typeString: "role-grant",