diff --git a/pkg/client/quay/types.go b/pkg/client/quay/types.go index 5006f53f..baee35b0 100644 --- a/pkg/client/quay/types.go +++ b/pkg/client/quay/types.go @@ -42,6 +42,13 @@ type Prototype struct { Delegate PrototypeDelegate `json:"delegate"` } +type PrototypeDelegate struct { + Kind string `json:"kind"` + Name string `json:"name"` + Robot bool `json:"is_robot"` + OrgMember bool `json:"is_org_member"` +} + type Repository struct { TrustEnabled bool `json:"trust_enabled"` Description string `json:"description"` @@ -74,13 +81,6 @@ type RepositoryRequest struct { Kind string `json:"repo_kind"` } -type PrototypeDelegate struct { - Kind string `json:"kind"` - Name string `json:"name"` - Robot bool `json:"is_robot"` - OrgMember bool `json:"is_org_member"` -} - // StringValue represents an object containing a single string type StringValue struct { Value string @@ -91,15 +91,10 @@ type QuayApiError struct { } func IsRobotAccountInPrototypeByRole(prototypes []Prototype, robotAccount string, role string) bool { - for _, prototype := range prototypes { - - if prototype.Role == role && prototype.Delegate.Robot == true && prototype.Delegate.Name == robotAccount { + if prototype.Role == role && prototype.Delegate.Robot && prototype.Delegate.Name == robotAccount { return true } - } - return false - } diff --git a/pkg/client/quay/types_test.go b/pkg/client/quay/types_test.go index 6ee60b8f..bee0b8a6 100644 --- a/pkg/client/quay/types_test.go +++ b/pkg/client/quay/types_test.go @@ -5,7 +5,6 @@ import ( ) func TestIsRobotAccountInPrototypeByRole(t *testing.T) { - cases := []struct { name string prototypes []Prototype @@ -64,11 +63,8 @@ func TestIsRobotAccountInPrototypeByRole(t *testing.T) { } for i, c := range cases { - t.Run(c.name, func(t *testing.T) { - result := IsRobotAccountInPrototypeByRole(c.prototypes, c.robotAccount, c.role) - if c.expected != result { t.Errorf("Test case %d did not match\nExpected: %#v\nActual: %#v", i, c.expected, result) }