Skip to content

Commit 14d20ce

Browse files
authored
[code] Cleanup unused replace rules (#18888)
1 parent 9f5c35c commit 14d20ce

File tree

2 files changed

+0
-116
lines changed

2 files changed

+0
-116
lines changed

components/ide/code/codehelper/main.go

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package main
66

77
import (
8-
"bytes"
98
"context"
109
"errors"
1110
"fmt"
@@ -49,10 +48,6 @@ func main() {
4948
log.Info("codehelper started")
5049
startTime := time.Now()
5150

52-
if err := replaceOpenVSXUrl(); err != nil {
53-
log.WithError(err).Error("failed to replace OpenVSX URL")
54-
}
55-
5651
phaseDone := phaseLogging("ResolveWsInfo")
5752
cstate, wsInfo, err := resolveWorkspaceInfo(context.Background())
5853
if err != nil || wsInfo == nil {
@@ -68,18 +63,6 @@ func main() {
6863
}
6964
domain := url.Hostname()
7065

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-
8366
// code server args install extension with id
8467
args := []string{}
8568

@@ -237,60 +220,3 @@ func phaseLogging(phase string) context.CancelFunc {
237220
}()
238221
return cancel
239222
}
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-
}

install/installer/pkg/components/blobserve/configmap.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ import (
2121
)
2222

2323
func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
24-
// todo(sje): find this value
25-
hasOpenVSXProxy := true
26-
27-
// todo(sje): find this value
28-
//nolint:typecheck
29-
openVSXProxyUrl := "vsx-proxy-host"
30-
if hasOpenVSXProxy {
31-
openVSXProxyUrl = fmt.Sprintf("https://open-vsx.%s", ctx.Config.Domain)
32-
}
33-
34-
// Check also link below before change values
35-
// https://github.com/gitpod-io/gitpod/blob/2cba7bd1d8a2accd294ab7733f6da4532e48984c/components/ide/code/startup.sh#L37
36-
extensionsGalleryItemUrl := "https://open-vsx.org/vscode/item"
37-
trustedDomain := "https://open-vsx.org"
38-
3924
bscfg := blobserve_config.Config{
4025
BlobServe: blobserve_config.BlobServe{
4126
Port: ContainerPort,
@@ -44,38 +29,11 @@ func configmap(ctx *common.RenderContext) ([]runtime.Object, error) {
4429
ctx.RepoName(ctx.Config.Repository, ide.CodeIDEImage): {
4530
PrePull: []string{},
4631
Workdir: "/ide",
47-
Replacements: []blobserve_config.StringReplacement{{
48-
Search: "vscode-cdn.net",
49-
Replacement: ctx.Config.Domain,
50-
Path: "/ide/out/vs/workbench/workbench.web.main.js",
51-
}, {
52-
Search: "https://open-vsx.org",
53-
Replacement: openVSXProxyUrl,
54-
Path: "/ide/out/vs/workbench/workbench.web.main.js",
55-
}, {
56-
Search: "{{extensionsGalleryItemUrl}}",
57-
Replacement: extensionsGalleryItemUrl,
58-
Path: "/ide/out/vs/workbench/workbench.web.main.js",
59-
}, {
60-
Search: "{{trustedDomain}}",
61-
Replacement: trustedDomain,
62-
Path: "/ide/out/vs/workbench/workbench.web.main.js",
63-
}, {
64-
Search: "ide.gitpod.io/code/markeplace.json",
65-
Replacement: fmt.Sprintf("ide.%s/code/marketplace.json", ctx.Config.Domain),
66-
Path: "/ide/out/vs/workbench/workbench.web.main.js",
67-
}},
6832
// TODO consider to provide it as a part of image label or rather inline ${ide} and ${supervisor} in index.html
6933
// to decouple blobserve and code image
7034
InlineStatic: []blobserve_config.InlineReplacement{{
7135
Search: "{{WORKBENCH_WEB_BASE_URL}}",
7236
Replacement: "${ide}",
73-
}, {
74-
Search: "window.location.origin;",
75-
Replacement: "'${ide}';",
76-
}, {
77-
Search: "./out",
78-
Replacement: "${ide}/out",
7937
}, {
8038
Search: "/_supervisor/frontend",
8139
Replacement: "${supervisor}",

0 commit comments

Comments
 (0)