forked from Cloud-Foundations/Dominator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
expiration.go
31 lines (28 loc) · 957 Bytes
/
expiration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package rpcd
import (
"github.com/Cloud-Foundations/Dominator/lib/errors"
"github.com/Cloud-Foundations/Dominator/lib/srpc"
"github.com/Cloud-Foundations/Dominator/proto/imageserver"
)
func (t *srpcType) ChangeImageExpiration(conn *srpc.Conn,
request imageserver.ChangeImageExpirationRequest,
reply *imageserver.ChangeImageExpirationResponse) error {
if err := t.checkMutability(); err != nil {
reply.Error = errors.ErrorToString(err)
return nil
}
_, err := t.imageDataBase.ChangeImageExpiration(
request.ImageName, request.ExpiresAt, conn.GetAuthInformation())
reply.Error = errors.ErrorToString(err)
return nil
}
func (t *srpcType) GetImageExpiration(conn *srpc.Conn,
request imageserver.GetImageExpirationRequest,
reply *imageserver.GetImageExpirationResponse) error {
if img := t.imageDataBase.GetImage(request.ImageName); img == nil {
reply.Error = "image not found"
} else {
reply.ExpiresAt = img.ExpiresAt
}
return nil
}