diff --git a/pkg/analyze/velero.go b/pkg/analyze/velero.go index 6a268bd79..36ee988be 100644 --- a/pkg/analyze/velero.go +++ b/pkg/analyze/velero.go @@ -653,19 +653,22 @@ func getVeleroVersion(excludedFiles []string, findFiles getChildCollectedFileCon veleroDeploymentDir := "cluster-resources/deployments" veleroVersion := "" veleroDeploymentGlob := filepath.Join(veleroDeploymentDir, "velero.json") - veleroDeploymentJson, err := findFiles(veleroDeploymentGlob, excludedFiles) - if err != nil { - return "", errors.Wrapf(err, "failed to find velero deployment file under %s", veleroDeploymentDir) + veleroDeploymentJson, _ := findFiles(veleroDeploymentGlob, excludedFiles) + if len(veleroDeploymentJson) == 0 { + return "", errors.Errorf("could not find Velero deployment in %s", veleroDeploymentDir) } var deploymentList *appsV1.DeploymentList // should run only once for key, veleroDeploymentJsonBytes := range veleroDeploymentJson { err := json.Unmarshal(veleroDeploymentJsonBytes, &deploymentList) if err != nil { - return "", errors.Wrapf(err, "failed to unmarshal velero deployment json from %s", key) + return "", errors.Wrapf(err, "failed to unmarshal Velero deployment json from %s", key) } break } + if deploymentList == nil { + return "", errors.Errorf("could not find Velero deployment") + } for _, deployment := range deploymentList.Items { for _, container := range deployment.Spec.Template.Spec.Containers { if container.Name == "velero" { @@ -676,7 +679,7 @@ func getVeleroVersion(excludedFiles []string, findFiles getChildCollectedFileCon } } - return "", errors.Errorf("Unable to get velero version. Could not find velero container in deployment!") + return "", errors.Errorf("could not find Velero container in deployment") } func GetVeleroBackupsDirectory() string {