-
-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathconfig.go
More file actions
66 lines (57 loc) · 1.36 KB
/
config.go
File metadata and controls
66 lines (57 loc) · 1.36 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
61
62
63
64
65
66
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
TunnelConfig TunnelConfig
}
type TunnelConfig struct {
License string
LicenseFile string
ClientImage string
InletsRelease string
}
func (c TunnelConfig) 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
}
if dashes := strings.Count(val, "-"); dashes == 4 {
return strings.TrimSpace(val), nil
}
return "", fmt.Errorf("inlets license may be invalid")
}