-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.go
More file actions
60 lines (51 loc) · 1.23 KB
/
types.go
File metadata and controls
60 lines (51 loc) · 1.23 KB
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
51
52
53
54
55
56
57
58
59
60
package scripts
import "time"
type Manifest struct {
Version string `json:"version"`
PublishedAt time.Time `json:"published_at"`
MinClientVersion string `json:"min_client_version,omitempty"`
Scripts map[string]ScriptEntry `json:"scripts"`
APK *APKEntry `json:"apk,omitempty"`
Signature string `json:"signature"`
}
type ScriptEntry struct {
URL string `json:"url"`
SHA256 string `json:"sha256"`
Size int64 `json:"size,omitempty"`
}
type APKEntry struct {
Version string `json:"version"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
Size int64 `json:"size,omitempty"`
}
type Bundle struct {
Manifest *Manifest
Files map[string][]byte
Source BundleSource
}
type BundleSource int
const (
SourceBundled BundleSource = iota
SourceLocal
SourceRemote
)
func (s BundleSource) String() string {
switch s {
case SourceBundled:
return "bundled"
case SourceLocal:
return "local"
case SourceRemote:
return "remote"
default:
return "unknown"
}
}
func (b *Bundle) File(name string) ([]byte, bool) {
if b == nil {
return nil, false
}
data, ok := b.Files[name]
return data, ok
}