Skip to content

Commit c2454e9

Browse files
committed
fix: bugs for skaffold.yaml files read in via stdin
1 parent cb636a8 commit c2454e9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/skaffold/parser/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func getConfigs(ctx context.Context, cfgOpts configOpts, opts config.SkaffoldOpt
107107
return nil, sErrors.ConfigParsingError(err)
108108
}
109109

110-
if !util.IsURL(cfgOpts.file) && !filepath.IsAbs(cfgOpts.file) {
110+
if !util.IsURL(cfgOpts.file) && !filepath.IsAbs(cfgOpts.file) && cfgOpts.file != "-" {
111111
cwd, _ := util.RealWorkDir()
112112
// convert `file` path to absolute value as it's used as a map key in several places.
113113
cfgOpts.file = filepath.Join(cwd, cfgOpts.file)

pkg/skaffold/util/config.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@ import (
2525
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
2626
)
2727

28+
var stdin []byte
29+
2830
// ReadConfiguration reads a `skaffold.yaml` configuration and
2931
// returns its content.
3032
func ReadConfiguration(filename string) ([]byte, error) {
3133
switch {
3234
case filename == "":
3335
return nil, errors.New("filename not specified")
3436
case filename == "-":
35-
return ioutil.ReadAll(os.Stdin)
37+
if len(stdin) == 0 {
38+
var err error
39+
stdin, err = ioutil.ReadAll(os.Stdin)
40+
if err != nil {
41+
return []byte{}, err
42+
}
43+
}
44+
return stdin, nil
3645
case IsURL(filename):
3746
return Download(filename)
3847
default:

0 commit comments

Comments
 (0)