@@ -2,10 +2,7 @@ package config
2
2
3
3
import (
4
4
"flag"
5
- "fmt"
6
- "os"
7
5
"regexp"
8
- "time"
9
6
10
7
"github.com/gorilla/securecookie"
11
8
@@ -27,10 +24,9 @@ const (
27
24
var NameFilter = regexp .MustCompile (PWDHostPortGroupRegex )
28
25
var AliasFilter = regexp .MustCompile (AliasPortGroupRegex )
29
26
30
- var PortNumber , Key , Cert , SessionsFile , PWDContainerName , L2ContainerName , L2Subdomain , PWDCName , HashKey , SSHKeyPath , L2RouterIP , DindVolumeSize , CookieHashKey , CookieBlockKey string
27
+ var PortNumber , Key , Cert , SessionsFile , PWDContainerName , L2ContainerName , L2Subdomain , HashKey , SSHKeyPath , L2RouterIP , DindVolumeSize , CookieHashKey , CookieBlockKey , DefaultDinDImage , DefaultSessionDuration string
31
28
var UseLetsEncrypt , ExternalDindVolume , NoWindows bool
32
29
var LetsEncryptCertsDir string
33
- var LetsEncryptDomains stringslice
34
30
var MaxLoadAvg float64
35
31
var ForceTLS bool
36
32
var Providers map [string ]* oauth2.Config
@@ -40,18 +36,9 @@ var GithubClientID, GithubClientSecret string
40
36
var FacebookClientID , FacebookClientSecret string
41
37
var DockerClientID , DockerClientSecret string
42
38
43
- type stringslice []string
44
-
45
- func (i * stringslice ) String () string {
46
- return fmt .Sprintf ("%s" , * i )
47
- }
48
- func (i * stringslice ) Set (value string ) error {
49
- * i = append (* i , value )
50
- return nil
51
- }
39
+ var PlaygroundDomain string
52
40
53
41
func ParseFlags () {
54
- flag .Var (& LetsEncryptDomains , "letsencrypt-domain" , "List of domains to validate with let's encrypt" )
55
42
flag .StringVar (& LetsEncryptCertsDir , "letsencrypt-certs-dir" , "/certs" , "Path where let's encrypt certs will be stored" )
56
43
flag .BoolVar (& UseLetsEncrypt , "letsencrypt-enable" , false , "Enabled let's encrypt tls certificates" )
57
44
flag .BoolVar (& ForceTLS , "tls" , false , "Use TLS to connect to docker daemons" )
@@ -63,7 +50,6 @@ func ParseFlags() {
63
50
flag .StringVar (& L2ContainerName , "l2" , "l2" , "Container name used to run L2 Router" )
64
51
flag .StringVar (& L2RouterIP , "l2-ip" , "" , "Host IP address for L2 router ping response" )
65
52
flag .StringVar (& L2Subdomain , "l2-subdomain" , "direct" , "Subdomain to the L2 Router" )
66
- flag .StringVar (& PWDCName , "cname" , "" , "CNAME given to this host" )
67
53
flag .StringVar (& HashKey , "hash_key" , "salmonrosado" , "Hash key to use for cookies" )
68
54
flag .StringVar (& DindVolumeSize , "dind-volume-size" , "5G" , "Dind volume folder size" )
69
55
flag .BoolVar (& NoWindows , "win-disable" , false , "Disable windows instances" )
@@ -72,6 +58,8 @@ func ParseFlags() {
72
58
flag .StringVar (& SSHKeyPath , "ssh_key_path" , "" , "SSH Private Key to use" )
73
59
flag .StringVar (& CookieHashKey , "cookie-hash-key" , "" , "Hash key to use to validate cookies" )
74
60
flag .StringVar (& CookieBlockKey , "cookie-block-key" , "" , "Block key to use to encrypt cookies" )
61
+ flag .StringVar (& DefaultDinDImage , "default-dind-image" , "franela/dind" , "Default DinD image to use if not specified otherwise" )
62
+ flag .StringVar (& DefaultSessionDuration , "default-session-duration" , "4h" , "Default session duration if not specified otherwise" )
75
63
76
64
flag .StringVar (& GithubClientID , "oauth-github-client-id" , "" , "Github OAuth Client ID" )
77
65
flag .StringVar (& GithubClientSecret , "oauth-github-client-secret" , "" , "Github OAuth Client Secret" )
@@ -82,6 +70,8 @@ func ParseFlags() {
82
70
flag .StringVar (& DockerClientID , "oauth-docker-client-id" , "" , "Docker OAuth Client ID" )
83
71
flag .StringVar (& DockerClientSecret , "oauth-docker-client-secret" , "" , "Docker OAuth Client Secret" )
84
72
73
+ flag .StringVar (& PlaygroundDomain , "playground-domain" , "localhost" , "Domain to use for the playground" )
74
+
85
75
flag .Parse ()
86
76
87
77
SecureCookie = securecookie .New ([]byte (CookieHashKey ), []byte (CookieBlockKey ))
@@ -126,38 +116,3 @@ func registerOAuthProviders() {
126
116
Providers ["docker" ] = conf
127
117
}
128
118
}
129
-
130
- func GetDindImageName () string {
131
- dindImage := os .Getenv ("DIND_IMAGE" )
132
- defaultDindImageName := "franela/dind"
133
- if len (dindImage ) == 0 {
134
- dindImage = defaultDindImageName
135
- }
136
- return dindImage
137
- }
138
-
139
- func GetSSHImage () string {
140
- sshImage := os .Getenv ("SSH_IMAGE" )
141
- defaultSSHImage := "franela/ssh"
142
- if len (sshImage ) == 0 {
143
- return defaultSSHImage
144
- }
145
- return sshImage
146
- }
147
-
148
- func GetDuration (reqDur string ) time.Duration {
149
- var defaultDuration = 4 * time .Hour
150
- if reqDur != "" {
151
- if dur , err := time .ParseDuration (reqDur ); err == nil && dur <= defaultDuration {
152
- return dur
153
- }
154
- return defaultDuration
155
- }
156
-
157
- envDur := os .Getenv ("EXPIRY" )
158
- if dur , err := time .ParseDuration (envDur ); err == nil {
159
- return dur
160
- }
161
-
162
- return defaultDuration
163
- }
0 commit comments