Do not fail if imagePuller CRD does not exist (#700)

* Fix check if ImagePuller API is installed

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

Co-authored-by: Anatolii Bazko <abazko@redhat.com>
pull/714/head
Serhii Leshchenko 2021-03-11 10:13:39 +02:00 committed by GitHub
parent e0ff1bfbd9
commit ddcabcb60c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -257,23 +257,27 @@ func SubscriptionsAreEqual(expected *operatorsv1alpha1.Subscription, actual *ope
// foundKubernetesImagePullerAPI - true if the server discovers the che.eclipse.org API
// error - any error returned by the call to discoveryClient.ServerGroups()
func CheckNeededImagePullerApis(ctx *DeployContext) (bool, bool, bool, error) {
groupList, err := ctx.ClusterAPI.DiscoveryClient.ServerGroups()
groupList, resourcesList, err := ctx.ClusterAPI.DiscoveryClient.ServerGroupsAndResources()
if err != nil {
return false, false, false, err
}
groups := groupList.Groups
foundPackagesAPI := false
foundOperatorsAPI := false
foundKubernetesImagePullerAPI := false
for _, group := range groups {
for _, group := range groupList {
if group.Name == packagesv1.SchemeGroupVersion.Group {
foundPackagesAPI = true
}
if group.Name == operatorsv1alpha1.SchemeGroupVersion.Group {
foundOperatorsAPI = true
}
if group.Name == chev1alpha1.SchemeGroupVersion.Group {
foundKubernetesImagePullerAPI = true
}
for _, l := range resourcesList {
for _, r := range l.APIResources {
if l.GroupVersion == chev1alpha1.SchemeGroupVersion.String() && r.Kind == "KubernetesImagePuller" {
foundKubernetesImagePullerAPI = true
}
}
}
return foundPackagesAPI, foundOperatorsAPI, foundKubernetesImagePullerAPI, nil