Skip to content

Commit a8c824b

Browse files
committed
fix: update schema description & refactor
1 parent 5d2ca51 commit a8c824b

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

components/gitpod-protocol/data/gitpod-schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290
},
291291
"vmoptions": {
292292
"type": "string",
293-
"description": "Adjust VM options for the remote IDE server, especially if you want to increase the '-Xmx' memory size when working with a larger project. See https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options"
293+
"description": "Configure VM options, for instance '-Xmx=4096m'."
294294
}
295295
}
296296
},
@@ -324,7 +324,7 @@
324324
},
325325
"vmoptions": {
326326
"type": "string",
327-
"description": "Adjust VM options for the remote IDE server, especially if you want to increase the '-Xmx' memory size when working with a larger project. See https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options"
327+
"description": "Configure VM options, for instance '-Xmx=4096m'."
328328
}
329329
}
330330
},
@@ -358,7 +358,7 @@
358358
},
359359
"vmoptions": {
360360
"type": "string",
361-
"description": "Adjust VM options for the remote IDE server, especially if you want to increase the '-Xmx' memory size when working with a larger project. See https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options"
361+
"description": "Configure VM options, for instance '-Xmx=4096m'."
362362
}
363363
}
364364
},
@@ -392,7 +392,7 @@
392392
},
393393
"vmoptions": {
394394
"type": "string",
395-
"description": "Adjust VM options for the remote IDE server, especially if you want to increase the '-Xmx' memory size when working with a larger project. See https://www.jetbrains.com/help/idea/tuning-the-ide.html#configure-jvm-options"
395+
"description": "Configure VM options, for instance '-Xmx=4096m'."
396396
}
397397
}
398398
}

components/ide/jetbrains/image/status/main.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,13 @@ func main() {
7777
log.WithField("cost", time.Now().Local().Sub(startTime).Milliseconds()).Info("content available")
7878

7979
repoRoot := wsInfo.GetCheckoutLocation()
80+
gitpodConfig, err := parseGitpodConfig(repoRoot)
81+
if err != nil {
82+
log.WithError(err).Error("parse .gitpod.yml failed")
83+
}
8084
version_2022_1, _ := version.NewVersion("2022.1")
8185
if version_2022_1.LessThanOrEqual(backendVersion) {
82-
err = installPlugins(repoRoot, alias)
86+
err = installPlugins(repoRoot, gitpodConfig, alias)
8387
installPluginsCost := time.Now().Local().Sub(startTime).Milliseconds()
8488
if err != nil {
8589
log.WithError(err).WithField("cost", installPluginsCost).Error("installing repo plugins: done")
@@ -88,7 +92,7 @@ func main() {
8892
}
8993
}
9094

91-
err = configureVMOptions(repoRoot, alias)
95+
err = configureVMOptions(gitpodConfig, alias)
9296
if err != nil {
9397
log.WithError(err).Error("failed to configure vmoptions")
9498
}
@@ -308,7 +312,7 @@ func handleSignal(projectPath string) {
308312
log.Info("asked IDE to terminate")
309313
}
310314

311-
func configureVMOptions(repoRoot string, alias string) error {
315+
func configureVMOptions(config *gitpod.GitpodConfig, alias string) error {
312316
idePrefix := alias
313317
if alias == "intellij" {
314318
idePrefix = "idea"
@@ -319,7 +323,7 @@ func configureVMOptions(repoRoot string, alias string) error {
319323
if err != nil {
320324
return err
321325
}
322-
newContent := updateVMOptions(repoRoot, alias, string(content))
326+
newContent := updateVMOptions(config, alias, string(content))
323327
return ioutil.WriteFile(path, []byte(newContent), 0)
324328
}
325329

@@ -341,7 +345,7 @@ func deduplicateVMOption(oldLines []string, newLines []string, predicate func(l,
341345
return result
342346
}
343347

344-
func updateVMOptions(repoRoot string, alias string, content string) string {
348+
func updateVMOptions(config *gitpod.GitpodConfig, alias string, content string) string {
345349
// inspired by how intellij platform merge the VMOptions
346350
// https://github.com/JetBrains/intellij-community/blob/master/platform/platform-impl/src/com/intellij/openapi/application/ConfigImportHelper.java#L1115
347351
filterFunc := func(l, r string) bool {
@@ -367,9 +371,8 @@ func updateVMOptions(repoRoot string, alias string, content string) string {
367371
}
368372

369373
// user-defined vmoptions (.gitpod.yml)
370-
gitpodConfig, err := parseGitpodConfig(repoRoot)
371-
if gitpodConfig != nil && err == nil {
372-
productConfig := getProductConfig(gitpodConfig, alias)
374+
if config != nil {
375+
productConfig := getProductConfig(config, alias)
373376
if productConfig != nil {
374377
userVMOptions = strings.Fields(productConfig.VMOptions)
375378
if len(userVMOptions) > 0 {
@@ -424,8 +427,8 @@ func resolveBackendVersion() (*version.Version, error) {
424427
return version.NewVersion(info.Version)
425428
}
426429

427-
func installPlugins(repoRoot string, alias string) error {
428-
plugins, err := getPlugins(repoRoot, alias)
430+
func installPlugins(repoRoot string, config *gitpod.GitpodConfig, alias string) error {
431+
plugins, err := getPlugins(config, alias)
429432
if err != nil {
430433
return err
431434
}
@@ -491,12 +494,8 @@ func parseGitpodConfig(repoRoot string) (*gitpod.GitpodConfig, error) {
491494
return config, nil
492495
}
493496

494-
func getPlugins(repoRoot string, alias string) ([]string, error) {
497+
func getPlugins(config *gitpod.GitpodConfig, alias string) ([]string, error) {
495498
var plugins []string
496-
config, err := parseGitpodConfig(repoRoot)
497-
if err != nil {
498-
return nil, err
499-
}
500499
if config == nil || config.JetBrains == nil {
501500
return nil, nil
502501
}

components/ide/jetbrains/image/status/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestUpdateVMOptions(t *testing.T) {
5858
lessFunc := func(a, b string) bool { return a < b }
5959

6060
t.Run(test.Desc, func(t *testing.T) {
61-
actual := updateVMOptions("", test.Alias, test.Src)
61+
actual := updateVMOptions(nil, test.Alias, test.Src)
6262
if diff := cmp.Diff(strings.Fields(test.Expectation), strings.Fields(actual), cmpopts.SortSlices(lessFunc)); diff != "" {
6363
t.Errorf("unexpected output (-want +got):\n%s", diff)
6464
}
@@ -67,7 +67,7 @@ func TestUpdateVMOptions(t *testing.T) {
6767
t.Run("updateVMOptions multiple time should be stable", func(t *testing.T) {
6868
actual := test.Src
6969
for i := 0; i < 5; i++ {
70-
actual = updateVMOptions("", test.Alias, actual)
70+
actual = updateVMOptions(nil, test.Alias, actual)
7171
if diff := cmp.Diff(strings.Fields(test.Expectation), strings.Fields(actual), cmpopts.SortSlices(lessFunc)); diff != "" {
7272
t.Errorf("unexpected output (-want +got):\n%s", diff)
7373
}

0 commit comments

Comments
 (0)