Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer send dockerconfigjson if container.HostedRegistry is true #818

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions certification/pyxis/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ type CertProject struct {

type Container struct {
DockerConfigJSON string `json:"docker_config_json,omitempty"`
HostedRegistry bool `json:"hosted_registry,omitempty"`
Type string `json:"type,omitempty"` // conditionally required
ISVPID string `json:"isv_pid,omitempty"` // required
Registry string `json:"registry,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions internal/lib/fakes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ func gpFuncReturnError(ctx context.Context) (*pyxis.CertProject, error) {
return nil, errors.New("some error returned from the api")
}

// gpFuncReturnHostedRegistry implements gpFunc and returns hosted_registry=true.
func gpFuncReturnHostedRegistry(ctx context.Context) (*pyxis.CertProject, error) {
return &pyxis.CertProject{
ID: "000000000000",
CertificationStatus: "false",
Name: "some-project",
Container: pyxis.Container{
HostedRegistry: true,
},
}, nil
}

// gpFuncReturnScratchException implements gpFunc and returns a scratch exception.
func gpFuncReturnScratchException(ctx context.Context) (*pyxis.CertProject, error) {
return &pyxis.CertProject{
Expand Down
11 changes: 11 additions & 0 deletions internal/lib/lib_container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ var _ = Describe("Lib Container Functions", func() {
})
})

Context("and certProject.Container.hosted_registry=true", func() {
BeforeEach(func() {
fakePC.setSRFuncSubmitSuccessfully("", "")
fakePC.getProjectsFunc = gpFuncReturnHostedRegistry
})
It("should not throw an error", func() {
err := sbmt.Submit(context.TODO())
Expect(err).ToNot(HaveOccurred())
})
})

Context("and the cert image cannot be read from disk", func() {
It("should throw an error", func() {
err := os.Remove(path.Join(artifacts.Path(), certification.DefaultCertImageFilename))
Expand Down
6 changes: 6 additions & 0 deletions internal/lib/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ func (s *ContainerCertificationSubmitter) Submit(ctx context.Context) error {
certProject.Container.DockerConfigJSON = ""
}

// no longer set DockerConfigJSON for registries which Red Hat hosts, this prevents the user from sending an invalid
// docker file that systems like clair and registry-proxy cannot use to pull the image
if certProject.Container.HostedRegistry {
certProject.Container.DockerConfigJSON = ""
}

// prepare submission. We ignore the error because nil checks for the certProject
// are done earlier to prevent panics, and that's the only error case for this function.
submission, _ := pyxis.NewCertificationInput(certProject)
Expand Down