Skip to content

Commit 1196157

Browse files
fix: add expiration date and time for bindings
* Add expiration date and time for bindings * Add renew before field * Fix tests
1 parent c78d48d commit 1196157

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

domain/apiresponses/responses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type BindingResponse struct {
6868
VolumeMounts []domain.VolumeMount `json:"volume_mounts,omitempty"`
6969
BackupAgentURL string `json:"backup_agent_url,omitempty"`
7070
Endpoints []domain.Endpoint `json:"endpoints,omitempty"`
71+
Metadata any `json:"metadata,omitempty"`
7172
}
7273

7374
type GetBindingResponse struct {

domain/service_broker.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,21 @@ type UnbindSpec struct {
190190
}
191191

192192
type Binding struct {
193-
IsAsync bool `json:"is_async"`
194-
AlreadyExists bool `json:"already_exists"`
195-
OperationData string `json:"operation_data"`
196-
Credentials any `json:"credentials"`
197-
SyslogDrainURL string `json:"syslog_drain_url"`
198-
RouteServiceURL string `json:"route_service_url"`
199-
BackupAgentURL string `json:"backup_agent_url,omitempty"`
200-
VolumeMounts []VolumeMount `json:"volume_mounts"`
201-
Endpoints []Endpoint `json:"endpoints,omitempty"`
193+
IsAsync bool `json:"is_async"`
194+
AlreadyExists bool `json:"already_exists"`
195+
OperationData string `json:"operation_data"`
196+
Credentials any `json:"credentials"`
197+
SyslogDrainURL string `json:"syslog_drain_url"`
198+
RouteServiceURL string `json:"route_service_url"`
199+
BackupAgentURL string `json:"backup_agent_url,omitempty"`
200+
VolumeMounts []VolumeMount `json:"volume_mounts"`
201+
Endpoints []Endpoint `json:"endpoints,omitempty"`
202+
Metadata BindingMetadata `json:"metadata,omitempty"`
203+
}
204+
205+
type BindingMetadata struct {
206+
ExpiresAt string `json:"expires_at,omitempty"`
207+
RenewBefore string `json:"renew_before,omitempty"`
202208
}
203209

204210
type GetBindingSpec struct {
@@ -208,6 +214,7 @@ type GetBindingSpec struct {
208214
VolumeMounts []VolumeMount
209215
Parameters any
210216
Endpoints []Endpoint
217+
Metadata BindingMetadata
211218
}
212219

213220
type Endpoint struct {
@@ -236,6 +243,10 @@ func (m InstanceMetadata) IsEmpty() bool {
236243
return len(m.Attributes) == 0 && len(m.Labels) == 0
237244
}
238245

246+
func (m BindingMetadata) IsEmpty() bool {
247+
return len(m.ExpiresAt) == 0 && len(m.RenewBefore) == 0
248+
}
249+
239250
func (d UpdateDetails) GetRawContext() json.RawMessage {
240251
return d.RawContext
241252
}

handlers/bind.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
8181
return
8282
}
8383

84+
var metadata any
85+
if !binding.Metadata.IsEmpty() {
86+
metadata = binding.Metadata
87+
}
88+
8489
if binding.AlreadyExists {
8590
h.respond(w, http.StatusOK, requestId, apiresponses.BindingResponse{
8691
Credentials: binding.Credentials,
@@ -89,6 +94,7 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
8994
VolumeMounts: binding.VolumeMounts,
9095
BackupAgentURL: binding.BackupAgentURL,
9196
Endpoints: binding.Endpoints,
97+
Metadata: metadata,
9298
})
9399
return
94100
}
@@ -140,5 +146,6 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
140146
VolumeMounts: binding.VolumeMounts,
141147
BackupAgentURL: binding.BackupAgentURL,
142148
Endpoints: binding.Endpoints,
149+
Metadata: metadata,
143150
})
144151
}

handlers/get_binding.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,19 @@ func (h APIHandler) GetBinding(w http.ResponseWriter, req *http.Request) {
5353
return
5454
}
5555

56+
var metadata any
57+
if !binding.Metadata.IsEmpty() {
58+
metadata = binding.Metadata
59+
}
60+
5661
h.respond(w, http.StatusOK, requestId, apiresponses.GetBindingResponse{
5762
BindingResponse: apiresponses.BindingResponse{
5863
Credentials: binding.Credentials,
5964
SyslogDrainURL: binding.SyslogDrainURL,
6065
RouteServiceURL: binding.RouteServiceURL,
6166
VolumeMounts: binding.VolumeMounts,
6267
Endpoints: binding.Endpoints,
68+
Metadata: metadata,
6369
},
6470
Parameters: binding.Parameters,
6571
})

0 commit comments

Comments
 (0)