-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
artifact.go
50 lines (42 loc) · 1.32 KB
/
artifact.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package keygen
import (
"time"
"github.com/keygen-sh/jsonapi-go"
)
// Artifact represents a Keygen artifact object.
type Artifact struct {
ID string `json:"-"`
Type string `json:"-"`
Filename string `json:"filename"`
Filetype string `json:"filetype"`
Filesize int64 `json:"filesize"`
Platform string `json:"platform"`
Arch string `json:"arch"`
Signature string `json:"signature"`
Checksum string `json:"checksum"`
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
ReleaseId string `json:"-"`
URL string `json:"-"`
}
// SetID implements the jsonapi.UnmarshalResourceIdentifier interface.
func (a *Artifact) SetID(id string) error {
a.ID = id
return nil
}
// SetType implements the jsonapi.UnmarshalResourceIdentifier interface.
func (a *Artifact) SetType(t string) error {
a.Type = t
return nil
}
// SetData implements the jsonapi.UnmarshalData interface.
func (a *Artifact) SetData(to func(target interface{}) error) error {
return to(a)
}
// SetRelationships implements the jsonapi.UnmarshalRelationship interface.
func (a *Artifact) SetRelationships(relationships map[string]interface{}) error {
if relationship, ok := relationships["release"]; ok {
a.ReleaseId = relationship.(*jsonapi.ResourceObjectIdentifier).ID
}
return nil
}