Skip to content

Commit

Permalink
fix: nil check http response when err is not nil (PROJQUAY-6507)
Browse files Browse the repository at this point in the history
Topic: projquay-6507

The operator was panicking due to the httpResponse being nil and attempting to return the httpResponse.StatusCode in the response; the response was most likely nil due to a prior error when attempting to marshal json and build the http request itself. This now allows the error to be propagated out to the logs instead of causing the operator to panic

Signed-off-by: Ross Bryan <robryan@redhat.com>
  • Loading branch information
arborite-rh committed Feb 27, 2024
1 parent 2f224ad commit 44a5dd1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ func (r *NamespaceIntegrationReconciler) setupResources(ctx context.Context, req
// Check if Repository Exists
_, repositoryHttpResponse, repositoryErr := quayClient.GetRepository(quayOrganizationName, imageStreamName)

if repositoryHttpResponse == nil {
return r.CoreComponents.ManageError(&core.QuayIntegrationCoreError{
Object: namespace,
Message: "Error creating request to retrieve repository",
KeyAndValues: []interface{}{"Namespace", namespace.Name, "Name", imageStreamName},
Error: repositoryErr.Error,
})
}

if repositoryErr.Error != nil {
return r.CoreComponents.ManageError(&core.QuayIntegrationCoreError{
Object: namespace,
Expand Down

0 comments on commit 44a5dd1

Please sign in to comment.