From ed2b6829f4cd8552d0c3a33bf9fe1f68e19d0ba9 Mon Sep 17 00:00:00 2001 From: Ross Bryan Date: Fri, 1 Mar 2024 23:27:47 -0500 Subject: [PATCH] fix: lint and clean up quay types (PROJQUAY-6620) Topic: quay-lint Signed-off-by: Ross Bryan --- pkg/client/quay/types.go | 21 ++++++++------------- pkg/client/quay/types_test.go | 4 ---- 2 files changed, 8 insertions(+), 17 deletions(-) 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) }