forked from kyma-project/kyma
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclusterserviceplan_resolver.go
41 lines (33 loc) · 1.39 KB
/
clusterserviceplan_resolver.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
package servicecatalog
import (
"context"
"fmt"
"github.com/golang/glog"
"github.com/kyma-project/kyma/components/console-backend-service/internal/domain/rafter/pretty"
"github.com/kyma-project/kyma/components/console-backend-service/internal/domain/shared"
"github.com/kyma-project/kyma/components/console-backend-service/internal/gqlerror"
"github.com/kyma-project/kyma/components/console-backend-service/internal/gqlschema"
)
type ClusterServicePlanResolver struct {
rafter shared.RafterRetriever
}
func NewClusterServicePlanResolver(r shared.RafterRetriever) *ClusterServicePlanResolver {
return &ClusterServicePlanResolver{r}
}
func (r *ClusterServicePlanResolver) ClusterServicePlanClusterAssetGroupField(ctx context.Context, obj *gqlschema.ClusterServicePlan) (*gqlschema.ClusterAssetGroup, error) {
if obj == nil {
glog.Error(fmt.Errorf("while getting %s field obj is empty", pretty.ClusterAssetGroup))
return nil, gqlerror.NewInternal()
}
clusterAssetGroup, err := r.rafter.ClusterAssetGroup().Find(obj.Name)
if err != nil {
glog.Errorf("Couldn't find %s with name %s", pretty.ClusterAssetGroup, obj.Name)
return nil, nil
}
convertedAssetGroup, err := r.rafter.ClusterAssetGroupConverter().ToGQL(clusterAssetGroup)
if err != nil {
glog.Errorf("Couldn't convert %s with name %s to GQL", pretty.ClusterAssetGroup, obj.Name)
return nil, nil
}
return convertedAssetGroup, nil
}