Skip to content

Commit

Permalink
Merge pull request #114 from quay/rb/revup/master/quay-lint
Browse files Browse the repository at this point in the history
fix: lint and clean up quay types (PROJQUAY-6620)
  • Loading branch information
openshift-merge-bot[bot] committed Mar 12, 2024
2 parents 223b31a + ed2b682 commit 715a697
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
21 changes: 8 additions & 13 deletions pkg/client/quay/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand All @@ -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

}
4 changes: 0 additions & 4 deletions pkg/client/quay/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
)

func TestIsRobotAccountInPrototypeByRole(t *testing.T) {

cases := []struct {
name string
prototypes []Prototype
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 715a697

Please sign in to comment.