Skip to content

Commit 4a24742

Browse files
committed
considered default value event if it was empty in non terminal env
1 parent c1f2f46 commit 4a24742

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/devspace/config/loader/variable/undefined_variable.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ func askQuestion(variable *latest.Variable, log log.Logger) (string, error) {
9191
if variable.Default != "" {
9292
params.DefaultValue = fmt.Sprintf("%v", variable.Default)
9393
}
94-
94+
if variable.Default != nil {
95+
params.DefaultValueSet = true
96+
}
9597
if len(variable.Options) > 0 {
9698
params.Options = variable.Options
99+
if variable.Default == nil {
100+
params.DefaultValue = params.Options[0]
101+
}
97102
} else if variable.ValidationPattern != "" {
98103
params.ValidationRegexPattern = variable.ValidationPattern
99104

pkg/util/log/stream_logger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,9 @@ func (s *StreamLogger) Question(params *survey.QuestionOptions) (string, error)
516516
s.m.Lock()
517517
defer s.m.Unlock()
518518

519-
if !s.isTerminal && (params.DefaultValue == "" || params.DefaultValue == "<nil>") {
519+
if !s.isTerminal && !params.DefaultValueSet {
520520
return "", fmt.Errorf("cannot ask question '%s' because currently you're not using devspace in a terminal and default value is also not provided", params.Question)
521-
} else if !s.isTerminal && params.DefaultValue != "" {
521+
} else if !s.isTerminal && params.DefaultValueSet {
522522
return params.DefaultValue, nil
523523
}
524524

pkg/util/survey/survey.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
type QuestionOptions struct {
1414
Question string
1515
DefaultValue string
16+
DefaultValueSet bool
1617
ValidationRegexPattern string
1718
ValidationMessage string
1819
ValidationFunc func(value string) error

0 commit comments

Comments
 (0)