Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KsaweryZietara committed Oct 9, 2024
1 parent cddf8f7 commit 120a0ce
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
14 changes: 7 additions & 7 deletions domain/apiresponses/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ type AsyncBindResponse struct {
}

type BindingResponse struct {
Credentials any `json:"credentials,omitempty"`
SyslogDrainURL string `json:"syslog_drain_url,omitempty"`
RouteServiceURL string `json:"route_service_url,omitempty"`
VolumeMounts []domain.VolumeMount `json:"volume_mounts,omitempty"`
BackupAgentURL string `json:"backup_agent_url,omitempty"`
Endpoints []domain.Endpoint `json:"endpoints,omitempty"`
Metadata domain.BindingMetadata `json:"metadata,omitempty"`
Credentials any `json:"credentials,omitempty"`
SyslogDrainURL string `json:"syslog_drain_url,omitempty"`
RouteServiceURL string `json:"route_service_url,omitempty"`
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 {
Expand Down
4 changes: 4 additions & 0 deletions domain/service_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,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
}
Expand Down
9 changes: 7 additions & 2 deletions handlers/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -89,7 +94,7 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
VolumeMounts: binding.VolumeMounts,
BackupAgentURL: binding.BackupAgentURL,
Endpoints: binding.Endpoints,
Metadata: binding.Metadata,
Metadata: metadata,
})
return
}
Expand Down Expand Up @@ -141,6 +146,6 @@ func (h APIHandler) Bind(w http.ResponseWriter, req *http.Request) {
VolumeMounts: binding.VolumeMounts,
BackupAgentURL: binding.BackupAgentURL,
Endpoints: binding.Endpoints,
Metadata: binding.Metadata,
Metadata: metadata,
})
}
7 changes: 6 additions & 1 deletion handlers/get_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,19 @@ 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,
Endpoints: binding.Endpoints,
Metadata: binding.Metadata,
Metadata: metadata,
},
Parameters: binding.Parameters,
})
Expand Down

0 comments on commit 120a0ce

Please sign in to comment.