5
5
package main
6
6
7
7
import (
8
- "bytes"
9
8
"context"
10
9
"errors"
11
10
"fmt"
@@ -49,10 +48,6 @@ func main() {
49
48
log .Info ("codehelper started" )
50
49
startTime := time .Now ()
51
50
52
- if err := replaceOpenVSXUrl (); err != nil {
53
- log .WithError (err ).Error ("failed to replace OpenVSX URL" )
54
- }
55
-
56
51
phaseDone := phaseLogging ("ResolveWsInfo" )
57
52
cstate , wsInfo , err := resolveWorkspaceInfo (context .Background ())
58
53
if err != nil || wsInfo == nil {
@@ -68,18 +63,6 @@ func main() {
68
63
}
69
64
domain := url .Hostname ()
70
65
71
- if wsInfo .DebugWorkspaceType != supervisor .DebugWorkspaceType_noDebug {
72
- // TODO actually should be performed always
73
- // the better way would be to apply replacements during a workspace start
74
- // to aling with content in blobserve
75
- if err := prepareWebWorkbenchMain (domain ); err != nil {
76
- log .WithError (err ).Error ("failed to prepare web workbench" )
77
- }
78
- if err := prepareServerMain (domain ); err != nil {
79
- log .WithError (err ).Error ("failed to prepare server" )
80
- }
81
- }
82
-
83
66
// code server args install extension with id
84
67
args := []string {}
85
68
@@ -237,60 +220,3 @@ func phaseLogging(phase string) context.CancelFunc {
237
220
}()
238
221
return cancel
239
222
}
240
-
241
- func replaceOpenVSXUrl () error {
242
- phase := phaseLogging ("ReplaceOpenVSXUrl" )
243
- defer phase ()
244
- b , err := os .ReadFile (ProductJsonLocation )
245
- if err != nil {
246
- return errors .New ("failed to read product.json: " + err .Error ())
247
- }
248
- b = replaceOpenVSX (b )
249
- if err := os .WriteFile (ProductJsonLocation , b , 0644 ); err != nil {
250
- return errors .New ("failed to write product.json: " + err .Error ())
251
- }
252
- return nil
253
- }
254
-
255
- // TODO it is be applied as well by blobserve if served for regular workspace location
256
- // reconsider how to configure in all modes, i.e. regular, debug, dev
257
- func prepareWebWorkbenchMain (domain string ) error {
258
- phase := phaseLogging ("prepareWebWorkbenchMain" )
259
- defer phase ()
260
- b , err := os .ReadFile (WebWorkbenchMainLocation )
261
- if err != nil {
262
- return errors .New ("failed to read " + WebWorkbenchMainLocation + ": " + err .Error ())
263
- }
264
- b = bytes .ReplaceAll (b , []byte ("vscode-cdn.net" ), []byte (domain ))
265
- b = bytes .ReplaceAll (b , []byte ("ide.gitpod.io/code/markeplace.json" ), []byte (fmt .Sprintf ("ide.%s/code/marketplace.json" , domain )))
266
-
267
- b = replaceOpenVSX (b )
268
-
269
- if err := os .WriteFile (WebWorkbenchMainLocation , b , 0644 ); err != nil {
270
- return errors .New ("failed to write " + WebWorkbenchMainLocation + ": " + err .Error ())
271
- }
272
- return nil
273
- }
274
-
275
- func prepareServerMain (domain string ) error {
276
- phase := phaseLogging ("prepareServerMain" )
277
- defer phase ()
278
- b , err := os .ReadFile (ServerMainLocation )
279
- if err != nil {
280
- return errors .New ("failed to read " + ServerMainLocation + ": " + err .Error ())
281
- }
282
- b = bytes .ReplaceAll (b , []byte ("https://*.vscode-cdn.net" ), []byte (fmt .Sprintf ("https://%s https://*.%s" , domain , domain )))
283
- if err := os .WriteFile (ServerMainLocation , b , 0644 ); err != nil {
284
- return errors .New ("failed to write " + ServerMainLocation + ": " + err .Error ())
285
- }
286
- return nil
287
- }
288
-
289
- func replaceOpenVSX (b []byte ) []byte {
290
- registryUrl := os .Getenv ("VSX_REGISTRY_URL" )
291
- if registryUrl != "" {
292
- b = bytes .ReplaceAll (b , []byte ("https://open-vsx.org" ), []byte (registryUrl ))
293
- }
294
- b = bytes .ReplaceAll (b , []byte ("{{extensionsGalleryItemUrl}}" ), []byte ("https://open-vsx.org/vscode/item" ))
295
- return bytes .ReplaceAll (b , []byte ("{{trustedDomain}}" ), []byte ("https://open-vsx.org" ))
296
- }
0 commit comments