From fedf6b6e5b565827832b9ffcaab6f409bc1cb45c Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Thu, 31 May 2018 03:01:40 +0800 Subject: [PATCH] Check spec directory exists before reading spec files (#709) * Check spec directory exists before reading spec files * Fix spec example --- examples/spec-example/hello/build.sh | 4 ++-- examples/spec-example/specs/env.yaml | 4 ++-- fission/spec.go | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/spec-example/hello/build.sh b/examples/spec-example/hello/build.sh index 3edecfcb..6f1ed084 100755 --- a/examples/spec-example/hello/build.sh +++ b/examples/spec-example/hello/build.sh @@ -3,7 +3,7 @@ set -e # check syntax -python -m compileall -l ${SRC_PKG} +python3 -m compileall -l ${SRC_PKG} # install deps -pip install -r ${SRC_PKG}/requirements.txt -t ${SRC_PKG} && cp -r ${SRC_PKG} ${DEPLOY_PKG} +pip3 install -r ${SRC_PKG}/requirements.txt -t ${SRC_PKG} && cp -r ${SRC_PKG} ${DEPLOY_PKG} diff --git a/examples/spec-example/specs/env.yaml b/examples/spec-example/specs/env.yaml index 6ede44ff..082c5e98 100644 --- a/examples/spec-example/specs/env.yaml +++ b/examples/spec-example/specs/env.yaml @@ -7,6 +7,6 @@ spec: version: 2 builder: command: build - image: fission/python-build-env-2.7:0.4.0rc + image: fission/python-builder runtime: - image: fission/python-env-2.7:0.4.0rc + image: fission/python-env diff --git a/fission/spec.go b/fission/spec.go index d3e42230..cc9bfb39 100644 --- a/fission/spec.go +++ b/fission/spec.go @@ -520,6 +520,12 @@ func (fr *FissionResources) parseYaml(b []byte, loc *location) error { // readSpecs reads all specs in the specified directory and returns a parsed set of // fission resources. func readSpecs(specDir string) (*FissionResources, error) { + + // make sure spec directory exists before continue + if _, err := os.Stat(specDir); os.IsNotExist(err) { + fatal(fmt.Sprintf("Spec directory %v doesn't exist. Please check directory path or run \"fission spec init\" to create it.", specDir)) + } + fr := FissionResources{ packages: make([]crd.Package, 0), functions: make([]crd.Function, 0),