Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binding metadata #1

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions domain/apiresponses/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type BindingResponse struct {
RouteServiceURL string `json:"route_service_url,omitempty"`
VolumeMounts []domain.VolumeMount `json:"volume_mounts,omitempty"`
BackupAgentURL string `json:"backup_agent_url,omitempty"`
Metadata any `json:"metadata,omitempty"`
}

type GetBindingResponse struct {
Expand Down
27 changes: 19 additions & 8 deletions domain/service_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,20 @@ type UnbindSpec struct {
}

type Binding struct {
IsAsync bool `json:"is_async"`
AlreadyExists bool `json:"already_exists"`
OperationData string `json:"operation_data"`
Credentials interface{} `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"`
IsAsync bool `json:"is_async"`
AlreadyExists bool `json:"already_exists"`
OperationData string `json:"operation_data"`
Credentials interface{} `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"`
Metadata BindingMetadata `json:"metadata,omitempty"`
}

type BindingMetadata struct {
ExpiresAt string `json:"expires_at,omitempty"`
RenewBefore string `json:"renew_before,omitempty"`
}

type GetBindingSpec struct {
Expand All @@ -206,6 +212,7 @@ type GetBindingSpec struct {
RouteServiceURL string
VolumeMounts []VolumeMount
Parameters interface{}
Metadata BindingMetadata
}

func (d ProvisionDetails) GetRawContext() json.RawMessage {
Expand All @@ -228,6 +235,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
}
Expand Down
7 changes: 7 additions & 0 deletions handlers/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,19 @@ 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,
SyslogDrainURL: binding.SyslogDrainURL,
RouteServiceURL: binding.RouteServiceURL,
VolumeMounts: binding.VolumeMounts,
BackupAgentURL: binding.BackupAgentURL,
Metadata: metadata,
})
return
}
Expand Down Expand Up @@ -142,5 +148,6 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
RouteServiceURL: binding.RouteServiceURL,
VolumeMounts: binding.VolumeMounts,
BackupAgentURL: binding.BackupAgentURL,
Metadata: metadata,
})
}
6 changes: 6 additions & 0 deletions handlers/get_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,18 @@ 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,
SyslogDrainURL: binding.SyslogDrainURL,
RouteServiceURL: binding.RouteServiceURL,
VolumeMounts: binding.VolumeMounts,
Metadata: metadata,
},
Parameters: binding.Parameters,
})
Expand Down