Skip to content

Commit c4e4ff9

Browse files
committed
Accept stack.yaml as a default file if present
Requested by @welteki, if stack.yml is present then it is taken to be the default with a --yaml/-f argument being needed. This change also looks for stack.yaml as a valid alternative name. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 7fdb7f7 commit c4e4ff9

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

commands/faas.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ import (
2121
)
2222

2323
const (
24-
defaultGateway = "http://127.0.0.1:8080"
25-
defaultNetwork = ""
26-
defaultYAML = "stack.yml"
24+
defaultGateway = "http://127.0.0.1:8080"
25+
defaultNetwork = ""
26+
defaultYML = "stack.yml"
27+
defaultYAML = "stack.yaml"
28+
2729
defaultSchemaVersion = "1.0"
2830
)
2931

@@ -144,6 +146,8 @@ func checkAndSetDefaultYaml() {
144146
// Check if there is a default yaml file and set it
145147
if _, err := stat(defaultYAML); err == nil {
146148
yamlFile = defaultYAML
149+
} else if _, err := stat(defaultYML); err == nil {
150+
yamlFile = defaultYML
147151
}
148152
}
149153

commands/faas_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package commands
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"os"
66
"testing"
77
)
@@ -11,15 +11,15 @@ var mockStatParams string
1111
func setupFaas(statError error) {
1212
yamlFile = ""
1313
mockStatParams = ""
14-
faasCmd.SetOutput(ioutil.Discard)
14+
faasCmd.SetOutput(io.Discard)
1515

1616
stat = func(f string) (os.FileInfo, error) {
1717
mockStatParams = f
1818
return nil, statError
1919
}
2020
}
2121

22-
func TestCallsStatWithDefaulYAMLFileName(t *testing.T) {
22+
func TestCallsStatWithDefaultYAMLFileName(t *testing.T) {
2323
setupFaas(nil)
2424

2525
Execute([]string{"help"})

commands/template_store_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func getTemplateInfo(repository string) ([]TemplateInfo, error) {
138138

139139
templatesInfo := []TemplateInfo{}
140140
if err := json.Unmarshal(body, &templatesInfo); err != nil {
141-
return nil, fmt.Errorf("can't unmarshal text: %s", err.Error())
141+
return nil, fmt.Errorf("can't unmarshal text: %s, value: %s", err.Error(), string(body))
142142
}
143143

144144
sortTemplates(templatesInfo)

0 commit comments

Comments
 (0)