Skip to content

Commit

Permalink
Look for sha is better attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mmulholla committed Jun 6, 2022
1 parent f53d219 commit 24b4249
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 3 additions & 7 deletions pkg/chartverifier/pyxis/pyxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ type RegistriesBody struct {

type PyxisRegistry struct {
Id string `json:"_id"`
ParsedData ImageData `json:"parsed_data"`
ImageId string `json:"image_id"`
Repositories []RegistryRepository `json:"repositories"`
}

type ImageData struct {
Digest string `json:"docker_image_digest"`
}

type RegistryRepository struct {
Registry string `json:"registry"`
Repository string `json:"repository"`
Expand Down Expand Up @@ -190,13 +186,13 @@ Loops:
found = false
for _, reg := range registriesBody.PyxisRegistries {
if len(imageRef.Sha) > 0 {
if imageRef.Sha == reg.ParsedData.Digest {
if imageRef.Sha == reg.ImageId {
utils.LogInfo(fmt.Sprintf("sha found: %s", imageRef.Sha))
found = true
err = nil
continue Loops
} else {
shas = append(shas, reg.ParsedData.Digest)
shas = append(shas, reg.ImageId)
}
} else {
for _, repo := range reg.Repositories {
Expand Down
2 changes: 2 additions & 0 deletions pkg/chartverifier/pyxis/pyxis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ func Test_checkImageInRegistry(t *testing.T) {
{description: "Test cpopen/ibmcloud-object-storage-driver respository and sha found.", imageRef: ImageReference{Repository: "cpopen/ibmcloud-object-storage-driver", Registries: []string{"icr.io"}, Tag: "", Sha: "sha256:fc17bb3e89d00b3eb0f50b3ea83aa75c52e43d8e56cf2e0f17475e934eeeeb5f"}, message: ""},
{description: "Test cpopen/ibmcloud-object-storage-plugin respository and sha found.", imageRef: ImageReference{Repository: "cpopen/ibmcloud-object-storage-plugin", Registries: []string{"icr.io"}, Tag: "", Sha: "sha256:cf654987c38d048bc9e654f3928e9ce9a2a4fd47ce0283bb5f339c1b99298e6e"}, message: ""},
{description: "Test postgresql-10-rhel7 respository and tag found", imageRef: ImageReference{Repository: "rhscl/postgresql-10-rhel7", Registries: []string{"registry.access.redhat.com"}, Tag: "latest", Sha: ""}, message: ""},
{description: "Test cpopen/ibmcloud-object-storage-plugin respository sha found.", imageRef: ImageReference{Repository: "cpopen/ibmcloud-object-storage-plugin", Registries: []string{"icr.io"}, Tag: "", Sha: "sha256:7c00bc76f91d456164f98375cd8932a0ec500c9dca1728368f3c1ccdbfd96e91"}, message: ""},
{description: "Test cpopen/ibmcloud-object-storage-driver respository sha found.", imageRef: ImageReference{Repository: "cpopen/ibmcloud-object-storage-driver", Registries: []string{"icr.io"}, Tag: "", Sha: "sha256:667667c5907d0ad145e8518ca0f8cf013ca778d6738b028d1cd08103b1b64667"}, message: ""},
}
for _, tc := range PassTestCases {
t.Run(tc.description, func(t *testing.T) {
Expand Down

0 comments on commit 24b4249

Please sign in to comment.