[Controller] Return an error when object cannot be retrieved from Helm template
Summary
In most of our Controller helpers, we return nil instead of err when an object cannot be retrieved from the Helm template.
// ShellDeployment returns the Deployment of GitLab Shell component.
func ShellDeployment(adapter CustomResourceAdapter) *appsv1.Deployment {
template, err := GetTemplate(adapter)
if err != nil {
return nil
/* WARNING: This should return an error instead. */
}
return template.Query().DeploymentByComponent(GitLabShellComponentName)
}
We should return an error in these cases since the object's existence is expected by the time this method is called. If the object is not expected, then we have proper conditions checking for that in controllers/gitlab_controller.go.
Acceptance criteria
-
Errors are returned when an object or set of objects cannot be retrieved from the Helm template