Skip to content

Commit 942491b

Browse files
authored
Merge pull request #798 from devspace-cloud/fix/deferred-request-command
minor fixes and improvements
2 parents 09eaf85 + 311cc92 commit 942491b

File tree

4 files changed

+50
-34
lines changed

4 files changed

+50
-34
lines changed

dist/npm/index.js

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,34 @@ exec("npm bin -g || yarn global bin", function(err, stdout, stderr) {
174174

175175
if (action == "uninstall") {
176176
let removeGlobalFolder = function() {
177-
inquirer
178-
.prompt([
179-
{
180-
type: "list",
181-
name: "removeGlobalFolder",
182-
message: "Do you want to remove the global DevSpace config folder ~/.devspace?",
183-
choices: ["no", "yes"],
184-
},
185-
])
186-
.then(answers => {
187-
if (answers.removeGlobalFolder == "yes") {
188-
try {
189-
let homedir = require('os').homedir();
190-
rimraf(homedir + path.sep + ".devspace");
191-
} catch (e) {
192-
console.error(e)
177+
try {
178+
let homedir = require('os').homedir();
179+
rimraf(homedir + path.sep + ".devspace");
180+
} catch (e) {
181+
console.error(e)
182+
}
183+
};
184+
185+
let checkRemoveGlobalFolder = function() {
186+
if (process.stdout.isTTY) {
187+
inquirer
188+
.prompt([
189+
{
190+
type: "list",
191+
name: "checkRemoveGlobalFolder",
192+
message: "Do you want to remove the global DevSpace config folder ~/.devspace?",
193+
choices: ["no", "yes"],
194+
},
195+
])
196+
.then(answers => {
197+
if (answers.checkRemoveGlobalFolder == "yes") {
198+
removeGlobalFolder();
193199
}
194-
}
195-
});
200+
});
201+
} else {
202+
console.warn("DevSpace will remvove the global ~/.devspace folder without asking because this uninstall call is being executed in a non-interactive environment.")
203+
removeGlobalFolder();
204+
}
196205
};
197206

198207
if (process.ppid > 1) {
@@ -204,19 +213,19 @@ exec("npm bin -g || yarn global bin", function(err, stdout, stderr) {
204213
if (list.length == 1 && /npm-cli.js("|')\s+up(date)?\s+(.+\s+)?devspace((\s)|$)/.test(list[0].cmd)) {
205214
// Do not ask to remove global folder because user runs: npm upgrade
206215
} else {
207-
removeGlobalFolder();
216+
checkRemoveGlobalFolder();
208217
}
209218
}, function () {
210-
removeGlobalFolder();
219+
checkRemoveGlobalFolder();
211220
})
212221
} else {
213-
removeGlobalFolder();
222+
checkRemoveGlobalFolder();
214223
}
215224
}, function () {
216-
removeGlobalFolder();
225+
checkRemoveGlobalFolder();
217226
})
218227
} else {
219-
removeGlobalFolder();
228+
checkRemoveGlobalFolder();
220229
}
221230
}
222231

pkg/devspace/config/versions/latest/schema.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,11 @@ type AutoScalingConfig struct {
201201

202202
// AutoScalingHorizontalConfig holds the horizontal autoscaling config of a component
203203
type AutoScalingHorizontalConfig struct {
204-
MaxReplicas *int `yaml:"maxReplicas,omitempty"`
205-
AverageCPU string `yaml:"averageCPU,omitempty"`
206-
AverageMemory string `yaml:"averageMemory,omitempty"`
204+
MaxReplicas *int `yaml:"maxReplicas,omitempty"`
205+
AverageCPU string `yaml:"averageCPU,omitempty"`
206+
AverageRelativeCPU string `yaml:"averageRelativeCPU,omitempty"`
207+
AverageMemory string `yaml:"averageMemory,omitempty"`
208+
AverageRelativeMemory string `yaml:"averageRelativeMemory,omitempty"`
207209
}
208210

209211
// RollingUpdateConfig holds the configuration for rolling updates

pkg/devspace/deploy/helm/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// DevSpaceChartConfig is the config that holds the devspace chart information
1313
var DevSpaceChartConfig = &latest.ChartConfig{
1414
Name: "component-chart",
15-
Version: "v0.0.6",
15+
Version: "v0.0.8",
1616
RepoURL: "https://charts.devspace.cloud",
1717
}
1818

pkg/util/analytics/analytics.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func (a *analyticsConfig) sendRequest(requestURL string, data map[string]interfa
329329
return errors.Errorf("Couldn't marshal analytics headers: %v", err)
330330
}
331331

332-
args := []string{DEFERRED_REQUEST_COMMAND, "POST", base64.StdEncoding.EncodeToString([]byte(requestURL.String())), base64.StdEncoding.EncodeToString(jsonRequestBody), base64.StdEncoding.EncodeToString(jsonHeaders)}
332+
args := []string{DEFERRED_REQUEST_COMMAND, "POST", base64.StdEncoding.EncodeToString([]byte(requestURL.String())), base64.StdEncoding.EncodeToString(jsonHeaders), base64.StdEncoding.EncodeToString(jsonRequestBody)}
333333
executable, err := os.Executable()
334334
if err != nil {
335335
executable = os.Args[0]
@@ -344,7 +344,7 @@ func (a *analyticsConfig) sendRequest(requestURL string, data map[string]interfa
344344

345345
// HandleDeferredRequest sends a request if args are: executable, DEFERRED_REQUEST_COMMAND
346346
func (a *analyticsConfig) HandleDeferredRequest() error {
347-
if len(os.Args) < 6 || os.Args[1] != DEFERRED_REQUEST_COMMAND {
347+
if len(os.Args) < 5 || os.Args[1] != DEFERRED_REQUEST_COMMAND {
348348
return nil
349349
}
350350

@@ -353,15 +353,20 @@ func (a *analyticsConfig) HandleDeferredRequest() error {
353353
if err != nil {
354354
return errors.Errorf("Couldn't base64.decode request URL: %v", err)
355355
}
356-
requestBody, err := base64.StdEncoding.DecodeString(os.Args[4])
357-
if err != nil {
358-
return errors.Errorf("Couldn't base64.decode request body: %v", err)
359-
}
360-
jsonRequestHeaders, err := base64.StdEncoding.DecodeString(os.Args[5])
356+
357+
jsonRequestHeaders, err := base64.StdEncoding.DecodeString(os.Args[4])
361358
if err != nil {
362359
return errors.Errorf("Couldn't base64.decode request headers: %v", err)
363360
}
364361

362+
requestBody := []byte{}
363+
if len(os.Args) > 5 {
364+
requestBody, err = base64.StdEncoding.DecodeString(os.Args[5])
365+
if err != nil {
366+
return errors.Errorf("Couldn't base64.decode request body: %v", err)
367+
}
368+
}
369+
365370
requestHeaders := map[string][]string{}
366371
err = json.Unmarshal([]byte(jsonRequestHeaders), &requestHeaders)
367372
if err != nil {

0 commit comments

Comments
 (0)