-
Notifications
You must be signed in to change notification settings - Fork 1
/
catalog.go
64 lines (55 loc) · 1.62 KB
/
catalog.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import (
"encoding/base64"
"fmt"
"io/ioutil"
"github.com/pivotal-cf/brokerapi/domain"
)
func LoadCatalogImage() string {
inBuf, err := ioutil.ReadFile("logo.png")
if err != nil {
return ""
}
return fmt.Sprintf("data:image/png;base64,%v", base64.StdEncoding.EncodeToString(inBuf))
}
func CatalogLoad(config brokerConfig, plans Plans) ([]domain.Service, error) {
var service domain.Service
boolTrue := true
service.ID = config.ServiceGUID
service.Name = config.ServiceName
service.Description = config.ServiceDescription
service.Bindable = true
service.BindingsRetrievable = false
service.InstancesRetrievable = true
service.Tags = config.ServiceTags
service.PlanUpdatable = true
service.Metadata = &domain.ServiceMetadata{
DisplayName: config.ServiceName,
ImageUrl: LoadCatalogImage(),
LongDescription: config.ServiceDescription,
ProviderDisplayName: "",
DocumentationUrl: config.DocsURL,
SupportUrl: "",
Shareable: &boolTrue,
AdditionalMetadata: map[string]interface{}{},
}
for planName, plan := range plans {
service.Plans = append(service.Plans, domain.ServicePlan{
ID: plan.ID,
Name: planName,
Description: plan.Description,
Free: plan.Free,
Bindable: &boolTrue,
Metadata: &domain.ServicePlanMetadata{
DisplayName: plan.DisplayName,
},
Schemas: &domain.ServiceSchemas{},
MaintenanceInfo: &domain.MaintenanceInfo{
Version: plan.MaintenanceInfo.Version,
Description: plan.MaintenanceInfo.Description,
},
})
}
services := []domain.Service{service}
return services, nil
}