-
Notifications
You must be signed in to change notification settings - Fork 72
/
status.go
48 lines (40 loc) · 1.63 KB
/
status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package cluster
import (
"github.com/redhat-developer/app-services-cli/pkg/shared/cluster/services/resources"
"github.com/redhat-developer/app-services-cli/pkg/shared/cluster/v1alpha"
bindv1alpha1 "github.com/redhat-developer/service-binding-operator/apis/binding/v1alpha1"
)
// ExecuteStatus executes status command by checking availability of operators and resources
// When unexpected error happens (non 404 error) function returns only error to the user
func (api *KubernetesClusterAPIImpl) ExecuteStatus() (*v1alpha.OperatorStatus, error) {
// Start with all resources unavailable
operatorStatus := v1alpha.OperatorStatus{
ServiceBindingOperatorAvailable: false,
RHOASOperatorAvailable: false,
LatestRHOASVersionAvailable: false,
}
namespace, err := api.KubernetesClients.CurrentNamespace()
if err != nil {
return nil, err
}
installed, err := api.KubernetesClients.IsResourceAvailableOnCluster(&resources.SRCResource, namespace)
// If unhandled error return instantly
if err != nil {
return nil, err
}
// Assign respective status otherwise
operatorStatus.LatestRHOASVersionAvailable = installed
installed, err = api.KubernetesClients.IsResourceAvailableOnCluster(&resources.AKCResource, namespace)
// If unhandled error return instantly
if err != nil {
return nil, err
}
operatorStatus.RHOASOperatorAvailable = installed
installed, err = api.KubernetesClients.IsResourceAvailableOnCluster(&bindv1alpha1.GroupVersionResource, namespace)
// If unhandled error return instantly
if err != nil {
return nil, err
}
operatorStatus.ServiceBindingOperatorAvailable = installed
return &operatorStatus, err
}