summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kud/deployment_infra/playbooks/configure-istio.yml6
-rw-r--r--kud/deployment_infra/playbooks/configure-kud.yml17
-rw-r--r--src/k8splugin/Makefile2
-rw-r--r--src/k8splugin/internal/helm/helm.go14
-rw-r--r--src/k8splugin/internal/rb/archive.go7
-rw-r--r--src/k8splugin/internal/utils.go12
6 files changed, 41 insertions, 17 deletions
diff --git a/kud/deployment_infra/playbooks/configure-istio.yml b/kud/deployment_infra/playbooks/configure-istio.yml
index 3a1ca8ed..f975e309 100644
--- a/kud/deployment_infra/playbooks/configure-istio.yml
+++ b/kud/deployment_infra/playbooks/configure-istio.yml
@@ -9,14 +9,10 @@
##############################################################################
- hosts: localhost
- pre_tasks:
+ tasks:
- name: Load kud variables
include_vars:
file: kud-vars.yml
- roles:
- - role: andrewrothstein.kubernetes-helm
- kubernetes_helm_ver: "v{{ helm_client_version }}"
- tasks:
- name: create istio folder
file:
state: directory
diff --git a/kud/deployment_infra/playbooks/configure-kud.yml b/kud/deployment_infra/playbooks/configure-kud.yml
index 9dcf6f39..0e32e69d 100644
--- a/kud/deployment_infra/playbooks/configure-kud.yml
+++ b/kud/deployment_infra/playbooks/configure-kud.yml
@@ -7,6 +7,23 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+- hosts: localhost
+ pre_tasks:
+ - name: Load kud variables
+ include_vars:
+ file: kud-vars.yml
+ - name: Check if helm client is already installed #It is in single node deployment
+ command: helm version -c
+ register: helm_client
+ failed_when: False
+ changed_when: False
+ check_mode: False
+ roles:
+ - name: andrewrothstein.kubernetes-helm
+ when: helm_client.rc != 0
+ vars:
+ kubernetes_helm_ver: "v{{ helm_client_version }}"
+
- hosts: kube-node
become: yes
tasks:
diff --git a/src/k8splugin/Makefile b/src/k8splugin/Makefile
index d5bdb6fc..55449947 100644
--- a/src/k8splugin/Makefile
+++ b/src/k8splugin/Makefile
@@ -44,5 +44,5 @@ clean:
.PHONY: cover
cover:
- @go test ./... -coverprofile=coverage.out
+ @go test -p 2 ./... -coverprofile=coverage.out
@go tool cover -html=coverage.out -o coverage.html
diff --git a/src/k8splugin/internal/helm/helm.go b/src/k8splugin/internal/helm/helm.go
index 1ab701ae..2150758b 100644
--- a/src/k8splugin/internal/helm/helm.go
+++ b/src/k8splugin/internal/helm/helm.go
@@ -21,11 +21,12 @@ import (
"io/ioutil"
"k8s.io/helm/pkg/strvals"
"os"
- "path"
"path/filepath"
"regexp"
"strings"
+ utils "github.com/onap/multicloud-k8s/src/k8splugin/internal"
+
"github.com/ghodss/yaml"
pkgerrors "github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -135,15 +136,6 @@ func (h *TemplateClient) mergeValues(dest map[string]interface{}, src map[string
return dest
}
-func (h *TemplateClient) ensureDirectory(f string) error {
- base := path.Dir(f)
- _, err := os.Stat(base)
- if err != nil && !os.IsNotExist(err) {
- return err
- }
- return os.MkdirAll(base, 0755)
-}
-
// GenerateKubernetesArtifacts a mapping of type to fully evaluated helm template
func (h *TemplateClient) GenerateKubernetesArtifacts(inputPath string, valueFiles []string,
values []string) ([]KubernetesResourceTemplate, error) {
@@ -245,7 +237,7 @@ func (h *TemplateClient) GenerateKubernetesArtifacts(inputPath string, valueFile
}
mfilePath := filepath.Join(outputDir, m.Name)
- h.ensureDirectory(mfilePath)
+ utils.EnsureDirectory(mfilePath)
err = ioutil.WriteFile(mfilePath, []byte(data), 0666)
if err != nil {
return retData, err
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")
diff --git a/src/k8splugin/internal/utils.go b/src/k8splugin/internal/utils.go
index 627fb305..47a236c2 100644
--- a/src/k8splugin/internal/utils.go
+++ b/src/k8splugin/internal/utils.go
@@ -18,6 +18,7 @@ import (
"log"
"os"
"path/filepath"
+ "path"
"plugin"
"strings"
@@ -128,3 +129,14 @@ func CheckInitialSettings() error {
return nil
}
+
+//EnsureDirectory makes sure that the directories specified in the path exist
+//If not, it will create them, if possible.
+func EnsureDirectory(f string) error {
+ base := path.Dir(f)
+ _, err := os.Stat(base)
+ if err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return os.MkdirAll(base, 0755)
+}