diff --git a/domain/apiresponses/responses.go b/domain/apiresponses/responses.go index 0b8f8525..177ca5bb 100644 --- a/domain/apiresponses/responses.go +++ b/domain/apiresponses/responses.go @@ -68,6 +68,7 @@ type BindingResponse struct { VolumeMounts []domain.VolumeMount `json:"volume_mounts,omitempty"` BackupAgentURL string `json:"backup_agent_url,omitempty"` Endpoints []domain.Endpoint `json:"endpoints,omitempty"` + Metadata any `json:"metadata,omitempty"` } type GetBindingResponse struct { diff --git a/domain/service_broker.go b/domain/service_broker.go index 0e0806c6..00786ff7 100644 --- a/domain/service_broker.go +++ b/domain/service_broker.go @@ -190,15 +190,21 @@ type UnbindSpec struct { } type Binding struct { - IsAsync bool `json:"is_async"` - AlreadyExists bool `json:"already_exists"` - OperationData string `json:"operation_data"` - Credentials any `json:"credentials"` - SyslogDrainURL string `json:"syslog_drain_url"` - RouteServiceURL string `json:"route_service_url"` - BackupAgentURL string `json:"backup_agent_url,omitempty"` - VolumeMounts []VolumeMount `json:"volume_mounts"` - Endpoints []Endpoint `json:"endpoints,omitempty"` + IsAsync bool `json:"is_async"` + AlreadyExists bool `json:"already_exists"` + OperationData string `json:"operation_data"` + Credentials any `json:"credentials"` + SyslogDrainURL string `json:"syslog_drain_url"` + RouteServiceURL string `json:"route_service_url"` + BackupAgentURL string `json:"backup_agent_url,omitempty"` + VolumeMounts []VolumeMount `json:"volume_mounts"` + Endpoints []Endpoint `json:"endpoints,omitempty"` + Metadata BindingMetadata `json:"metadata,omitempty"` +} + +type BindingMetadata struct { + ExpiresAt string `json:"expires_at,omitempty"` + RenewBefore string `json:"renew_before,omitempty"` } type GetBindingSpec struct { @@ -208,6 +214,7 @@ type GetBindingSpec struct { VolumeMounts []VolumeMount Parameters any Endpoints []Endpoint + Metadata BindingMetadata } type Endpoint struct { @@ -236,6 +243,10 @@ func (m InstanceMetadata) IsEmpty() bool { return len(m.Attributes) == 0 && len(m.Labels) == 0 } +func (m BindingMetadata) IsEmpty() bool { + return len(m.ExpiresAt) == 0 && len(m.RenewBefore) == 0 +} + func (d UpdateDetails) GetRawContext() json.RawMessage { return d.RawContext } diff --git a/handlers/bind.go b/handlers/bind.go index c7006ee4..5d51b6e4 100644 --- a/handlers/bind.go +++ b/handlers/bind.go @@ -81,6 +81,11 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) { return } + var metadata any + if !binding.Metadata.IsEmpty() { + metadata = binding.Metadata + } + if binding.AlreadyExists { h.respond(w, http.StatusOK, requestId, apiresponses.BindingResponse{ Credentials: binding.Credentials, @@ -89,6 +94,7 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) { VolumeMounts: binding.VolumeMounts, BackupAgentURL: binding.BackupAgentURL, Endpoints: binding.Endpoints, + Metadata: metadata, }) return } @@ -140,5 +146,6 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) { VolumeMounts: binding.VolumeMounts, BackupAgentURL: binding.BackupAgentURL, Endpoints: binding.Endpoints, + Metadata: metadata, }) } diff --git a/handlers/get_binding.go b/handlers/get_binding.go index d7edc008..346600a3 100644 --- a/handlers/get_binding.go +++ b/handlers/get_binding.go @@ -53,6 +53,11 @@ func (h APIHandler) GetBinding(w http.ResponseWriter, req *http.Request) { return } + var metadata any + if !binding.Metadata.IsEmpty() { + metadata = binding.Metadata + } + h.respond(w, http.StatusOK, requestId, apiresponses.GetBindingResponse{ BindingResponse: apiresponses.BindingResponse{ Credentials: binding.Credentials, @@ -60,6 +65,7 @@ func (h APIHandler) GetBinding(w http.ResponseWriter, req *http.Request) { RouteServiceURL: binding.RouteServiceURL, VolumeMounts: binding.VolumeMounts, Endpoints: binding.Endpoints, + Metadata: metadata, }, Parameters: binding.Parameters, })