forked from cloudfoundry-community/rds-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog.go
139 lines (125 loc) · 3.4 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package main
type Metadata struct {
DisplayName string `json:"displayName"`
ImageUrl string `json:"imageUrl"`
LongDescription string `json:"longDescription"`
ProviderDisplayName string `json:"providerDisplayName"`
DocumentationUrl string `json:"documentationUrl"`
SupportUrl string `json:"supportUrl"`
}
type PlanCost struct {
Amount map[string]float64 `json:"amount"`
Unit string `json:"unit"`
}
type PlanMetadata struct {
Bullets []string `json:"bullets"`
Costs []PlanCost `json:"costs"`
DisplayName string `json:"displayName"`
}
type Plan struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Metadata PlanMetadata `json:"metadata"`
Free bool `json:"free"`
Adapter string `json:"-"`
InstanceType string `json:"-"`
DbType string `json:"-"`
}
type Service struct {
Id string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Bindable bool `json:"bindable"`
Tags []string `json:"tags"`
Metadata Metadata `json:"metadata"`
Plans []Plan `json:"plans"`
}
func BuildCatalog() []Service {
service := Service{
Id: "db80ca29-2d1b-4fbc-aad3-d03c0bfa7593",
Name: "rds",
Description: "RDS Database Broker",
Bindable: true,
Tags: []string{"database", "RDS", "postgresql"},
Metadata: Metadata{
DisplayName: "RDS Database Broker",
ProviderDisplayName: "RDS",
},
Plans: GetPlans(),
}
return []Service{service}
}
func GetPlans() []Plan {
sharedPlan := Plan{
Id: "44d24fc7-f7a4-4ac1-b7a0-de82836e89a3",
Name: "shared-psql",
Description: "Shared infrastructure for Postgres DB",
Metadata: PlanMetadata{
Bullets: []string{"Shared RDS Instance", "Postgres instance"},
Costs: []PlanCost{
PlanCost{
Amount: map[string]float64{
"usd": 0.00,
},
Unit: "MONTHLY",
},
},
DisplayName: "Free Shared Plan",
},
Free: true,
Adapter: "shared",
DbType: "postgres",
}
microPlan := Plan{
Id: "da91e15c-98c9-46a9-b114-02b8d28062c6",
Name: "micro-psql",
Description: "Dedicated Micro RDS Postgres DB Instance",
Metadata: PlanMetadata{
Bullets: []string{"Dedicated Redundant RDS Instance", "Postgres instance"},
Costs: []PlanCost{
PlanCost{
Amount: map[string]float64{
"usd": 0.036,
},
Unit: "HOURLY",
},
},
DisplayName: "Dedicated Micro Postgres",
},
Free: false,
Adapter: "dedicated",
InstanceType: "db.t2.micro",
DbType: "postgres",
}
mediumPlan := Plan{
Id: "332e0168-6969-4bd7-b07f-29f08c4bf78e",
Name: "medium-psql",
Description: "Dedicated Medium RDS Postgres DB Instance",
Metadata: PlanMetadata{
Bullets: []string{"Dedicated Redundant RDS Instance", "Postgres instance"},
Costs: []PlanCost{
PlanCost{
Amount: map[string]float64{
"usd": 0.190,
},
Unit: "HOURLY",
},
},
DisplayName: "Dedicated Medium Postgres",
},
Free: false,
Adapter: "dedicated",
InstanceType: "db.m3.medium",
DbType: "postgres",
}
return []Plan{sharedPlan, microPlan, mediumPlan}
}
func FindPlan(id string) *Plan {
for _, p := range GetPlans() {
if p.Id == id {
return &p
}
}
return nil
}