Skip to content

Commit

Permalink
Merge pull request #114 from laverya/dont-require-resources.json
Browse files Browse the repository at this point in the history
if resources.json does not exist, do not fail the distribution analyzer
  • Loading branch information
laverya authored Jan 9, 2020
2 parents ff97a4e + 0379274 commit 5f60b1f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/analyze/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ func analyzeDistribution(analyzer *troubleshootv1beta1.Distribution, getCollecte
}

apiResourcesBytes, err := getCollectedFileContents("cluster-resources/resources.json")
if err != nil {
return nil, errors.Wrap(err, "failed to get contents of resources.json")
}
var apiResources []*metav1.APIResourceList
if err := json.Unmarshal(apiResourcesBytes, &apiResources); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal api resource list")
}
for _, resource := range apiResources {
if strings.Contains(resource.GroupVersion, "openshift") {
foundProviders.openShift = true
// if the file is not found, that is not a fatal error
// troubleshoot 0.9.15 and earlier did not collect that file
if err == nil {
var apiResources []*metav1.APIResourceList
if err := json.Unmarshal(apiResourcesBytes, &apiResources); err != nil {
return nil, errors.Wrap(err, "failed to unmarshal api resource list")
}
for _, resource := range apiResources {
if strings.Contains(resource.GroupVersion, "openshift") {
foundProviders.openShift = true
}
}
}

Expand Down

0 comments on commit 5f60b1f

Please sign in to comment.