@@ -153,16 +153,12 @@ func Run(options ...RunOption) {
153
153
return
154
154
}
155
155
156
- // BEWARE: we can only call buildChildProcEnv once, because it might download env vars from a one-time-secret
157
- // URL, which would fail if we tried another time.
158
- childProcEnvvars := buildChildProcEnv (cfg , nil )
159
-
160
156
err = AddGitpodUserIfNotExists ()
161
157
if err != nil {
162
158
log .WithError (err ).Fatal ("cannot ensure Gitpod user exists" )
163
159
}
164
160
symlinkBinaries (cfg )
165
- configureGit (cfg , childProcEnvvars )
161
+ configureGit (cfg )
166
162
167
163
tokenService := NewInMemoryTokenService ()
168
164
tkns , err := cfg .GetTokens (true )
@@ -250,7 +246,7 @@ func Run(options ...RunOption) {
250
246
return ""
251
247
}
252
248
}
253
- termMuxSrv .Env = childProcEnvvars
249
+ termMuxSrv .Env = buildChildProcEnv ( cfg , nil )
254
250
termMuxSrv .DefaultCreds = & syscall.Credential {
255
251
Uid : gitpodUID ,
256
252
Gid : gitpodGID ,
@@ -287,15 +283,15 @@ func Run(options ...RunOption) {
287
283
288
284
// We need to checkout dotfiles first, because they may be changing the path which affects the IDE.
289
285
// TODO(cw): provide better feedback if the IDE start fails because of the dotfiles (provide any feedback at all).
290
- installDotfiles (ctx , cfg , childProcEnvvars )
286
+ installDotfiles (ctx , termMuxSrv , cfg )
291
287
}
292
288
293
289
var ideWG sync.WaitGroup
294
290
ideWG .Add (1 )
295
- go startAndWatchIDE (ctx , cfg , & cfg .IDE , childProcEnvvars , & ideWG , ideReady , WebIDE )
291
+ go startAndWatchIDE (ctx , cfg , & cfg .IDE , & ideWG , ideReady , WebIDE )
296
292
if cfg .DesktopIDE != nil {
297
293
ideWG .Add (1 )
298
- go startAndWatchIDE (ctx , cfg , cfg .DesktopIDE , childProcEnvvars , & ideWG , desktopIdeReady , DesktopIDE )
294
+ go startAndWatchIDE (ctx , cfg , cfg .DesktopIDE , & ideWG , desktopIdeReady , DesktopIDE )
299
295
}
300
296
301
297
var wg sync.WaitGroup
@@ -304,7 +300,7 @@ func Run(options ...RunOption) {
304
300
wg .Add (1 )
305
301
go startAPIEndpoint (ctx , cfg , & wg , apiServices , tunneledPortsService , apiEndpointOpts ... )
306
302
wg .Add (1 )
307
- go startSSHServer (ctx , cfg , & wg , childProcEnvvars )
303
+ go startSSHServer (ctx , cfg , & wg )
308
304
wg .Add (1 )
309
305
tasksSuccessChan := make (chan taskSuccess , 1 )
310
306
go taskManager .Run (ctx , & wg , tasksSuccessChan )
@@ -340,7 +336,7 @@ func Run(options ...RunOption) {
340
336
}()
341
337
342
338
cmd := runAsGitpodUser (exec .Command ("git" , "fetch" , "--unshallow" , "--tags" ))
343
- cmd .Env = childProcEnvvars
339
+ cmd .Env = buildChildProcEnv ( cfg , nil )
344
340
cmd .Dir = cfg .RepoRoot
345
341
cmd .Stdout = os .Stdout
346
342
cmd .Stderr = os .Stderr
@@ -374,7 +370,7 @@ func Run(options ...RunOption) {
374
370
wg .Wait ()
375
371
}
376
372
377
- func installDotfiles (ctx context.Context , cfg * Config , childProcEnvvars [] string ) {
373
+ func installDotfiles (ctx context.Context , term * terminal. MuxTerminalService , cfg * Config ) {
378
374
repo := cfg .DotfileRepo
379
375
if repo == "" {
380
376
return
@@ -389,7 +385,7 @@ func installDotfiles(ctx context.Context, cfg *Config, childProcEnvvars []string
389
385
prep := func (cfg * Config , out io.Writer , name string , args ... string ) * exec.Cmd {
390
386
cmd := exec .Command (name , args ... )
391
387
cmd .Dir = "/home/gitpod"
392
- cmd .Env = childProcEnvvars
388
+ cmd .Env = buildChildProcEnv ( cfg , nil )
393
389
cmd .SysProcAttr = & syscall.SysProcAttr {
394
390
// All supervisor children run as gitpod user. The environment variables we produce are also
395
391
// gitpod user specific.
@@ -592,7 +588,7 @@ func symlinkBinaries(cfg *Config) {
592
588
}
593
589
}
594
590
595
- func configureGit (cfg * Config , childProcEnvvars [] string ) {
591
+ func configureGit (cfg * Config ) {
596
592
settings := [][]string {
597
593
{"push.default" , "simple" },
598
594
{"alias.lg" , "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" },
@@ -608,7 +604,7 @@ func configureGit(cfg *Config, childProcEnvvars []string) {
608
604
for _ , s := range settings {
609
605
cmd := exec .Command ("git" , append ([]string {"config" , "--global" }, s ... )... )
610
606
cmd = runAsGitpodUser (cmd )
611
- cmd .Env = childProcEnvvars
607
+ cmd .Env = buildChildProcEnv ( cfg , nil )
612
608
cmd .Stdout = os .Stdout
613
609
cmd .Stderr = os .Stderr
614
610
err := cmd .Run ()
@@ -709,7 +705,7 @@ const (
709
705
statusShouldShutdown
710
706
)
711
707
712
- func startAndWatchIDE (ctx context.Context , cfg * Config , ideConfig * IDEConfig , childProcEnvvars [] string , wg * sync.WaitGroup , ideReady * ideReadyState , ide IDEKind ) {
708
+ func startAndWatchIDE (ctx context.Context , cfg * Config , ideConfig * IDEConfig , wg * sync.WaitGroup , ideReady * ideReadyState , ide IDEKind ) {
713
709
defer wg .Done ()
714
710
defer log .WithField ("ide" , ide .String ()).Debug ("startAndWatchIDE shutdown" )
715
711
@@ -731,7 +727,7 @@ supervisorLoop:
731
727
}
732
728
733
729
ideStopped = make (chan struct {}, 1 )
734
- cmd = prepareIDELaunch (cfg , ideConfig , childProcEnvvars )
730
+ cmd = prepareIDELaunch (cfg , ideConfig )
735
731
launchIDE (cfg , ideConfig , cmd , ideStopped , ideReady , & ideStatus , ide )
736
732
737
733
select {
@@ -812,7 +808,7 @@ func launchIDE(cfg *Config, ideConfig *IDEConfig, cmd *exec.Cmd, ideStopped chan
812
808
}()
813
809
}
814
810
815
- func prepareIDELaunch (cfg * Config , ideConfig * IDEConfig , childProcEnvvars [] string ) * exec.Cmd {
811
+ func prepareIDELaunch (cfg * Config , ideConfig * IDEConfig ) * exec.Cmd {
816
812
args := ideConfig .EntrypointArgs
817
813
818
814
// Add default args for IDE (not desktop IDE) to be backwards compatible
@@ -840,7 +836,7 @@ func prepareIDELaunch(cfg *Config, ideConfig *IDEConfig, childProcEnvvars []stri
840
836
Gid : gitpodGID ,
841
837
},
842
838
}
843
- cmd .Env = childProcEnvvars
839
+ cmd .Env = buildChildProcEnv ( cfg , nil )
844
840
845
841
// Here we must resist the temptation to "neaten up" the IDE output for headless builds.
846
842
// This would break the JSON parsing of the headless builds.
@@ -858,8 +854,6 @@ func prepareIDELaunch(cfg *Config, ideConfig *IDEConfig, childProcEnvvars []stri
858
854
859
855
// buildChildProcEnv computes the environment variables passed to a child process, based on the total list
860
856
// of envvars. If envvars is nil, os.Environ() is used.
861
- //
862
- // Beware: if config contains an OTS URL the results may differ on subsequent calls.
863
857
func buildChildProcEnv (cfg * Config , envvars []string ) []string {
864
858
if envvars == nil {
865
859
envvars = os .Environ ()
@@ -882,20 +876,6 @@ func buildChildProcEnv(cfg *Config, envvars []string) []string {
882
876
}
883
877
envs ["SUPERVISOR_ADDR" ] = fmt .Sprintf ("localhost:%d" , cfg .APIEndpointPort )
884
878
885
- if cfg .EnvvarOTS != "" {
886
- es , err := downloadEnvvarOTS (cfg .EnvvarOTS )
887
- if err != nil {
888
- log .WithError (err ).Warn ("unable to download environment variables from OTS" )
889
- }
890
- for k , v := range es {
891
- if isBlacklistedEnvvar (k ) {
892
- continue
893
- }
894
-
895
- envs [k ] = v
896
- }
897
- }
898
-
899
879
// We're forcing basic environment variables here, because supervisor acts like a login process at this point.
900
880
// The gitpod user might not have existed when supervisor was started, hence the HOME coming
901
881
// from the container runtime is probably wrong ("/" to be exact).
@@ -931,31 +911,6 @@ func buildChildProcEnv(cfg *Config, envvars []string) []string {
931
911
return env
932
912
}
933
913
934
- func downloadEnvvarOTS (url string ) (res map [string ]string , err error ) {
935
- client := & http.Client {Timeout : 10 * time .Second }
936
- resp , err := client .Get (url )
937
- if err != nil {
938
- return nil , err
939
- }
940
-
941
- defer resp .Body .Close ()
942
-
943
- var dl []struct {
944
- Name string `json:"name"`
945
- Value string `json:"value"`
946
- }
947
- err = json .NewDecoder (resp .Body ).Decode (& dl )
948
- if err != nil {
949
- return nil , err
950
- }
951
-
952
- res = make (map [string ]string )
953
- for _ , e := range dl {
954
- res [e .Name ] = e .Value
955
- }
956
- return res , nil
957
- }
958
-
959
914
func runIDEReadinessProbe (cfg * Config , ideConfig * IDEConfig , ide IDEKind ) (desktopIDEStatus * DesktopIDEStatus ) {
960
915
defer log .WithField ("ide" , ide .String ()).Info ("IDE is ready" )
961
916
@@ -1224,15 +1179,15 @@ func stopWhenTasksAreDone(ctx context.Context, wg *sync.WaitGroup, shutdown chan
1224
1179
shutdown <- ShutdownReasonSuccess
1225
1180
}
1226
1181
1227
- func startSSHServer (ctx context.Context , cfg * Config , wg * sync.WaitGroup , childProcEnvvars [] string ) {
1182
+ func startSSHServer (ctx context.Context , cfg * Config , wg * sync.WaitGroup ) {
1228
1183
defer wg .Done ()
1229
1184
1230
1185
if cfg .isHeadless () {
1231
1186
return
1232
1187
}
1233
1188
1234
1189
go func () {
1235
- ssh , err := newSSHServer (ctx , cfg , childProcEnvvars )
1190
+ ssh , err := newSSHServer (ctx , cfg )
1236
1191
if err != nil {
1237
1192
log .WithError (err ).Error ("err starting SSH server" )
1238
1193
}
0 commit comments