aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/internal/rb
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-07-11 17:21:27 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-07-11 18:28:51 -0700
commitd0182270d9169c4928bdbdefc5b83b67ff3b457e (patch)
tree3a64a080e4c80f19401f23d65e61ddbcab719952 /src/k8splugin/internal/rb
parentba082d48a4be3471b58444e94f2b89ebe3a9d5e8 (diff)
Create dir before extracting archive
Some archives don't include a directory entry. Eg: tgz archives generated by helm package. This bug fix checks that a directory exists before an extracted file is created there. Issue-ID: MULTICLOUD-705 Change-Id: If6720948d470b83786901574f5d8d3227835a047 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/internal/rb')
-rw-r--r--src/k8splugin/internal/rb/archive.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/k8splugin/internal/rb/archive.go b/src/k8splugin/internal/rb/archive.go
index 624adfba..c0753134 100644
--- a/src/k8splugin/internal/rb/archive.go
+++ b/src/k8splugin/internal/rb/archive.go
@@ -24,6 +24,8 @@ import (
"io/ioutil"
"os"
"path/filepath"
+
+ utils "github.com/onap/multicloud-k8s/src/k8splugin/internal"
)
func isTarGz(r io.Reader) error {
@@ -113,6 +115,11 @@ func ExtractTarBall(r io.Reader) (string, error) {
}
}
case tar.TypeReg:
+ err = utils.EnsureDirectory(target)
+ if err != nil {
+ return "", pkgerrors.Wrap(err, "Creating Directory")
+ }
+
f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
if err != nil {
return "", pkgerrors.Wrap(err, "Creating file")