-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
54 lines (48 loc) · 1.21 KB
/
config.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
51
52
53
54
package sparkle
import (
"dario.cat/mergo"
"github.com/abemedia/appcast/pkg/crypto/dsa"
"github.com/abemedia/appcast/pkg/crypto/ed25519"
"github.com/abemedia/appcast/pkg/version"
"github.com/abemedia/appcast/source"
"github.com/abemedia/appcast/target"
)
type Config struct {
Title string
Description string
URL string
FileName string
DetectOS func(string) OS
DSAKey *dsa.PrivateKey
Ed25519Key ed25519.PrivateKey
Settings []Rule
Source *source.Source
Target target.Target
Version string
Prerelease bool
UploadPackages bool
}
type Rule struct {
OS OS
Version string
*Settings
}
type Settings struct {
InstallerArguments string
MinimumSystemVersion string
MinimumAutoupdateVersion string
IgnoreSkippedUpgradesBelowVersion string
CriticalUpdate bool
CriticalUpdateBelowVersion string
}
func getSettings(settings []Rule, v string, os OS) (*Settings, error) {
opt := &Settings{}
for _, s := range settings {
if isOS(os, s.OS) && version.Check(s.Version, v) {
if err := mergo.MergeWithOverwrite(opt, s.Settings); err != nil {
return nil, err
}
}
}
return opt, nil
}