-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
57 lines (50 loc) · 1.92 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
55
56
57
package main
import (
"crypto/tls"
"fmt"
"io/ioutil"
)
type Version struct {
Major int `json:"major"`
Minor int `json:"minor"`
Patch int `json:"patch"`
}
func (v Version) Clone() Version {
return Version{Major: v.Major, Minor: v.Minor, Patch: v.Patch}
}
func (v Version) String() string {
return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Patch)
}
type GoBuilderPackage struct {
Package string `yaml:"package"`
VerbosePackage string `yaml:"verbose-package"`
BuildFlag []string `yaml:"build-flag,omitempty"` // suffix flag
BuildMode string `yaml:"build-mode"` // host or docker
BuildOS string `yaml:"build-os,omitempty"` // darwin or linux or windows
BuildArch string `yaml:"build-arch,omitempty"` // arm64 or amd64 or ...
Version *Version `yaml:"version,omitempty"`
Dest string `yaml:"dest,omitempty"`
Deploy string `yaml:"deploy,omitempty"` // remote quic path
CleanAfterDeploy bool `yaml:"clean-after-deploy,omitempty"`
}
type GoBuilderConfig struct {
Packages map[string]*GoBuilderPackage `yaml:"packages,omitempty"`
Version string `yaml:"version,omitempty"` // golang version only build mode docker working
Parallel int `yaml:"parallel,omitempty"`
AutoUpgrade bool `yaml:"auto-upgrade"`
Verbose bool `yaml:"verbose"`
CA string `yaml:"ca,omitempty"`
Cert string `yaml:"cert,omitempty"`
Key string `yaml:"key,omitempty"`
}
func (c GoBuilderConfig) GetTlsCert() (tls.Certificate, error) {
certPEM, err := ioutil.ReadFile(c.Cert)
if err != nil {
return tls.Certificate{}, err
}
privateKeyPEM, err := ioutil.ReadFile(c.Key)
if err != nil {
return tls.Certificate{}, err
}
return tls.X509KeyPair(certPEM, privateKeyPEM)
}