forked from kyma-project/control-plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance_get.go
44 lines (35 loc) · 1.24 KB
/
instance_get.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
package broker
import (
"context"
"github.com/kyma-project/control-plane/components/kyma-environment-broker/internal/storage"
"github.com/pivotal-cf/brokerapi/v7/domain"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
type GetInstanceEndpoint struct {
instancesStorage storage.Instances
log logrus.FieldLogger
}
func NewGetInstance(instancesStorage storage.Instances, log logrus.FieldLogger) *GetInstanceEndpoint {
return &GetInstanceEndpoint{
instancesStorage: instancesStorage,
log: log.WithField("service", "GetInstanceEndpoint"),
}
}
// GetInstance fetches information about a service instance
// GET /v2/service_instances/{instance_id}
func (b *GetInstanceEndpoint) GetInstance(ctx context.Context, instanceID string) (domain.GetInstanceDetailsSpec, error) {
logger := b.log.WithField("instanceID", instanceID)
logger.Infof("GetInstance called")
inst, err := b.instancesStorage.GetByID(instanceID)
if err != nil {
return domain.GetInstanceDetailsSpec{}, errors.Wrapf(err, "while getting instance from storage")
}
spec := domain.GetInstanceDetailsSpec{
ServiceID: inst.ServiceID,
PlanID: inst.ServicePlanID,
DashboardURL: inst.DashboardURL,
Parameters: inst.Parameters,
}
return spec, nil
}