-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
config.go
62 lines (54 loc) · 1.28 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
58
59
60
61
62
package main
import (
"fmt"
"io/ioutil"
"strings"
)
// InfraConfig is the configuration for
// creating Infrastructure Resources
type InfraConfig struct {
Provider string
Region string
Zone string
AccessKey string
SecretKey string
OrganizationID string
SubscriptionID string
VpcID string
SubnetID string
AccessKeyFile string
SecretKeyFile string
ProjectID string
AnnotatedOnly bool
MaxClientMemory string
Plan string
ProConfig InletsProConfig
}
type InletsProConfig struct {
License string
LicenseFile string
ClientImage string
InletsRelease string
}
func (c InletsProConfig) GetLicenseKey() (string, error) {
val := ""
if len(c.License) > 0 {
val = c.License
} else {
data, err := ioutil.ReadFile(c.LicenseFile)
if err != nil {
return "", fmt.Errorf("error with GetLicenseKey: %s", err.Error())
}
val = string(data)
}
if len(val) == 0 {
return "", fmt.Errorf("--license or --license-key is required for inlets PRO")
}
if dots := strings.Count(val, "."); dots >= 2 {
return strings.TrimSpace(val), nil
}
if dashes := strings.Count(val, "-"); dashes == 3 {
return strings.TrimSpace(val), nil
}
return "", fmt.Errorf("inlets license may be invalid")
}