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
@ -902,8 +902,16 @@ func listSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
return errorReplyFormater(m, "backend error", err)
|
return errorReplyFormater(m, "backend error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var output SnapshotsMetadata
|
||||||
|
for _, snapshot := range snapshots {
|
||||||
|
output = append(output, SnapshotMetadata{
|
||||||
|
Key: snapshot.KeyName(),
|
||||||
|
Metadata: snapshot,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
reply := ReplyMessage{
|
reply := ReplyMessage{
|
||||||
Payload: snapshots,
|
Payload: output,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(reply)
|
data, err := json.Marshal(reply)
|
||||||
@ -943,8 +951,16 @@ func listAppsSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
return errorReplyFormater(m, "backend error", err)
|
return errorReplyFormater(m, "backend error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var output SnapshotsMetadata
|
||||||
|
for _, snapshot := range snapshots {
|
||||||
|
output = append(output, SnapshotMetadata{
|
||||||
|
Key: snapshot.KeyName(),
|
||||||
|
Metadata: snapshot,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
reply := ReplyMessage{
|
reply := ReplyMessage{
|
||||||
Payload: snapshots,
|
Payload: output,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(reply)
|
data, err := json.Marshal(reply)
|
||||||
@ -984,8 +1000,16 @@ func listSnapshotsByLabelEventHandler(m *nats.Msg, message *RequestMessage) erro
|
|||||||
return errorReplyFormater(m, "backend error", err)
|
return errorReplyFormater(m, "backend error", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var output SnapshotsMetadata
|
||||||
|
for _, snapshot := range snapshots {
|
||||||
|
output = append(output, SnapshotMetadata{
|
||||||
|
Key: snapshot.KeyName(),
|
||||||
|
Metadata: snapshot,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
reply := ReplyMessage{
|
reply := ReplyMessage{
|
||||||
Payload: snapshots,
|
Payload: output,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := json.Marshal(reply)
|
data, err := json.Marshal(reply)
|
||||||
|
15
types.go
15
types.go
@ -1,6 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "encoding/json"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/rosti-cz/node-api/apps"
|
||||||
|
)
|
||||||
|
|
||||||
// Path where authorized keys are
|
// Path where authorized keys are
|
||||||
const sshPubKeysLocation = "/srv/.ssh/authorized_keys"
|
const sshPubKeysLocation = "/srv/.ssh/authorized_keys"
|
||||||
@ -60,3 +64,12 @@ type QuickServices struct {
|
|||||||
Memcached bool `json:"memcached"`
|
Memcached bool `json:"memcached"`
|
||||||
Redis bool `json:"redis"`
|
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 New Issue
Block a user