Encapsulate snapshot list replies with key
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
615029f6c0
commit
81bcdcf00c
2 changed files with 41 additions and 4 deletions
|
@ -902,8 +902,16 @@ func listSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||
return errorReplyFormater(m, "backend error", err)
|
||||
}
|
||||
|
||||
var output SnapshotsMetadata
|
||||
for _, snapshot := range snapshots {
|
||||
output = append(output, SnapshotMetadata{
|
||||
Key: snapshot.KeyName(),
|
||||
Metadata: snapshot,
|
||||
})
|
||||
}
|
||||
|
||||
reply := ReplyMessage{
|
||||
Payload: snapshots,
|
||||
Payload: output,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(reply)
|
||||
|
@ -943,8 +951,16 @@ func listAppsSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||
return errorReplyFormater(m, "backend error", err)
|
||||
}
|
||||
|
||||
var output SnapshotsMetadata
|
||||
for _, snapshot := range snapshots {
|
||||
output = append(output, SnapshotMetadata{
|
||||
Key: snapshot.KeyName(),
|
||||
Metadata: snapshot,
|
||||
})
|
||||
}
|
||||
|
||||
reply := ReplyMessage{
|
||||
Payload: snapshots,
|
||||
Payload: output,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(reply)
|
||||
|
@ -984,8 +1000,16 @@ func listSnapshotsByLabelEventHandler(m *nats.Msg, message *RequestMessage) erro
|
|||
return errorReplyFormater(m, "backend error", err)
|
||||
}
|
||||
|
||||
var output SnapshotsMetadata
|
||||
for _, snapshot := range snapshots {
|
||||
output = append(output, SnapshotMetadata{
|
||||
Key: snapshot.KeyName(),
|
||||
Metadata: snapshot,
|
||||
})
|
||||
}
|
||||
|
||||
reply := ReplyMessage{
|
||||
Payload: snapshots,
|
||||
Payload: output,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(reply)
|
||||
|
|
15
types.go
15
types.go
|
@ -1,6 +1,10 @@
|
|||
package main
|
||||
|
||||
import "encoding/json"
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/rosti-cz/node-api/apps"
|
||||
)
|
||||
|
||||
// Path where authorized keys are
|
||||
const sshPubKeysLocation = "/srv/.ssh/authorized_keys"
|
||||
|
@ -60,3 +64,12 @@ type QuickServices struct {
|
|||
Memcached bool `json:"memcached"`
|
||||
Redis bool `json:"redis"`
|
||||
}
|
||||
|
||||
// SnapshotMetadata is snapshot structure encapsulation that combines key and metadata about the snapshot
|
||||
type SnapshotMetadata struct {
|
||||
Key string `json:"key"`
|
||||
Metadata apps.Snapshot `json:"metadata"`
|
||||
}
|
||||
|
||||
// SnapshotsMetadata is returned by handlers
|
||||
type SnapshotsMetadata []SnapshotMetadata
|
||||
|
|
Loading…
Reference in a new issue