Helm Query interface methods must return error

In addition to results, all query methods of helm.Query must return error to contrast between a failure and a empty result.

Summary

In most of our Controller helpers, we return nil instead of err when an object cannot be retrieved from the Helm template.

Example:

// 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
Edited by Mitchell Nielsen