aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdeployments/build.sh1
-rw-r--r--src/k8splugin/api/defhandler.go6
-rw-r--r--src/k8splugin/api/defhandler_test.go10
-rw-r--r--src/k8splugin/go.mod66
-rw-r--r--src/k8splugin/go.sum167
-rw-r--r--src/k8splugin/internal/db/mongo.go38
-rw-r--r--src/k8splugin/internal/db/mongo_test.go66
-rw-r--r--src/k8splugin/internal/helm/helm.go259
-rw-r--r--src/k8splugin/internal/helm/helm_test.go195
-rw-r--r--src/k8splugin/internal/rb/definition.go43
-rw-r--r--src/k8splugin/internal/rb/definition_test.go89
-rw-r--r--src/k8splugin/internal/rb/profile.go8
-rw-r--r--src/k8splugin/internal/rb/profile_yaml.go109
-rw-r--r--src/k8splugin/internal/rb/profile_yaml_test.go139
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/Chart.yaml4
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml4
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml15
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml17
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml4
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml15
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml35
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/templates/NOTES.txt1
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/templates/service.yaml22
-rw-r--r--src/k8splugin/mock_files/mock_charts/testchart1/values.yaml55
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml7
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/faulty-manifest.yaml8
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml7
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/manifest.yaml7
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/override_values.yaml9
-rw-r--r--src/k8splugin/mock_files/mock_profiles/profile1/subdir/p1.yaml22
-rw-r--r--vagrant/playbooks/krd-vars.yml2
-rwxr-xr-xvagrant/tests/_common.sh22
-rwxr-xr-xvagrant/tests/_functions.sh8
-rw-r--r--vagrant/tests/cFW/README.md10
-rw-r--r--vagrant/tests/cFW/Vagrantfile33
-rw-r--r--vagrant/tests/cFW/darkstat/Dockerfile14
-rw-r--r--vagrant/tests/cFW/docker-compose.yml38
-rw-r--r--vagrant/tests/cFW/firewall/Dockerfile49
-rw-r--r--vagrant/tests/cFW/packetgen/Dockerfile44
-rwxr-xr-xvagrant/tests/cFW/postinstall.sh83
-rw-r--r--vagrant/tests/cFW/sink/Dockerfile34
-rw-r--r--vagrant/tests/cFW/vpp/80-vpp.conf15
-rw-r--r--vagrant/tests/cFW/vpp/Dockerfile17
-rwxr-xr-xvagrant/tests/plugin.sh82
-rw-r--r--vagrant/tests/vnfs/testrb/helm/profile/manifest.yaml7
-rw-r--r--vagrant/tests/vnfs/testrb/helm/profile/override_values.yaml7
-rw-r--r--vagrant/tests/vnfs/testrb/helm/profile/testfol/subdir/deployment.yaml51
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/Chart.yaml19
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/Chart.yaml18
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_name.tpl31
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_namespace.tpl26
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_repository.tpl48
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_service.tpl31
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/values.yaml44
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/deployment.yaml62
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/service.yaml39
-rw-r--r--vagrant/tests/vnfs/testrb/helm/vault-consul-dev/values.yaml90
57 files changed, 2252 insertions, 100 deletions
diff --git a/deployments/build.sh b/deployments/build.sh
index f7deb547..f40542eb 100755
--- a/deployments/build.sh
+++ b/deployments/build.sh
@@ -50,6 +50,7 @@ function _push_image {
local tag_name=${IMAGE_NAME}:${1:-latest}
echo "Start push {$tag_name}"
+ docker push ${IMAGE_NAME}:latest
docker tag ${IMAGE_NAME}:latest ${tag_name}
docker push ${tag_name}
}
diff --git a/src/k8splugin/api/defhandler.go b/src/k8splugin/api/defhandler.go
index 21e5e768..44521dd1 100644
--- a/src/k8splugin/api/defhandler.go
+++ b/src/k8splugin/api/defhandler.go
@@ -54,12 +54,6 @@ func (h rbDefinitionHandler) createHandler(w http.ResponseWriter, r *http.Reques
return
}
- // Chart Name is required
- if v.ChartName == "" {
- http.Error(w, "Missing chart name in POST request", http.StatusBadRequest)
- return
- }
-
ret, err := h.client.Create(v)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
diff --git a/src/k8splugin/api/defhandler_test.go b/src/k8splugin/api/defhandler_test.go
index 20ef537e..48e2406c 100644
--- a/src/k8splugin/api/defhandler_test.go
+++ b/src/k8splugin/api/defhandler_test.go
@@ -125,16 +125,6 @@ func TestRBDefCreateHandler(t *testing.T) {
expectedCode: http.StatusBadRequest,
rbDefClient: &mockRBDefinition{},
},
- {
- label: "Missing Chart Name in Request Body",
- reader: bytes.NewBuffer([]byte(`{
- "name":"testresourcebundle",
- "description":"test description",
- "service-type":"firewall"
- }`)),
- expectedCode: http.StatusBadRequest,
- rbDefClient: &mockRBDefinition{},
- },
}
for _, testCase := range testCases {
diff --git a/src/k8splugin/go.mod b/src/k8splugin/go.mod
index c6d2ef23..29a10ecb 100644
--- a/src/k8splugin/go.mod
+++ b/src/k8splugin/go.mod
@@ -1,55 +1,91 @@
module k8splugin
require (
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/ghodss/yaml v1.0.0 // indirect
+ github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
+ github.com/BurntSushi/toml v0.3.1 // indirect
+ github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect
+ github.com/Masterminds/semver v1.4.2 // indirect
+ github.com/Masterminds/sprig v2.17.1+incompatible // indirect
+ github.com/aokoli/goutils v1.1.0 // indirect
+ github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
+ github.com/cyphar/filepath-securejoin v0.2.2 // indirect
+ github.com/docker/distribution v2.7.0+incompatible // indirect
+ github.com/docker/docker v0.7.3-0.20190312165151-258edd715d46 // indirect
+ github.com/docker/go-connections v0.4.0 // indirect
+ github.com/docker/go-units v0.3.3 // indirect
+ github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
+ github.com/emicklei/go-restful v2.8.0+incompatible // indirect
+ github.com/evanphx/json-patch v4.1.0+incompatible // indirect
+ github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
+ github.com/fatih/camelcase v1.0.0 // indirect
+ github.com/ghodss/yaml v1.0.0
+ github.com/go-openapi/spec v0.18.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
+ github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.0.0 // indirect
- github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
- github.com/golang/protobuf v1.2.0 // indirect
+ github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c // indirect
github.com/google/go-cmp v0.2.0 // indirect
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
+ github.com/google/uuid v1.1.0 // indirect
github.com/googleapis/gnostic v0.2.0 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect
+ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/consul v1.4.0
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 // indirect
github.com/hashicorp/go-uuid v1.0.0
+ github.com/hashicorp/golang-lru v0.5.0 // indirect
github.com/hashicorp/serf v0.8.1 // indirect
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c // indirect
+ github.com/huandu/xstrings v1.2.0 // indirect
github.com/imdario/mergo v0.3.5 // indirect
+ github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.5 // indirect
+ github.com/mitchellh/go-homedir v1.1.0 // indirect
+ github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81 // indirect
- github.com/mongodb/mongo-go-driver v0.2.0
+ github.com/mongodb/mongo-go-driver v1.0.0
+ github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
+ github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.8.0
- github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/prometheus/client_golang v0.9.2 // indirect
+ github.com/russross/blackfriday v1.5.2 // indirect
+ github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
+ github.com/sirupsen/logrus v1.4.0 // indirect
+ github.com/spf13/cobra v0.0.3 // indirect
github.com/spf13/pflag v1.0.1 // indirect
- github.com/stretchr/testify v1.2.2 // indirect
+ github.com/technosophos/moniker v0.0.0-20180509230615-a5dbd03a2245 // indirect
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51 // indirect
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
- golang.org/x/crypto v0.0.0-20180608092829-8ac0e0d97ce4 // indirect
- golang.org/x/net v0.0.0-20180724234803-3673e40ba225
+ go.mongodb.org/mongo-driver v1.0.0
+ golang.org/x/net v0.0.0-20181201002055-351d144fa1fc
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect
- golang.org/x/sync v0.0.0-20181108010431-42b317875d0f // indirect
- golang.org/x/sys v0.0.0-20180611080425-bff228c7b664 // indirect
- golang.org/x/text v0.3.0 // indirect
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
+ google.golang.org/grpc v1.17.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
+ gopkg.in/square/go-jose.v2 v2.2.2 // indirect
gopkg.in/yaml.v2 v2.2.1
- k8s.io/api v0.0.0-20181130031204-d04500c8c3dd
- k8s.io/apimachinery v0.0.0-20181215012845-4d029f033399
+ k8s.io/api v0.0.0-20181126151915-b503174bad59
+ k8s.io/apiextensions-apiserver v0.0.0-20181126155829-0cd23ebeb688 // indirect
+ k8s.io/apimachinery v0.0.0-20181126123746-eddba98df674
+ k8s.io/apiserver v0.0.0-20181126153457-92fdef3a232a // indirect
+ k8s.io/cli-runtime v0.0.0-20190107235426-31214e12222d // indirect
k8s.io/client-go v2.0.0-alpha.0.0.20181126152608-d082d5923d3c+incompatible
+ k8s.io/helm v2.12.2+incompatible
k8s.io/klog v0.1.0 // indirect
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be // indirect
- k8s.io/utils v0.0.0-20181102055113-1bd4f387aa67
+ k8s.io/kubernetes v1.12.3 // indirect
+ k8s.io/utils v0.0.0-20181221173059-8a16e7dd8fb6
+ sigs.k8s.io/kustomize v1.0.11 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
+ vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787 // indirect
)
diff --git a/src/k8splugin/go.sum b/src/k8splugin/go.sum
index dbc0a60a..f22fe8da 100644
--- a/src/k8splugin/go.sum
+++ b/src/k8splugin/go.sum
@@ -1,13 +1,72 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
+github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
+github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
+github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
+github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e h1:eb0Pzkt15Bm7f2FFYv7sjY7NPFi3cPkS3tv1CcrFBWA=
+github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
+github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
+github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
+github.com/Masterminds/sprig v2.17.1+incompatible h1:PChbxFGKTWsg9IWh+pSZRCSj3zQkVpL6Hd9uWsFwxtc=
+github.com/Masterminds/sprig v2.17.1+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
+github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
+github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
+github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/aokoli/goutils v1.1.0 h1:jy4ghdcYvs5EIoGssZNslIASX5m+KNMfyyKvRQ0TEVE=
+github.com/aokoli/goutils v1.1.0/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
+github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 h1:HD4PLRzjuCVW79mQ0/pdsalOLHJ+FaEoqJLxfltpb2U=
+github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg=
+github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/docker/distribution v2.7.0+incompatible h1:neUDAlf3wX6Ml4HdqTrbcOHXtfRN0TFIwt6YFL7N9RU=
+github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
+github.com/docker/docker v0.7.3-0.20190312165151-258edd715d46 h1:6ulO/mTQ7hN75egZfHioZVG2srV1c7CBXCQsXJmSOQU=
+github.com/docker/docker v0.7.3-0.20190312165151-258edd715d46/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/docker v1.13.1 h1:5VBhsO6ckUxB0A8CE5LlUJdXzik9cbEbBTQ/ggeml7M=
+github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
+github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
+github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
+github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
+github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s=
+github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
+github.com/emicklei/go-restful v2.8.0+incompatible h1:wN8GCRDPGHguIynsnBartv5GUgGUg1LAU7+xnSn1j7Q=
+github.com/emicklei/go-restful v2.8.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc=
+github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
+github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM=
+github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
+github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8=
+github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
+github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680 h1:ZktWZesgun21uEDrwW7iEV1zPCGQldM2atlJZ3TdvVM=
+github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
+github.com/go-openapi/jsonpointer v0.17.0 h1:nH6xp8XdXHx8dqveo0ZuJBluCO2qGrPbDNZ0dwoRHP0=
+github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M=
+github.com/go-openapi/jsonreference v0.17.0 h1:yJW3HCkTHg7NOA+gZ83IPHzUSnUzGXhGmsdiCcMexbA=
+github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I=
+github.com/go-openapi/spec v0.18.0 h1:aIjeyG5mo5/FrvDkpKKEGZPmF9MPHahS72mzfVqeQXQ=
+github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI=
+github.com/go-openapi/swag v0.17.0 h1:iqrgMg7Q7SvtbWLlltPrkMs0UBJI6oTSs79JFRUi880=
+github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
+github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM=
github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
+github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff h1:kOkM9whyQYodu09SJ6W3NCsHG7crFaJILQ22Gozp3lg=
+github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
@@ -18,6 +77,8 @@ github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
+github.com/google/uuid v1.1.0 h1:Jf4mxPC/ziBnoPIdpQdPJ9OeiomAUHLvxmPRSPH9m4s=
+github.com/google/uuid v1.1.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gnostic v0.2.0 h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g=
github.com/googleapis/gnostic v0.2.0/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
@@ -28,6 +89,8 @@ github.com/gorilla/mux v1.6.2 h1:Pgr17XVTNXAk3q/r4CpKzC5xBM/qW1uVLV+IhRZpIIk=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f h1:ShTPMJQes6tubcjzGMODIVG5hlrCeImaBnZzKF2N8SM=
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
+github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/hashicorp/consul v1.4.0 h1:PQTW4xCuAExEiSbhrsFsikzbW5gVBoi74BjUvYFyKHw=
github.com/hashicorp/consul v1.4.0/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI=
github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig=
@@ -36,16 +99,33 @@ github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 h1:9HVkPxOp
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90/go.mod h1:o4zcYY1e0GEZI6eSEr+43QDYmuGglw1qSO6qdHUHCgg=
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
+github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
+github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/serf v0.8.1 h1:mYs6SMzu72+90OcPa5wr3nfznA4Dw9UyR791ZFNOIf4=
github.com/hashicorp/serf v0.8.1/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c h1:kQWxfPIHVLbgLzphqk3QUflDy9QdksZR4ygR807bpy0=
github.com/howeyc/gopass v0.0.0-20170109162249-bf9dde6d0d2c/go.mod h1:lADxMC39cJJqL93Duh1xhAs4I2Zs8mKS89XWXFGp9cs=
+github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
+github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
github.com/imdario/mergo v0.3.5 h1:JboBksRwiiAJWvIYJVo46AfV+IAIKZpfrSzVKj42R4Q=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
+github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
+github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece h1:3HJXp/18JmMk5sjBP3LDUBtWjczCvynxaeAF6b6kWp8=
github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
+github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
+github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
@@ -54,61 +134,148 @@ github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81 h1:ImOHKpmdLPXW
github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/mongodb/mongo-go-driver v0.2.0 h1:MBI/hnb0LiACJRVAlT+nL5wdtV4EFKTjJEhQdapZFB0=
github.com/mongodb/mongo-go-driver v0.2.0/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
+github.com/mongodb/mongo-go-driver v1.0.0 h1:aq055NT+Xu6ta/f7D51gIbLHIZwM0Gwzt9RHfmrzs6A=
+github.com/mongodb/mongo-go-driver v1.0.0/go.mod h1:NK/HWDIIZkaYsnYa0hmtP443T5ELr0KDecmIioVuuyU=
+github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
+github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
+github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
+github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740=
+github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8=
+github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE=
+github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
+github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
+github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
+github.com/russross/blackfriday v2.0.0+incompatible h1:cBXrhZNUf9C+La9/YpS+UHpUT8YD6Td9ZMSU9APFcsk=
+github.com/russross/blackfriday v2.0.0+incompatible/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
+github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
+github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
+github.com/sirupsen/logrus v1.4.0 h1:yKenngtzGh+cUSSh6GWbxW2abRqhYUSR/t/6+2QqNvE=
+github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
+github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
+github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/technosophos/moniker v0.0.0-20180509230615-a5dbd03a2245 h1:DNVk+NIkGS0RbLkjQOLCJb/759yfCysThkMbl7EXxyY=
+github.com/technosophos/moniker v0.0.0-20180509230615-a5dbd03a2245/go.mod h1:O1c8HleITsZqzNZDjSNzirUGsMT0oGu9LhHKoJrqO+A=
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51 h1:BP2bjP495BBPaBcS5rmqviTfrOkN5rO5ceKAMRZCRFc=
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV0YCnDjqSL7/q/JyPhhJSPk=
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
+go.mongodb.org/mongo-driver v1.0.0 h1:KxPRDyfB2xXnDE2My8acoOWBQkfv3tz0SaWTRZjJR0c=
+go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
golang.org/x/crypto v0.0.0-20180608092829-8ac0e0d97ce4 h1:wviDUSmtheHRBfoY8B9U8ELl2USoXi2YFwdGdpIIkzI=
golang.org/x/crypto v0.0.0-20180608092829-8ac0e0d97ce4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
+golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 h1:kNX+jCowfMYzvlSvJu5pQWEmyWFrBXJ3PBy10xKMXK8=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d h1:g9qWBGx4puODJTMVyoPrpoxPFgVGd+z1DZwjfRu4d0I=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 h1:uESlIz09WIHT2I+pasSXcpLYqYK8wHcdCetU3VuMBJE=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180611080425-bff228c7b664 h1:GvcVmbE8Pa64iW3MTrVA9mxHx1HEjSSWV6zF1JSlFcg=
golang.org/x/sys v0.0.0-20180611080425-bff228c7b664/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522 h1:Ve1ORMCxvRmSXBwJK+t3Oy+V2vRW2OetUQBq4rJIkZE=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
+golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.17.0 h1:TRJYBgMclJvGYn2rIMjj+h9KtMt5r1Ij7ODVRIZkwhk=
+google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/square/go-jose.v2 v2.2.2 h1:orlkJ3myw8CN1nVQHBFfloD+L3egixIa4FvUP6RosSA=
+gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20180607235014-72d6e4405f81 h1:OTYaNzRYUjk5sXxfClCTJnBBDAxI43KuldJtfjxx2fE=
k8s.io/api v0.0.0-20180607235014-72d6e4405f81/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
+k8s.io/api v0.0.0-20181126151915-b503174bad59 h1:uXjIvSvNtNUQjqpBznXm29/Ntx/6Aezf/wa0yAFryWE=
+k8s.io/api v0.0.0-20181126151915-b503174bad59/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
k8s.io/api v0.0.0-20181130031204-d04500c8c3dd h1:5aHsneN62ehs/tdtS9tWZlhVk68V7yms/Qw7nsGmvCA=
k8s.io/api v0.0.0-20181130031204-d04500c8c3dd/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
+k8s.io/api v0.0.0-20181221193117-173ce66c1e39 h1:iGq7zEPXFb0IeXAQK5RiYT1SVKX/af9F9Wv0M+yudPY=
+k8s.io/api v0.0.0-20181221193117-173ce66c1e39/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
+k8s.io/apiextensions-apiserver v0.0.0-20181126155829-0cd23ebeb688 h1:sadcWnjCmaJ/cYN8FpBylEjmjskFHLvjbC3MnkhCGIA=
+k8s.io/apiextensions-apiserver v0.0.0-20181126155829-0cd23ebeb688/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
+k8s.io/apiextensions-apiserver v0.0.0-20190103235604-e7617803aceb h1:3yElwSbnV34qIVTlGgkbWwWM+wq7fw6i7EKRtLV6z58=
+k8s.io/apiextensions-apiserver v0.0.0-20190103235604-e7617803aceb/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05 h1:IxbzCht0hGNBVprna3ou1lB+jvFGT2Sh83htT2jL4sk=
k8s.io/apimachinery v0.0.0-20180515182440-31dade610c05/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apimachinery v0.0.0-20181126123746-eddba98df674 h1:S3ImTLK1F6igG0/5Tx8hf08XMRSwxhPfgtCLjs0Q8q4=
+k8s.io/apimachinery v0.0.0-20181126123746-eddba98df674/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
k8s.io/apimachinery v0.0.0-20181215012845-4d029f033399 h1:xdXaRQ7uNX4x6NpvxXASvlVXtKa8+WbCXK7Hjr6XZ6c=
k8s.io/apimachinery v0.0.0-20181215012845-4d029f033399/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apimachinery v0.0.0-20190104073114-849b284f3b75 h1:dLhsGWh58R0WYgTCX6ZdaqSz2FltMZsk+ByHsUgMWRU=
+k8s.io/apimachinery v0.0.0-20190104073114-849b284f3b75/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apiserver v0.0.0-20181126153457-92fdef3a232a h1:+GApCkYtoBEjQZC8bariB5dM4Xa4MmmKId5dLV3AODQ=
+k8s.io/apiserver v0.0.0-20181126153457-92fdef3a232a/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
+k8s.io/apiserver v0.0.0-20190107233756-bcc52745160f h1:k2l9d/byRk1Tpjgx9Pu5qqiZFWiaY5CipqlMmB1zVd8=
+k8s.io/apiserver v0.0.0-20190107233756-bcc52745160f/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
+k8s.io/cli-runtime v0.0.0-20190107235426-31214e12222d h1:hdarETxu5sE+zfQ8CPfvWbQzMe1yaJA1XvURyx1u514=
+k8s.io/cli-runtime v0.0.0-20190107235426-31214e12222d/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM=
k8s.io/client-go v2.0.0-alpha.0.0.20181126152608-d082d5923d3c+incompatible h1:+gASq5lVUhelbDuyHr/ojUKGLZVeUhAFKHbAK8Kymfs=
k8s.io/client-go v2.0.0-alpha.0.0.20181126152608-d082d5923d3c+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/client-go v7.0.0+incompatible h1:gokIETH5yPpln/LuXmg1TLVH5bMSaVQTVxuRizwjWwU=
k8s.io/client-go v7.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
k8s.io/client-go v9.0.0+incompatible h1:/PdJjifJTjMFe0G4ESclZDcwF1+bFePTJ2xf+MXjcvs=
k8s.io/client-go v9.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
+k8s.io/client-go v10.0.0+incompatible h1:h3fciHPG0O5QEzATTFoRw/YGtDsU6pxrMrAhxiTtcq0=
+k8s.io/client-go v10.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
+k8s.io/helm v2.12.1+incompatible h1:Fw6it7ALJfqbbX95U3is3aswD6E8nh4aUYtvgzfna8A=
+k8s.io/helm v2.12.1+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
+k8s.io/helm v2.12.2+incompatible h1:vtddbkiGNMOd8maDDZDc111Rm9E5JeeNWDndows18i8=
+k8s.io/helm v2.12.2+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
k8s.io/klog v0.1.0 h1:I5HMfc/DtuVaGR1KPwUrTc476K8NCqNBldC7H4dYEzk=
k8s.io/klog v0.1.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be h1:aWEq4nbj7HRJ0mtKYjNSk/7X28Tl6TI6FeG8gKF+r7Q=
k8s.io/kube-openapi v0.0.0-20181114233023-0317810137be/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
+k8s.io/kubernetes v1.12.3 h1:LgVHLYuVlSgzMhn0ZRUZBLe2O7MKuJEplLth4s5jPtg=
+k8s.io/kubernetes v1.12.3/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
+k8s.io/kubernetes v1.13.1 h1:hkqyN83WwEjOwJmdVURGT5CP+2oOQ3OV0Dj3LUCs7u8=
+k8s.io/kubernetes v1.13.1/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/utils v0.0.0-20181102055113-1bd4f387aa67 h1:+kBMW7D4cSYIhPz0fVs6NRp5QILMz6+65ec4kWJOoXs=
k8s.io/utils v0.0.0-20181102055113-1bd4f387aa67/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
+k8s.io/utils v0.0.0-20181221173059-8a16e7dd8fb6 h1:+jRzzMyx+I9J18BvwHYmZ5hpPwoZfh6g39WfNlsMCkY=
+k8s.io/utils v0.0.0-20181221173059-8a16e7dd8fb6/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
+sigs.k8s.io/kustomize v1.0.11 h1:Yb+6DDt9+aR2AvQApvUaKS/ugteeG4MPyoFeUHiPOjk=
+sigs.k8s.io/kustomize v1.0.11/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
+vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787 h1:O69FD9pJA4WUZlEwYatBEEkRWKQ5cKodWpdKTrCS/iQ=
+vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787/go.mod h1:so/NYdZXCz+E3ZpW0uAoCj6uzU2+8OWDFv/HxUSs7kI=
diff --git a/src/k8splugin/internal/db/mongo.go b/src/k8splugin/internal/db/mongo.go
index 05976b12..d414f543 100644
--- a/src/k8splugin/internal/db/mongo.go
+++ b/src/k8splugin/internal/db/mongo.go
@@ -17,14 +17,15 @@
package db
import (
- "github.com/mongodb/mongo-go-driver/bson"
- "github.com/mongodb/mongo-go-driver/bson/primitive"
- "github.com/mongodb/mongo-go-driver/mongo"
- "github.com/mongodb/mongo-go-driver/mongo/options"
- pkgerrors "github.com/pkg/errors"
"golang.org/x/net/context"
"log"
"os"
+
+ pkgerrors "github.com/pkg/errors"
+ "go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/bson/primitive"
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
)
// MongoCollection defines the a subset of MongoDB operations
@@ -39,7 +40,7 @@ type MongoCollection interface {
DeleteOne(ctx context.Context, filter interface{},
opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
Find(ctx context.Context, filter interface{},
- opts ...*options.FindOptions) (mongo.Cursor, error)
+ opts ...*options.FindOptions) (*mongo.Cursor, error)
}
// MongoStore is an implementation of the db.Store interface
@@ -60,12 +61,25 @@ var decodeBytes = func(sr *mongo.SingleResult) (bson.Raw, error) {
return sr.DecodeBytes()
}
+// These exists only for allowing us to mock the cursor.Next function
+// Mainly because we cannot construct a mongo.Cursor struct from our
+// tests. All fields in that struct are private and there is no public
+// constructor method.
+var cursorNext = func(ctx context.Context, cursor *mongo.Cursor) bool {
+ return cursor.Next(ctx)
+}
+var cursorClose = func(ctx context.Context, cursor *mongo.Cursor) error {
+ return cursor.Close(ctx)
+}
+
// NewMongoStore initializes a Mongo Database with the name provided
// If a database with that name exists, it will be returned
func NewMongoStore(name string, store *mongo.Database) (Store, error) {
if store == nil {
ip := "mongodb://" + os.Getenv("DATABASE_IP") + ":27017"
- mongoClient, err := mongo.NewClient(ip)
+ clientOptions := options.Client()
+ clientOptions.ApplyURI(ip)
+ mongoClient, err := mongo.NewClient(clientOptions)
if err != nil {
return nil, err
}
@@ -292,16 +306,12 @@ func (m *MongoStore) ReadAll(coll, tag string) (map[string][]byte, error) {
if err != nil {
return nil, pkgerrors.Errorf("Error reading from database: %s", err.Error())
}
- defer cursor.Close(ctx)
+ defer cursorClose(ctx, cursor)
//Iterate over all the master tables
result := make(map[string][]byte)
- for cursor.Next(ctx) {
- d, err := cursor.DecodeBytes()
- if err != nil {
- log.Printf("Unable to decode data in Readall: %s", err.Error())
- continue
- }
+ for cursorNext(ctx, cursor) {
+ d := cursor.Current
//Read key of each master table
key, ok := d.Lookup("key").StringValueOK()
diff --git a/src/k8splugin/internal/db/mongo_test.go b/src/k8splugin/internal/db/mongo_test.go
index 1663e774..973921c3 100644
--- a/src/k8splugin/internal/db/mongo_test.go
+++ b/src/k8splugin/internal/db/mongo_test.go
@@ -21,43 +21,21 @@ package db
import (
"bytes"
"context"
- "github.com/mongodb/mongo-go-driver/bson"
- "github.com/mongodb/mongo-go-driver/mongo"
- "github.com/mongodb/mongo-go-driver/mongo/options"
- pkgerrors "github.com/pkg/errors"
"reflect"
"strings"
"testing"
-)
-
-// Implements the mongo.Cursor interface
-type mockCursor struct {
- mongo.Cursor
- err error
- bson bson.Raw
- count int
-}
-
-func (mc *mockCursor) Next(ctx context.Context) bool {
- if mc.count > 0 {
- mc.count = mc.count - 1
- return true
- }
- return false
-}
-
-func (mc *mockCursor) DecodeBytes() (bson.Raw, error) {
- return mc.bson, mc.err
-}
-func (mc *mockCursor) Close(ctx context.Context) error {
- return nil
-}
+ pkgerrors "github.com/pkg/errors"
+ "go.mongodb.org/mongo-driver/bson"
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/mongo/options"
+)
//Implements the functions used currently in mongo.go
type mockCollection struct {
- Err error
- mCursor mongo.Cursor
+ Err error
+ mCursor *mongo.Cursor
+ mCursorCount int
}
func (c *mockCollection) InsertOne(ctx context.Context, document interface{},
@@ -89,7 +67,7 @@ func (c *mockCollection) DeleteOne(ctx context.Context, filter interface{},
}
func (c *mockCollection) Find(ctx context.Context, filter interface{},
- opts ...*options.FindOptions) (mongo.Cursor, error) {
+ opts ...*options.FindOptions) (*mongo.Cursor, error) {
return c.mCursor, c.Err
}
@@ -415,14 +393,14 @@ func TestReadAll(t *testing.T) {
"tag": "metadata",
},
mockColl: &mockCollection{
- mCursor: &mockCursor{
+ mCursor: &mongo.Cursor{
// Binary form of
// {
// "_id" : ObjectId("5c115156777ff85654248ae1"),
// "key" : "b82c4bb1-09ff-6093-4d58-8327b94e1e20",
// "metadata" : ObjectId("5c115156c9755047e318bbfd")
// }
- bson: bson.Raw{
+ Current: bson.Raw{
'\x5a', '\x00', '\x00', '\x00', '\x07', '\x5f', '\x69', '\x64',
'\x00', '\x5c', '\x11', '\x51', '\x56', '\x77', '\x7f', '\xf8',
'\x56', '\x54', '\x24', '\x8a', '\xe1', '\x02', '\x6b', '\x65',
@@ -436,8 +414,8 @@ func TestReadAll(t *testing.T) {
'\x56', '\xc9', '\x75', '\x50', '\x47', '\xe3', '\x18', '\xbb',
'\xfd', '\x00',
},
- count: 1,
},
+ mCursorCount: 1,
},
expected: map[string][]byte{
"b82c4bb1-09ff-6093-4d58-8327b94e1e20": []byte{
@@ -462,14 +440,14 @@ func TestReadAll(t *testing.T) {
"tag": "tagName",
},
mockColl: &mockCollection{
- mCursor: &mockCursor{
+ mCursor: &mongo.Cursor{
// Binary form of
// {
// "_id" : ObjectId("5c115156777ff85654248ae1"),
// "key" : "b82c4bb1-09ff-6093-4d58-8327b94e1e20",
// "metadata" : ObjectId("5c115156c9755047e318bbfd")
// }
- bson: bson.Raw{
+ Current: bson.Raw{
'\x5a', '\x00', '\x00', '\x00', '\x07', '\x5f', '\x69', '\x64',
'\x00', '\x5c', '\x11', '\x51', '\x56', '\x77', '\x7f', '\xf8',
'\x56', '\x54', '\x24', '\x8a', '\xe1', '\x02', '\x6b', '\x65',
@@ -483,8 +461,8 @@ func TestReadAll(t *testing.T) {
'\x56', '\xc9', '\x75', '\x50', '\x47', '\xe3', '\x18', '\xbb',
'\xfd', '\x00',
},
- count: 1,
},
+ mCursorCount: 1,
},
expectedError: "Did not find any objects with tag",
},
@@ -508,7 +486,19 @@ func TestReadAll(t *testing.T) {
}
decodeBytes = func(sr *mongo.SingleResult) (bson.Raw, error) {
- return testCase.mockColl.mCursor.DecodeBytes()
+ return testCase.mockColl.mCursor.Current, testCase.mockColl.Err
+ }
+
+ cursorNext = func(ctx context.Context, cursor *mongo.Cursor) bool {
+ if testCase.mockColl.mCursorCount > 0 {
+ testCase.mockColl.mCursorCount -= 1
+ return true
+ }
+ return false
+ }
+
+ cursorClose = func(ctx context.Context, cursor *mongo.Cursor) error {
+ return nil
}
got, err := m.ReadAll(testCase.input["coll"].(string), testCase.input["tag"].(string))
diff --git a/src/k8splugin/internal/helm/helm.go b/src/k8splugin/internal/helm/helm.go
new file mode 100644
index 00000000..65a36d6b
--- /dev/null
+++ b/src/k8splugin/internal/helm/helm.go
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2018 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package helm
+
+import (
+ "fmt"
+ "io/ioutil"
+ "k8s.io/helm/pkg/strvals"
+ "os"
+ "path"
+ "path/filepath"
+ "regexp"
+ "strings"
+
+ "github.com/ghodss/yaml"
+ pkgerrors "github.com/pkg/errors"
+
+ "k8s.io/apimachinery/pkg/util/validation"
+ "k8s.io/helm/pkg/chartutil"
+ "k8s.io/helm/pkg/manifest"
+ "k8s.io/helm/pkg/proto/hapi/chart"
+ "k8s.io/helm/pkg/releaseutil"
+ "k8s.io/helm/pkg/renderutil"
+ "k8s.io/helm/pkg/tiller"
+ "k8s.io/helm/pkg/timeconv"
+)
+
+// Template is the interface for all helm templating commands
+// Any backend implementation will implement this interface and will
+// access the functionality via this.
+type Template interface {
+ GenerateKubernetesArtifacts(
+ chartPath string,
+ valueFiles []string,
+ values []string) (map[string][]string, error)
+}
+
+// TemplateClient implements the Template interface
+// It will also be used to maintain any localized state
+type TemplateClient struct {
+ whitespaceRegex *regexp.Regexp
+ kubeVersion string
+ kubeNameSpace string
+ releaseName string
+}
+
+// NewTemplateClient returns a new instance of TemplateClient
+func NewTemplateClient(k8sversion, namespace, releasename string) *TemplateClient {
+ return &TemplateClient{
+ whitespaceRegex: regexp.MustCompile(`^\s*$`),
+ // defaultKubeVersion is the default value of --kube-version flag
+ kubeVersion: k8sversion,
+ kubeNameSpace: namespace,
+ releaseName: releasename,
+ }
+}
+
+// Combines valueFiles and values into a single values stream.
+// values takes precedence over valueFiles
+func (h *TemplateClient) processValues(valueFiles []string, values []string) ([]byte, error) {
+ base := map[string]interface{}{}
+
+ //Values files that are used for overriding the chart
+ for _, filePath := range valueFiles {
+ currentMap := map[string]interface{}{}
+
+ var bytes []byte
+ var err error
+ if strings.TrimSpace(filePath) == "-" {
+ bytes, err = ioutil.ReadAll(os.Stdin)
+ } else {
+ bytes, err = ioutil.ReadFile(filePath)
+ }
+
+ if err != nil {
+ return []byte{}, err
+ }
+
+ if err := yaml.Unmarshal(bytes, &currentMap); err != nil {
+ return []byte{}, fmt.Errorf("failed to parse %s: %s", filePath, err)
+ }
+ // Merge with the previous map
+ base = h.mergeValues(base, currentMap)
+ }
+
+ //User specified value. Similar to ones provided by -x
+ for _, value := range values {
+ if err := strvals.ParseInto(value, base); err != nil {
+ return []byte{}, fmt.Errorf("failed parsing --set data: %s", err)
+ }
+ }
+
+ return yaml.Marshal(base)
+}
+
+func (h *TemplateClient) mergeValues(dest map[string]interface{}, src map[string]interface{}) map[string]interface{} {
+ for k, v := range src {
+ // If the key doesn't exist already, then just set the key to that value
+ if _, exists := dest[k]; !exists {
+ dest[k] = v
+ continue
+ }
+ nextMap, ok := v.(map[string]interface{})
+ // If it isn't another map, overwrite the value
+ if !ok {
+ dest[k] = v
+ continue
+ }
+ // Edge case: If the key exists in the destination, but isn't a map
+ destMap, isMap := dest[k].(map[string]interface{})
+ // If the source map has a map for this key, prefer it
+ if !isMap {
+ dest[k] = v
+ continue
+ }
+ // If we got to this point, it is a map in both, so merge them
+ dest[k] = h.mergeValues(destMap, nextMap)
+ }
+ 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) (map[string][]string, error) {
+
+ var outputDir, chartPath, namespace, releaseName string
+ var retData map[string][]string
+
+ releaseName = h.releaseName
+ namespace = h.kubeNameSpace
+
+ // verify chart path exists
+ if _, err := os.Stat(inputPath); err == nil {
+ if chartPath, err = filepath.Abs(inputPath); err != nil {
+ return retData, err
+ }
+ } else {
+ return retData, err
+ }
+
+ //Create a temp directory in the system temp folder
+ outputDir, err := ioutil.TempDir("", "helm-tmpl-")
+ if err != nil {
+ return retData, pkgerrors.Wrap(err, "Got error creating temp dir")
+ }
+
+ if namespace == "" {
+ namespace = "default"
+ }
+
+ // get combined values and create config
+ rawVals, err := h.processValues(valueFiles, values)
+ if err != nil {
+ return retData, err
+ }
+ config := &chart.Config{Raw: string(rawVals), Values: map[string]*chart.Value{}}
+
+ if msgs := validation.IsDNS1123Label(releaseName); releaseName != "" && len(msgs) > 0 {
+ return retData, fmt.Errorf("release name %s is not a valid DNS label: %s", releaseName, strings.Join(msgs, ";"))
+ }
+
+ // Check chart requirements to make sure all dependencies are present in /charts
+ c, err := chartutil.Load(chartPath)
+ if err != nil {
+ return retData, pkgerrors.Errorf("Got error: %s", err.Error())
+ }
+
+ renderOpts := renderutil.Options{
+ ReleaseOptions: chartutil.ReleaseOptions{
+ Name: releaseName,
+ IsInstall: true,
+ IsUpgrade: false,
+ Time: timeconv.Now(),
+ Namespace: namespace,
+ },
+ KubeVersion: h.kubeVersion,
+ }
+
+ renderedTemplates, err := renderutil.Render(c, config, renderOpts)
+ if err != nil {
+ return retData, err
+ }
+
+ newRenderedTemplates := make(map[string]string)
+
+ //Some manifests can contain multiple yaml documents
+ //This step is splitting them up into multiple files
+ //Each file contains only a single k8s kind
+ for k, v := range renderedTemplates {
+ //Splits into manifest-0, manifest-1 etc
+ if filepath.Base(k) == "NOTES.txt" {
+ continue
+ }
+ rmap := releaseutil.SplitManifests(v)
+ count := 0
+ for _, v1 := range rmap {
+ key := fmt.Sprintf("%s-%d", k, count)
+ newRenderedTemplates[key] = v1
+ count = count + 1
+ }
+ }
+
+ listManifests := manifest.SplitManifests(newRenderedTemplates)
+ var manifestsToRender []manifest.Manifest
+ //render all manifests in the chart
+ manifestsToRender = listManifests
+ retData = make(map[string][]string)
+ for _, m := range tiller.SortByKind(manifestsToRender) {
+ data := m.Content
+ b := filepath.Base(m.Name)
+ if b == "NOTES.txt" {
+ continue
+ }
+ if strings.HasPrefix(b, "_") {
+ continue
+ }
+
+ // blank template after execution
+ if h.whitespaceRegex.MatchString(data) {
+ continue
+ }
+
+ mfilePath := filepath.Join(outputDir, m.Name)
+ h.ensureDirectory(mfilePath)
+ err = ioutil.WriteFile(mfilePath, []byte(data), 0666)
+ if err != nil {
+ return retData, err
+ }
+
+ if val, ok := retData[m.Head.Kind]; ok {
+ retData[m.Head.Kind] = append(val, mfilePath)
+ } else {
+ retData[m.Head.Kind] = []string{mfilePath}
+ }
+ }
+ return retData, nil
+}
diff --git a/src/k8splugin/internal/helm/helm_test.go b/src/k8splugin/internal/helm/helm_test.go
new file mode 100644
index 00000000..a5bcd9c8
--- /dev/null
+++ b/src/k8splugin/internal/helm/helm_test.go
@@ -0,0 +1,195 @@
+// +build unit
+
+/*
+ * Copyright 2018 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package helm
+
+import (
+ "crypto/sha256"
+ "fmt"
+ "io/ioutil"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestProcessValues(t *testing.T) {
+
+ chartDir := "../../mock_files/mock_charts/testchart1"
+ profileDir := "../../mock_files/mock_profiles/profile1"
+
+ testCases := []struct {
+ label string
+ valueFiles []string
+ values []string
+ expectedHash string
+ expectedError string
+ }{
+ {
+ label: "Process Values with Value Files Override",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "c18a70f426933de3c051c996dc34fd537d0131b2d13a2112a2ecff674db6c2f9",
+ expectedError: "",
+ },
+ {
+ label: "Process Values with Values Pair Override",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ },
+ //Use the same convention as specified in helm template --set
+ values: []string{
+ "service.externalPort=82",
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "028a3521fc9f8777ea7e67a6de0c51f2c875b88ca91734999657f0ca924ddb7a",
+ expectedError: "",
+ },
+ {
+ label: "Process Values with Both Overrides",
+ valueFiles: []string{
+ filepath.Join(chartDir, "values.yaml"),
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ //Use the same convention as specified in helm template --set
+ //Key takes precedence over the value from override_values.yaml
+ values: []string{
+ "service.externalPort=82",
+ },
+ //Hash of a combined values.yaml file that is expected
+ expectedHash: "516fab4ab7b76ba2ff35a97c2a79b74302543f532857b945f2fe25e717e755be",
+ expectedError: "",
+ },
+ }
+
+ h := sha256.New()
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ tc := NewTemplateClient("1.12.3", "testnamespace", "testreleasename")
+ out, err := tc.processValues(testCase.valueFiles, testCase.values)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got an error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+ } else {
+ //Compute the hash of returned data and compare
+ h.Write(out)
+ gotHash := fmt.Sprintf("%x", h.Sum(nil))
+ h.Reset()
+ if gotHash != testCase.expectedHash {
+ t.Fatalf("Got unexpected values.yaml %s", out)
+ }
+ }
+ })
+ }
+}
+
+func TestGenerateKubernetesArtifacts(t *testing.T) {
+
+ chartDir := "../../mock_files/mock_charts/testchart1"
+ profileDir := "../../mock_files/mock_profiles/profile1"
+
+ testCases := []struct {
+ label string
+ chartPath string
+ valueFiles []string
+ values []string
+ expectedHashMap map[string]string
+ expectedError string
+ }{
+ {
+ label: "Generate artifacts without any overrides",
+ chartPath: chartDir,
+ valueFiles: []string{},
+ values: []string{},
+ //sha256 hash of the evaluated templates in each chart
+ expectedHashMap: map[string]string{
+ "testchart1/templates/service.yaml": "bbd7257d1f6ab958680e642a8fbbbea2002ebbaa9276fb51fbd71b4b66a772cc",
+ "subcharta/templates/service.yaml": "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
+ "subchartb/templates/service.yaml": "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
+ },
+ expectedError: "",
+ },
+ {
+ label: "Generate artifacts with overrides",
+ chartPath: chartDir,
+ valueFiles: []string{
+ filepath.Join(profileDir, "override_values.yaml"),
+ },
+ values: []string{
+ "service.externalPort=82",
+ },
+ //sha256 hash of the evaluated templates in each chart
+ expectedHashMap: map[string]string{
+ "testchart1/templates/service.yaml": "4c5aa5d38b763fe4730fc31a759c40566a99a9c51f5e0fc7f93473c9affc2ca8",
+ "subcharta/templates/service.yaml": "570389588fffdb7193ab265888d781f3d751f3a40362533344f9aa7bb93a8bb0",
+ "subchartb/templates/service.yaml": "5654e03d922e8ec49649b4bbda9dfc9e643b3b7c9c18b602cc7e26fd36a39c2a",
+ },
+ expectedError: "",
+ },
+ }
+
+ h := sha256.New()
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ tc := NewTemplateClient("1.12.3", "testnamespace", "testreleasename")
+ out, err := tc.GenerateKubernetesArtifacts(testCase.chartPath, testCase.valueFiles,
+ testCase.values)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got an error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+ } else {
+ //Compute the hash of returned data and compare
+ for _, v := range out {
+ for _, f := range v {
+ data, err := ioutil.ReadFile(f)
+ if err != nil {
+ t.Errorf("Unable to read file %s", v)
+ }
+ h.Write(data)
+ gotHash := fmt.Sprintf("%x", h.Sum(nil))
+ h.Reset()
+
+ //Find the right hash from expectedHashMap
+ expectedHash := ""
+ for k1, v1 := range testCase.expectedHashMap {
+ if strings.Contains(f, k1) == true {
+ expectedHash = v1
+ break
+ }
+ }
+ if gotHash != expectedHash {
+ t.Fatalf("Got unexpected hash for %s", f)
+ }
+ }
+ }
+ }
+ })
+ }
+}
diff --git a/src/k8splugin/internal/rb/definition.go b/src/k8splugin/internal/rb/definition.go
index 19844990..4eaa9578 100644
--- a/src/k8splugin/internal/rb/definition.go
+++ b/src/k8splugin/internal/rb/definition.go
@@ -19,8 +19,12 @@ package rb
import (
"bytes"
"encoding/base64"
- "k8splugin/internal/db"
+ "io/ioutil"
"log"
+ "os"
+ "path/filepath"
+
+ "k8splugin/internal/db"
uuid "github.com/hashicorp/go-uuid"
pkgerrors "github.com/pkg/errors"
@@ -142,8 +146,8 @@ func (v *DefinitionClient) Delete(id string) error {
// Upload the contents of resource bundle into database
func (v *DefinitionClient) Upload(id string, inp []byte) error {
- //ignore the returned data here
- _, err := v.Get(id)
+ //Check if definition metadata exists
+ def, err := v.Get(id)
if err != nil {
return pkgerrors.Errorf("Invalid Definition ID provided: %s", err.Error())
}
@@ -153,6 +157,39 @@ func (v *DefinitionClient) Upload(id string, inp []byte) error {
return pkgerrors.Errorf("Error in file format: %s", err.Error())
}
+ //Detect chart name from data if it was not provided originally
+ if def.ChartName == "" {
+ path, err := ExtractTarBall(bytes.NewBuffer(inp))
+ if err != nil {
+ return pkgerrors.Wrap(err, "Detecting chart name")
+ }
+
+ finfo, err := ioutil.ReadDir(path)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Detecting chart name")
+ }
+
+ //Store the first directory with Chart.yaml found as the chart name
+ for _, f := range finfo {
+ if f.IsDir() {
+ //Check if Chart.yaml exists
+ if _, err = os.Stat(filepath.Join(path, f.Name(), "Chart.yaml")); err == nil {
+ def.ChartName = f.Name()
+ break
+ }
+ }
+ }
+
+ if def.ChartName == "" {
+ return pkgerrors.New("Unable to detect chart name")
+ }
+
+ _, err = v.Create(def)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Storing updated chart metadata")
+ }
+ }
+
//Encode given byte stream to text for storage
encodedStr := base64.StdEncoding.EncodeToString(inp)
err = db.DBconn.Create(v.storeName, id, v.tagContent, encodedStr)
diff --git a/src/k8splugin/internal/rb/definition_test.go b/src/k8splugin/internal/rb/definition_test.go
index f720b6a9..b1875fd7 100644
--- a/src/k8splugin/internal/rb/definition_test.go
+++ b/src/k8splugin/internal/rb/definition_test.go
@@ -281,8 +281,95 @@ func TestUploadDefinition(t *testing.T) {
mockdb *db.MockDB
}{
{
- label: "Upload Resource Bundle Definition",
+ label: "Upload With Chart Name Detection",
inp: "123e4567-e89b-12d3-a456-426655440000",
+ //Binary format for testchart/Chart.yaml
+ content: []byte{
+ 0x1f, 0x8b, 0x08, 0x08, 0xb3, 0xeb, 0x86, 0x5c,
+ 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x63, 0x68,
+ 0x61, 0x72, 0x74, 0x2e, 0x74, 0x61, 0x72, 0x00,
+ 0xed, 0xd2, 0x41, 0x4b, 0xc3, 0x30, 0x18, 0xc6,
+ 0xf1, 0x9c, 0xfb, 0x29, 0xde, 0x4f, 0x50, 0x93,
+ 0x36, 0x69, 0x60, 0x37, 0xd9, 0x45, 0xf0, 0xee,
+ 0x55, 0xe2, 0x16, 0xb1, 0x74, 0xed, 0x46, 0x9a,
+ 0x0d, 0xfc, 0xf6, 0xae, 0x83, 0x4d, 0x91, 0x89,
+ 0x97, 0x0d, 0x91, 0xfd, 0x7f, 0x87, 0x84, 0x90,
+ 0x90, 0xbc, 0xe1, 0x79, 0x73, 0x1c, 0xf3, 0xe2,
+ 0x2d, 0xa4, 0x7c, 0xa7, 0xae, 0x46, 0xef, 0x79,
+ 0xef, 0xa6, 0xd9, 0x78, 0xa7, 0xbf, 0xce, 0x47,
+ 0xca, 0xd4, 0xd6, 0x1a, 0xd7, 0xb8, 0xa6, 0xb6,
+ 0x4a, 0x1b, 0x5b, 0xbb, 0x4a, 0x89, 0xbb, 0x5e,
+ 0x49, 0x9f, 0xb6, 0x63, 0x0e, 0x49, 0x44, 0x85,
+ 0xe5, 0x73, 0xd7, 0x75, 0xa1, 0x6f, 0x87, 0x78,
+ 0xf6, 0xdc, 0x6f, 0xfb, 0xff, 0x54, 0x3e, 0xe5,
+ 0x3f, 0x9f, 0xc6, 0xf2, 0x3d, 0xf4, 0xab, 0x4b,
+ 0xbf, 0x31, 0x05, 0xdc, 0x34, 0xf6, 0xc7, 0xfc,
+ 0x4d, 0xe5, 0xbf, 0xe5, 0xdf, 0x54, 0xde, 0x2b,
+ 0xd1, 0x97, 0x2e, 0xe4, 0x9c, 0x1b, 0xcf, 0x3f,
+ 0x6c, 0xda, 0xa7, 0x98, 0xc6, 0x76, 0x3d, 0xcc,
+ 0x64, 0x67, 0x8a, 0x65, 0x1c, 0x17, 0xa9, 0xdd,
+ 0xe4, 0xc3, 0xfa, 0x5e, 0x1e, 0xe2, 0xaa, 0x97,
+ 0x43, 0x7b, 0xc8, 0xeb, 0x3a, 0xc9, 0xe3, 0xf6,
+ 0x25, 0xa6, 0x21, 0xee, 0x7b, 0xa6, 0x18, 0x42,
+ 0x1f, 0x67, 0x72, 0xea, 0x9e, 0x62, 0x77, 0xbc,
+ 0x44, 0x97, 0xa6, 0xd4, 0xc5, 0x5f, 0x7f, 0x0b,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xb8, 0x09, 0x1f, 0xae,
+ 0x48, 0xfe, 0xe8, 0x00, 0x28, 0x00, 0x00,
+ },
+ mockdb: &db.MockDB{
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
+ },
+ },
+ },
+ {
+ label: "Upload With Chart Name",
+ inp: "123e4567-e89b-12d3-a456-426655440000",
+ content: []byte{
+ 0x1f, 0x8b, 0x08, 0x08, 0xb0, 0x6b, 0xf4, 0x5b,
+ 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
+ 0x61, 0x72, 0x00, 0xed, 0xce, 0x41, 0x0a, 0xc2,
+ 0x30, 0x10, 0x85, 0xe1, 0xac, 0x3d, 0x45, 0x4e,
+ 0x50, 0x12, 0xd2, 0xc4, 0xe3, 0x48, 0xa0, 0x01,
+ 0x4b, 0x52, 0x0b, 0xed, 0x88, 0x1e, 0xdf, 0x48,
+ 0x11, 0x5c, 0x08, 0xa5, 0x8b, 0x52, 0x84, 0xff,
+ 0xdb, 0xbc, 0x61, 0x66, 0x16, 0x4f, 0xd2, 0x2c,
+ 0x8d, 0x3c, 0x45, 0xed, 0xc8, 0x54, 0x21, 0xb4,
+ 0xef, 0xb4, 0x67, 0x6f, 0xbe, 0x73, 0x61, 0x9d,
+ 0xb2, 0xce, 0xd5, 0x55, 0xf0, 0xde, 0xd7, 0x3f,
+ 0xdb, 0xd6, 0x49, 0x69, 0xb3, 0x67, 0xa9, 0x8f,
+ 0xfb, 0x2c, 0x71, 0xd2, 0x5a, 0xc5, 0xee, 0x92,
+ 0x73, 0x8e, 0x43, 0x7f, 0x4b, 0x3f, 0xff, 0xd6,
+ 0xee, 0x7f, 0xea, 0x9a, 0x4a, 0x19, 0x1f, 0xe3,
+ 0x54, 0xba, 0xd3, 0xd1, 0x55, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x1b, 0xbc, 0x00, 0xb5, 0xe8,
+ 0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
+ },
+ mockdb: &db.MockDB{
+ Items: map[string]map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": {
+ "metadata": []byte(
+ "{\"name\":\"testresourcebundle\"," +
+ "\"description\":\"testresourcebundle\"," +
+ "\"chart-name\":\"testchart\"," +
+ "\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
+ "\"service-type\":\"firewall\"}"),
+ },
+ },
+ },
+ },
+ {
+ label: "Upload Without Chart.yaml",
+ inp: "123e4567-e89b-12d3-a456-426655440000",
+ expectedError: "Unable to detect chart name",
content: []byte{
0x1f, 0x8b, 0x08, 0x08, 0xb0, 0x6b, 0xf4, 0x5b,
0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74,
diff --git a/src/k8splugin/internal/rb/profile.go b/src/k8splugin/internal/rb/profile.go
index 2456ad2d..d78e32e4 100644
--- a/src/k8splugin/internal/rb/profile.go
+++ b/src/k8splugin/internal/rb/profile.go
@@ -51,6 +51,7 @@ type ProfileManager interface {
type ProfileClient struct {
storeName string
tagMeta, tagContent string
+ manifestName string
}
// NewProfileClient returns an instance of the ProfileClient
@@ -58,9 +59,10 @@ type ProfileClient struct {
// Uses rb/def prefix
func NewProfileClient() *ProfileClient {
return &ProfileClient{
- storeName: "rbprofile",
- tagMeta: "metadata",
- tagContent: "content",
+ storeName: "rbprofile",
+ tagMeta: "metadata",
+ tagContent: "content",
+ manifestName: "manifest.yaml",
}
}
diff --git a/src/k8splugin/internal/rb/profile_yaml.go b/src/k8splugin/internal/rb/profile_yaml.go
new file mode 100644
index 00000000..ba55fba9
--- /dev/null
+++ b/src/k8splugin/internal/rb/profile_yaml.go
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2018 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rb
+
+import (
+ "io/ioutil"
+ "log"
+ "path/filepath"
+
+ "github.com/ghodss/yaml"
+ pkgerrors "github.com/pkg/errors"
+)
+
+/*
+#Sample Yaml format for profile manifest.yaml
+---
+version: v1
+type:
+ values: "values_override.yaml"
+ configresource:
+ - filepath: config.yaml
+ chartpath: chart/config/resources/config.yaml
+ - filepath: config2.yaml
+ chartpath: chart/config/resources/config2.yaml
+*/
+
+type overrideFiles struct {
+ FilePath string `yaml:"filepath"`
+ ChartPath string `yaml:"chartpath"`
+}
+
+type supportedOverrides struct {
+ ConfigResource []overrideFiles `yaml:"configresource"`
+ Values string `yaml:"values"`
+}
+
+type profileOverride struct {
+ Version string `yaml:"version"`
+ Type supportedOverrides `yaml:"type"`
+}
+
+type ProfileYamlClient struct {
+ path string
+ override profileOverride
+}
+
+func (p ProfileYamlClient) Print() {
+ log.Println(p.override)
+}
+
+//GetValues returns a path to the override values.yam
+//that was part of the profile
+func (p ProfileYamlClient) GetValues() string {
+ return filepath.Join(p.path, p.override.Type.Values)
+}
+
+//CopyConfigurationOverrides copies the various files that are
+//provided as overrides to their corresponding locations within
+//the destination chart.
+func (p ProfileYamlClient) CopyConfigurationOverrides(chartPath string) error {
+
+ //Iterate over each configresource and copy that file into
+ //the respective path in the chart.
+ for _, v := range p.override.Type.ConfigResource {
+ data, err := ioutil.ReadFile(filepath.Join(p.path, v.FilePath))
+ if err != nil {
+ return pkgerrors.Wrap(err, "Reading configuration file")
+ }
+ err = ioutil.WriteFile(filepath.Join(chartPath, v.ChartPath), data, 0644)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Writing configuration file into chartpath")
+ }
+ }
+
+ return nil
+}
+
+//ProcessProfileYaml parses the manifest.yaml file that is part of the profile
+//package and creates the appropriate structures out of it.
+func ProcessProfileYaml(fpath string, manifestFileName string) (ProfileYamlClient, error) {
+
+ p := filepath.Join(fpath, manifestFileName)
+ data, err := ioutil.ReadFile(p)
+ if err != nil {
+ return ProfileYamlClient{}, pkgerrors.Wrap(err, "Reading manifest file")
+ }
+
+ out := profileOverride{}
+ err = yaml.Unmarshal(data, &out)
+ if err != nil {
+ return ProfileYamlClient{}, pkgerrors.Wrap(err, "Marshaling manifest yaml file")
+ }
+
+ return ProfileYamlClient{path: fpath, override: out}, nil
+}
diff --git a/src/k8splugin/internal/rb/profile_yaml_test.go b/src/k8splugin/internal/rb/profile_yaml_test.go
new file mode 100644
index 00000000..c29bf9ed
--- /dev/null
+++ b/src/k8splugin/internal/rb/profile_yaml_test.go
@@ -0,0 +1,139 @@
+// +build unit
+
+/*
+ * Copyright 2018 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package rb
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+)
+
+func TestProcessProfileYaml(t *testing.T) {
+
+ profileDir := "../../mock_files/mock_profiles/profile1"
+ manifestFile := "manifest.yaml"
+ faultymanifestfile := "faulty-manifest.yaml"
+
+ testCases := []struct {
+ label string
+ prDir, manifest string
+ expectedError string
+ }{
+ {
+ label: "Process Profile Yaml",
+ prDir: profileDir,
+ manifest: manifestFile,
+ expectedError: "",
+ },
+ {
+ label: "Non existent manifest file",
+ prDir: profileDir,
+ manifest: "non-existant-file.yaml",
+ expectedError: "Reading manifest file",
+ },
+ {
+ label: "Faulty manifest file",
+ prDir: profileDir,
+ manifest: faultymanifestfile,
+ expectedError: "Marshaling manifest yaml file",
+ },
+ }
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ _, err := ProcessProfileYaml(testCase.prDir, testCase.manifest)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got an error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+ }
+ })
+ }
+}
+
+func TestCopyConfigurationOverrides(t *testing.T) {
+
+ profileDir := "../../mock_files/mock_profiles/profile1"
+ profileFileName := "p1.yaml"
+ manifestFile := "manifest.yaml"
+ faultySrcManifestFile := "faulty-src-manifest.yaml"
+ faultyDestManifestFile := "faulty-dest-manifest.yaml"
+ chartBaseDir := "../../mock_files/mock_charts"
+
+ //Remove the testchart1/templates/p1.yaml file that gets copied over
+ defer os.Remove(filepath.Join(chartBaseDir, "testchart1", "templates", profileFileName))
+
+ testCases := []struct {
+ label string
+ prDir, chDir, manifest string
+ expectedError string
+ }{
+ {
+ label: "Copy Configuration Overrides",
+ prDir: profileDir,
+ manifest: manifestFile,
+ chDir: chartBaseDir,
+ expectedError: "",
+ },
+ {
+ label: "Copy Configuration Overrides Faulty Source",
+ prDir: profileDir,
+ manifest: faultySrcManifestFile,
+ chDir: chartBaseDir,
+ expectedError: "Reading configuration file",
+ },
+ {
+ label: "Copy Configuration Overrides Faulty Destination",
+ prDir: profileDir,
+ manifest: faultyDestManifestFile,
+ chDir: chartBaseDir,
+ expectedError: "Writing configuration file",
+ },
+ }
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ p, err := ProcessProfileYaml(testCase.prDir, testCase.manifest)
+ if err != nil {
+ t.Fatalf("Got unexpected error processing yaml %s", err)
+ }
+
+ err = p.CopyConfigurationOverrides(testCase.chDir)
+ if err != nil {
+ if testCase.expectedError == "" {
+ t.Fatalf("Got error %s", err)
+ }
+ if strings.Contains(err.Error(), testCase.expectedError) == false {
+ t.Fatalf("Got unexpected error message %s", err)
+ }
+
+ } else {
+ //Check if the file got copied over
+ if _, err = os.Stat(filepath.Join(testCase.chDir, "testchart1",
+ "templates", profileFileName)); os.IsNotExist(err) {
+ t.Fatalf("Failed to copy override file: %s", profileFileName)
+ }
+ }
+ })
+ }
+}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/Chart.yaml
new file mode 100644
index 00000000..91a641bd
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: testchart1
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml
new file mode 100644
index 00000000..be3edcef
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subcharta
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml
new file mode 100644
index 00000000..f0381ae6
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml
@@ -0,0 +1,17 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchartA
+service:
+ name: apache
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+SCAdata:
+ SCAbool: false
+ SCAfloat: 3.1
+ SCAint: 55
+ SCAstring: "jabba"
+ SCAnested1:
+ SCAnested2: true
+
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml
new file mode 100644
index 00000000..c3c6bbaf
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: subchartb
+version: 0.1.0
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml
new file mode 100644
index 00000000..774fdd75
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml
@@ -0,0 +1,35 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+SCBdata:
+ SCBbool: true
+ SCBfloat: 7.77
+ SCBint: 33
+ SCBstring: "boba"
+
+exports:
+ SCBexported1:
+ SCBexported1A:
+ SCBexported1B: 1965
+
+ SCBexported2:
+ SCBexported2A: "blaster"
+
+global:
+ kolla:
+ nova:
+ api:
+ all:
+ port: 8774
+ metadata:
+ all:
+ port: 8775
+
+
+
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/templates/NOTES.txt b/src/k8splugin/mock_files/mock_charts/testchart1/templates/NOTES.txt
new file mode 100644
index 00000000..4bdf443f
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/templates/NOTES.txt
@@ -0,0 +1 @@
+Sample notes for {{ .Chart.Name }} \ No newline at end of file
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/templates/service.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/templates/service.yaml
new file mode 100644
index 00000000..e06d19b9
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/templates/service.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ namespace: "{{ .Release.Namespace }}"
+ release-name: "{{ .Release.Name }}"
+ release-is-upgrade: "{{ .Release.IsUpgrade }}"
+ release-is-install: "{{ .Release.IsInstall }}"
+ kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+ kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+ kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/src/k8splugin/mock_files/mock_charts/testchart1/values.yaml b/src/k8splugin/mock_files/mock_charts/testchart1/values.yaml
new file mode 100644
index 00000000..72d3fa5c
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_charts/testchart1/values.yaml
@@ -0,0 +1,55 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 80
+ internalPort: 80
+
+
+SC1data:
+ SC1bool: true
+ SC1float: 3.14
+ SC1int: 100
+ SC1string: "dollywood"
+ SC1extra1: 11
+
+imported-chartA:
+ SC1extra2: 1.337
+
+overridden-chartA:
+ SCAbool: true
+ SCAfloat: 3.14
+ SCAint: 100
+ SCAstring: "jabathehut"
+ SC1extra3: true
+
+imported-chartA-B:
+ SC1extra5: "tiller"
+
+overridden-chartA-B:
+ SCAbool: true
+ SCAfloat: 3.33
+ SCAint: 555
+ SCAstring: "wormwood"
+ SCAextra1: 23
+
+ SCBbool: true
+ SCBfloat: 0.25
+ SCBint: 98
+ SCBstring: "murkwood"
+ SCBextra1: 13
+
+ SC1extra6: 77
+
+SCBexported1A:
+ SC1extra7: true
+
+exports:
+ SC1exported1:
+ global:
+ SC1exported2:
+ all:
+ SC1exported3: "SC1expstr" \ No newline at end of file
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml
new file mode 100644
index 00000000..8c61a4e4
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/folderdoesNOTexist/p1.yaml
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/faulty-manifest.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-manifest.yaml
new file mode 100644
index 00000000..a123111a
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-manifest.yaml
@@ -0,0 +1,8 @@
+---
+version: v1
+type:
+ values:
+ - override_values.yaml
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml
new file mode 100644
index 00000000..eff534bb
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/filedoesNOTexist.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/manifest.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/manifest.yaml
new file mode 100644
index 00000000..e4beada0
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: subdir/p1.yaml
+ chartpath: testchart1/templates/p1.yaml
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/override_values.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/override_values.yaml
new file mode 100644
index 00000000..0186c662
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/override_values.yaml
@@ -0,0 +1,9 @@
+# Default values for subchart.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+# subchart1
+service:
+ name: nginx
+ type: ClusterIP
+ externalPort: 8080
+ internalPort: 8080 \ No newline at end of file
diff --git a/src/k8splugin/mock_files/mock_profiles/profile1/subdir/p1.yaml b/src/k8splugin/mock_files/mock_profiles/profile1/subdir/p1.yaml
new file mode 100644
index 00000000..2dad677a
--- /dev/null
+++ b/src/k8splugin/mock_files/mock_profiles/profile1/subdir/p1.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Chart.Name }}-override
+ labels:
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ namespace: "{{ .Release.Namespace }}"
+ release-name: "{{ .Release.Name }}"
+ release-is-upgrade: "{{ .Release.IsUpgrade }}"
+ release-is-install: "{{ .Release.IsInstall }}"
+ kube-version/major: "{{ .Capabilities.KubeVersion.Major }}"
+ kube-version/minor: "{{ .Capabilities.KubeVersion.Minor }}"
+ kube-version/gitversion: "v{{ .Capabilities.KubeVersion.Major }}.{{ .Capabilities.KubeVersion.Minor }}.0"
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ protocol: TCP
+ name: {{ .Values.service.name }}
+ selector:
+ app: {{ .Chart.Name }}
diff --git a/vagrant/playbooks/krd-vars.yml b/vagrant/playbooks/krd-vars.yml
index 81e11c11..d6bd0ee6 100644
--- a/vagrant/playbooks/krd-vars.yml
+++ b/vagrant/playbooks/krd-vars.yml
@@ -35,7 +35,7 @@ criproxy_url: "https://github.com/Mirantis/criproxy/releases/download/v{{ cripro
#criproxy_url: "https://github.com/Mirantis/criproxy"
virtlet_dest: "{{ base_dest }}/virtlet"
virtlet_source_type: "binary"
-virtlet_version: 1.4.3
+virtlet_version: 1.4.4
virtlet_url: "https://github.com/Mirantis/virtlet/releases/download/v{{ virtlet_version }}/virtletctl"
#virtlet_source_type: "source"
#virtlet_version: 68e11b8f1db2c78b063126899f0e60910700975d
diff --git a/vagrant/tests/_common.sh b/vagrant/tests/_common.sh
index 674c752a..f0fa7d6f 100755
--- a/vagrant/tests/_common.sh
+++ b/vagrant/tests/_common.sh
@@ -26,6 +26,11 @@ onap_private_net=onap-private-net
unprotected_private_net=unprotected-private-net
protected_private_net=protected-private-net
ovn_multus_network_name=ovn-networkobj
+rbd_metadata=rbd_metatada.json
+rbd_content_tarball=vault-consul-dev.tar
+rbp_metadata=rbp_metatada.json
+rbp_instance=rbp_instance.json
+rbp_content_tarball=profile.tar
# vFirewall vars
demo_artifacts_version=1.3.0
@@ -1094,3 +1099,20 @@ spec:
DEPLOYMENT
popd
}
+
+# populate_CSAR_rbdefinition() - Function that populates CSAR folder
+# for testing resource bundle definition
+function populate_CSAR_rbdefinition {
+ local csar_id=$1
+
+ _checks_args $csar_id
+ pushd ${CSAR_DIR}/${csar_id}
+ print_msg "Create Helm Chart Archives"
+ rm -f ${rbd_content_tarball}.gz
+ rm -f ${rbp_content_tarball}.gz
+ tar -cf $rbd_content_tarball -C $test_folder/vnfs/testrb/helm vault-consul-dev
+ tar -cf $rbp_content_tarball -C $test_folder/vnfs/testrb/helm/profile .
+ gzip $rbp_content_tarball
+ gzip $rbd_content_tarball
+ popd
+}
diff --git a/vagrant/tests/_functions.sh b/vagrant/tests/_functions.sh
index fe69b07b..62feb7b7 100755
--- a/vagrant/tests/_functions.sh
+++ b/vagrant/tests/_functions.sh
@@ -12,6 +12,14 @@ set -o errexit
set -o nounset
set -o pipefail
+function print_msg {
+ local msg=$1
+ local RED='\033[0;31m'
+ local NC='\033[0m'
+
+ echo -e "${RED} $msg ---------------------------------------${NC}"
+}
+
function _get_ovn_central_address {
ansible_ifconfig=$(ansible ovn-central[0] -i $test_folder/../inventory/hosts.ini -m shell -a "ifconfig eth1 |grep \"inet addr\" |awk '{print \$2}' |awk -F: '{print \$2}'")
if [[ $ansible_ifconfig != *CHANGED* ]]; then
diff --git a/vagrant/tests/cFW/README.md b/vagrant/tests/cFW/README.md
new file mode 100644
index 00000000..c6ac9e20
--- /dev/null
+++ b/vagrant/tests/cFW/README.md
@@ -0,0 +1,10 @@
+# Cloud-Native Firewall Virtual Network Function
+
+[CNF][1] version of the ONAP vFirewall use case.
+
+## License
+
+Apache-2.0
+
+[1]: https://github.com/ligato/cn-infra/blob/master/docs/readmes/cn_virtual_function.md
+[2]: https://github.com/electrocucaracha/vFW-demo
diff --git a/vagrant/tests/cFW/Vagrantfile b/vagrant/tests/cFW/Vagrantfile
new file mode 100644
index 00000000..d02e7d01
--- /dev/null
+++ b/vagrant/tests/cFW/Vagrantfile
@@ -0,0 +1,33 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure("2") do |config|
+ config.vm.box = "elastic/ubuntu-16.04-x86_64"
+ config.vm.hostname = "demo"
+ config.vm.provision 'shell', path: 'postinstall.sh'
+ config.vm.network :private_network, :ip => "192.168.10.5", :type => :static # unprotected_private_net_cidr
+ config.vm.network :private_network, :ip => "192.168.20.5", :type => :static # protected_private_net_cidr
+ config.vm.network :private_network, :ip => "10.10.12.5", :type => :static, :netmask => "16" # onap_private_net_cidr
+
+ if ENV['http_proxy'] != nil and ENV['https_proxy'] != nil
+ if not Vagrant.has_plugin?('vagrant-proxyconf')
+ system 'vagrant plugin install vagrant-proxyconf'
+ raise 'vagrant-proxyconf was installed but it requires to execute again'
+ end
+ config.proxy.http = ENV['http_proxy'] || ENV['HTTP_PROXY'] || ""
+ config.proxy.https = ENV['https_proxy'] || ENV['HTTPS_PROXY'] || ""
+ config.proxy.no_proxy = ENV['NO_PROXY'] || ENV['no_proxy'] || "127.0.0.1,localhost"
+ config.proxy.enabled = { docker: false }
+ end
+
+ config.vm.provider 'virtualbox' do |v|
+ v.customize ["modifyvm", :id, "--memory", 8192]
+ v.customize ["modifyvm", :id, "--cpus", 2]
+ end
+ config.vm.provider 'libvirt' do |v|
+ v.memory = 8192
+ v.cpus = 2
+ v.nested = true
+ v.cpu_mode = 'host-passthrough'
+ end
+end
diff --git a/vagrant/tests/cFW/darkstat/Dockerfile b/vagrant/tests/cFW/darkstat/Dockerfile
new file mode 100644
index 00000000..d3a46b9c
--- /dev/null
+++ b/vagrant/tests/cFW/darkstat/Dockerfile
@@ -0,0 +1,14 @@
+FROM ubuntu:16.04
+MAINTAINER Victor Morales <electrocucaracha@gmail.com>
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+RUN apt-get update && apt-get install -y -qq darkstat
+
+EXPOSE 667
+
+CMD ["/usr/sbin/darkstat", "-i", "eth1", "--no-daemon"]
diff --git a/vagrant/tests/cFW/docker-compose.yml b/vagrant/tests/cFW/docker-compose.yml
new file mode 100644
index 00000000..6d883fbd
--- /dev/null
+++ b/vagrant/tests/cFW/docker-compose.yml
@@ -0,0 +1,38 @@
+version: '3'
+
+services:
+ packetgen:
+ privileged: true
+ network_mode: "host"
+ image: electrocucaracha/packetgen
+ build:
+ context: ./packetgen
+ args:
+ HTTP_PROXY: $HTTP_PROXY
+ HTTPS_PROXY: $HTTPS_PROXY
+ firewall:
+ privileged: true
+ network_mode: "host"
+ image: electrocucaracha/firewall
+ build:
+ context: ./firewall
+ args:
+ HTTP_PROXY: $HTTP_PROXY
+ HTTPS_PROXY: $HTTPS_PROXY
+ sink:
+ privileged: true
+ network_mode: "host"
+ image: electrocucaracha/sink
+ build:
+ context: ./sink
+ args:
+ HTTP_PROXY: $HTTP_PROXY
+ HTTPS_PROXY: $HTTPS_PROXY
+ darkstat:
+ network_mode: "host"
+ image: electrocucaracha/darkstat
+ build:
+ context: ./darkstat
+ args:
+ HTTP_PROXY: $HTTP_PROXY
+ HTTPS_PROXY: $HTTPS_PROXY
diff --git a/vagrant/tests/cFW/firewall/Dockerfile b/vagrant/tests/cFW/firewall/Dockerfile
new file mode 100644
index 00000000..7d3e6ede
--- /dev/null
+++ b/vagrant/tests/cFW/firewall/Dockerfile
@@ -0,0 +1,49 @@
+FROM electrocucaracha/vpp
+MAINTAINER Victor Morales <electrocucaracha@gmail.com>
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+ENV repo_url "https://nexus.onap.org/content/repositories/staging/org/onap/demo/vnf"
+
+ENV protected_net_cidr "192.168.20.0/24"
+ENV fw_ipaddr "192.168.10.100"
+ENV sink_ipaddr "192.168.20.250"
+ENV demo_artifacts_version "1.3.0"
+
+RUN apt-get install -y -qq wget openjdk-8-jre bridge-utils net-tools \
+ bsdmainutils make gcc libcurl4-gnutls-dev
+
+WORKDIR /opt
+
+RUN wget "https://git.onap.org/demo/plain/vnfs/vFW/scripts/v_firewall_init.sh" \
+ && chmod +x v_firewall_init.sh \
+ && sed -i 's|start vpp|/usr/bin/vpp -c /etc/vpp/startup.conf|g' v_firewall_init.sh
+
+RUN wget "${repo_url}/sample-distribution/${demo_artifacts_version}/sample-distribution-${demo_artifacts_version}-hc.tar.gz" \
+ && tar -zmxf sample-distribution-${demo_artifacts_version}-hc.tar.gz \
+ && rm sample-distribution-${demo_artifacts_version}-hc.tar.gz \
+ && mv sample-distribution-${demo_artifacts_version} honeycomb \
+ && sed -i 's/"restconf-binding-address": "127.0.0.1",/"restconf-binding-address": "0.0.0.0",/g' /opt/honeycomb/config/honeycomb.json
+
+RUN wget "${repo_url}/ves5/ves/${demo_artifacts_version}/ves-${demo_artifacts_version}-demo.tar.gz" \
+ && tar -zmxf ves-${demo_artifacts_version}-demo.tar.gz \
+ && rm ves-${demo_artifacts_version}-demo.tar.gz \
+ && mv ves-${demo_artifacts_version} VES
+
+RUN wget "${repo_url}/ves5/ves_vfw_reporting/${demo_artifacts_version}/ves_vfw_reporting-${demo_artifacts_version}-demo.tar.gz" \
+ && tar -zmxf ves_vfw_reporting-${demo_artifacts_version}-demo.tar.gz \
+ && rm ves_vfw_reporting-${demo_artifacts_version}-demo.tar.gz \
+ && mv ves_vfw_reporting-${demo_artifacts_version} VES/evel/evel-library/code/VESreporting \
+ && chmod +x VES/evel/evel-library/code/VESreporting/go-client.sh \
+ && cd VES/evel/evel-library/bldjobs/ && make clean && make && cd -
+
+RUN mkdir -p /opt/config/ \
+ && echo $protected_net_cidr > /opt/config/protected_net_cidr.txt \
+ && echo $fw_ipaddr > /opt/config/fw_ipaddr.txt \
+ && echo $sink_ipaddr > /opt/config/sink_ipaddr.txt \
+ && echo $demo_artifacts_version > /opt/config/demo_artifacts_version.txt
+
+CMD ["./v_firewall_init.sh"]
diff --git a/vagrant/tests/cFW/packetgen/Dockerfile b/vagrant/tests/cFW/packetgen/Dockerfile
new file mode 100644
index 00000000..cb1da555
--- /dev/null
+++ b/vagrant/tests/cFW/packetgen/Dockerfile
@@ -0,0 +1,44 @@
+FROM electrocucaracha/vpp
+MAINTAINER Victor Morales <electrocucaracha@gmail.com>
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+ENV repo_url "https://nexus.onap.org/content/repositories/staging/org/onap/demo/vnf"
+
+ENV protected_net_cidr "192.168.20.0/24"
+ENV fw_ipaddr "192.168.10.100"
+ENV sink_ipaddr "192.168.20.250"
+ENV demo_artifacts_version "1.3.0"
+
+RUN apt-get install -y -qq wget openjdk-8-jre bridge-utils net-tools \
+ bsdmainutils
+
+WORKDIR /opt
+EXPOSE 8183
+
+RUN wget "https://git.onap.org/demo/plain/vnfs/vFW/scripts/v_packetgen_init.sh" \
+ && wget "https://git.onap.org/demo/plain/vnfs/vFW/scripts/run_traffic_fw_demo.sh" \
+ && chmod +x *.sh \
+ && sed -i 's|start vpp|/usr/bin/vpp -c /etc/vpp/startup.conf|g;s|/opt/honeycomb/sample-distribution-\$VERSION/honeycomb|/opt/honeycomb/honeycomb|g' v_packetgen_init.sh
+
+RUN wget "${repo_url}/sample-distribution/${demo_artifacts_version}/sample-distribution-${demo_artifacts_version}-hc.tar.gz" \
+ && tar -zmxf sample-distribution-${demo_artifacts_version}-hc.tar.gz \
+ && rm sample-distribution-${demo_artifacts_version}-hc.tar.gz \
+ && mv sample-distribution-${demo_artifacts_version} honeycomb \
+ && sed -i 's/"restconf-binding-address": "127.0.0.1",/"restconf-binding-address": "0.0.0.0",/g' /opt/honeycomb/config/honeycomb.json
+
+RUN wget "${repo_url}/vfw/vfw_pg_streams/${demo_artifacts_version}/vfw_pg_streams-${demo_artifacts_version}-demo.tar.gz" \
+ && tar -zmxf vfw_pg_streams-${demo_artifacts_version}-demo.tar.gz \
+ && rm vfw_pg_streams-${demo_artifacts_version}-demo.tar.gz \
+ && mv vfw_pg_streams-${demo_artifacts_version} pg_streams
+
+RUN mkdir -p /opt/config/ \
+ && echo $protected_net_cidr > /opt/config/protected_net_cidr.txt \
+ && echo $fw_ipaddr > /opt/config/fw_ipaddr.txt \
+ && echo $sink_ipaddr > /opt/config/sink_ipaddr.txt \
+ && echo $demo_artifacts_version > /opt/config/demo_artifacts_version.txt
+
+CMD ["./v_packetgen_init.sh"]
diff --git a/vagrant/tests/cFW/postinstall.sh b/vagrant/tests/cFW/postinstall.sh
new file mode 100755
index 00000000..5a1d5043
--- /dev/null
+++ b/vagrant/tests/cFW/postinstall.sh
@@ -0,0 +1,83 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2018
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+set -o nounset
+set -o pipefail
+set -o xtrace
+
+# install_docker() - Download and install docker-engine
+function install_docker {
+ local max_concurrent_downloads=${1:-3}
+
+ if $(docker version &>/dev/null); then
+ return
+ fi
+ apt-get install -y software-properties-common linux-image-extra-$(uname -r) linux-image-extra-virtual apt-transport-https ca-certificates curl
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
+ apt-get update
+ apt-get install -y docker-ce
+
+ mkdir -p /etc/systemd/system/docker.service.d
+ if [ $http_proxy ]; then
+ cat <<EOL > /etc/systemd/system/docker.service.d/http-proxy.conf
+[Service]
+Environment="HTTP_PROXY=$http_proxy"
+EOL
+ fi
+ if [ $https_proxy ]; then
+ cat <<EOL > /etc/systemd/system/docker.service.d/https-proxy.conf
+[Service]
+Environment="HTTPS_PROXY=$https_proxy"
+EOL
+ fi
+ if [ $no_proxy ]; then
+ cat <<EOL > /etc/systemd/system/docker.service.d/no-proxy.conf
+[Service]
+Environment="NO_PROXY=$no_proxy"
+EOL
+ fi
+ systemctl daemon-reload
+ echo "DOCKER_OPTS=\"-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --max-concurrent-downloads $max_concurrent_downloads \"" >> /etc/default/docker
+ usermod -aG docker $USER
+
+ systemctl restart docker
+ sleep 10
+}
+
+# install_docker_compose() - Installs docker compose python module
+function install_docker_compose {
+ if ! which pip; then
+ curl -sL https://bootstrap.pypa.io/get-pip.py | python
+ fi
+ pip install --upgrade pip
+ pip install docker-compose
+}
+
+echo 'vm.nr_hugepages = 1024' >> /etc/sysctl.conf
+sysctl -p
+
+install_docker
+install_docker_compose
+
+cd /vagrant
+# build vpp docker image
+BUILD_ARGS="--no-cache"
+if [ $HTTP_PROXY ]; then
+ BUILD_ARGS+=" --build-arg HTTP_PROXY=${HTTP_PROXY}"
+fi
+if [ $HTTPS_PROXY ]; then
+ BUILD_ARGS+=" --build-arg HTTPS_PROXY=${HTTPS_PROXY}"
+fi
+pushd vpp
+docker build ${BUILD_ARGS} -t electrocucaracha/vpp:latest .
+popd
+
+docker-compose up -d
diff --git a/vagrant/tests/cFW/sink/Dockerfile b/vagrant/tests/cFW/sink/Dockerfile
new file mode 100644
index 00000000..6b43ba61
--- /dev/null
+++ b/vagrant/tests/cFW/sink/Dockerfile
@@ -0,0 +1,34 @@
+FROM ubuntu:16.04
+MAINTAINER Victor Morales <electrocucaracha@gmail.com>
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+ENV protected_net_cidr "192.168.20.0/24"
+ENV fw_ipaddr "192.168.10.100"
+ENV sink_ipaddr "192.168.20.250"
+ENV demo_artifacts_version "1.3.0"
+ENV protected_net_gw "192.168.20.100"
+ENV unprotected_net "192.168.10.0/24"
+
+RUN apt-get update && apt-get install -y -qq wget net-tools
+
+WORKDIR /opt
+
+RUN wget "https://git.onap.org/demo/plain/vnfs/vFW/scripts/v_sink_init.sh" \
+ && chmod +x v_sink_init.sh
+
+RUN mkdir -p config/ \
+ && echo $protected_net_cidr > config/protected_net_cidr.txt \
+ && echo $fw_ipaddr > config/fw_ipaddr.txt \
+ && echo $sink_ipaddr > config/sink_ipaddr.txt \
+ && echo $demo_artifacts_version > config/demo_artifacts_version.txt \
+ && echo $protected_net_gw > config/protected_net_gw.txt \
+ && echo $unprotected_net > config/unprotected_net.txt
+
+# NOTE: this script executes $ route add -net 192.168.10.0 netmask 255.255.255.0 gw 192.168.20.100
+# which results in this error if doesn't have all nics required -> SIOCADDRT: File exists
+CMD ["./v_sink_init.sh"]
diff --git a/vagrant/tests/cFW/vpp/80-vpp.conf b/vagrant/tests/cFW/vpp/80-vpp.conf
new file mode 100644
index 00000000..8fdf184c
--- /dev/null
+++ b/vagrant/tests/cFW/vpp/80-vpp.conf
@@ -0,0 +1,15 @@
+# Number of 2MB hugepages desired
+vm.nr_hugepages=1024
+
+# Must be greater than or equal to (2 * vm.nr_hugepages).
+vm.max_map_count=3096
+
+# All groups allowed to access hugepages
+vm.hugetlb_shm_group=0
+
+# Shared Memory Max must be greator or equal to the total size of hugepages.
+# For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024
+# If the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
+# is greater than the calculated TotalHugepageSize then set this parameter
+# to current shmmax value.
+kernel.shmmax=2147483648
diff --git a/vagrant/tests/cFW/vpp/Dockerfile b/vagrant/tests/cFW/vpp/Dockerfile
new file mode 100644
index 00000000..63b08b01
--- /dev/null
+++ b/vagrant/tests/cFW/vpp/Dockerfile
@@ -0,0 +1,17 @@
+FROM ubuntu:16.04
+MAINTAINER Victor Morales <electrocucaracha@gmail.com>
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+RUN apt-get update && apt-get install -y -qq apt-transport-https \
+ && echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io.stable.1609.ubuntu.xenial.main/ ./" | tee -a /etc/apt/sources.list.d/99fd.io.list \
+ && apt-get update \
+ && apt-get install -y -qq vpp vpp-lib vpp-plugins
+
+COPY 80-vpp.conf /etc/sysctl.d/80-vpp.conf
+
+CMD ["/usr/bin/vpp", "-c", "/etc/vpp/startup.conf"]
diff --git a/vagrant/tests/plugin.sh b/vagrant/tests/plugin.sh
index 55be1686..2ed37b18 100755
--- a/vagrant/tests/plugin.sh
+++ b/vagrant/tests/plugin.sh
@@ -16,10 +16,13 @@ set -o pipefail
source _common.sh
source _functions.sh
-base_url="http://localhost:8081/v1/vnf_instances/"
+base_url="http://localhost:8081"
cloud_region_id="krd"
namespace="default"
csar_id="94e414f6-9ca4-11e8-bb6a-52540067263b"
+rbd_csar_id="7eb09e38-4363-9942-1234-3beb2e95fd85"
+definition_id="9d117af8-30b8-11e9-af94-525400277b3d"
+profile_id="ebe353d2-30b7-11e9-9515-525400277b3d"
# _build_generic_sim() - Creates a generic simulator image in case that doesn't exist
function _build_generic_sim {
@@ -55,8 +58,59 @@ destroy_deployment $plugin_deployment_name
#start_aai_service
populate_CSAR_plugin $csar_id
+populate_CSAR_rbdefinition $rbd_csar_id
# Test
+print_msg "Create Resource Bundle Definition Metadata"
+payload_raw="
+{
+ \"name\": \"test-rbdef\",
+ \"chart-name\": \"vault-consul-dev\",
+ \"description\": \"testing resource bundle definition api\",
+ \"uuid\": \"$definition_id\",
+ \"service-type\": \"firewall\"
+}
+"
+payload=$(echo $payload_raw | tr '\n' ' ')
+rbd_id=$(curl -s -d "$payload" -X POST "${base_url}/v1/rb/definition" | jq -r '.uuid')
+
+print_msg "Upload Resource Bundle Definition Content"
+curl -s --data-binary @${CSAR_DIR}/${rbd_csar_id}/${rbd_content_tarball}.gz -X POST "${base_url}/v1/rb/definition/$rbd_id/content"
+
+print_msg "Listing Resource Bundle Definitions"
+rbd_id_list=$(curl -s -X GET "${base_url}/v1/rb/definition")
+if [[ "$rbd_id_list" != *"${rbd_id}"* ]]; then
+ echo $rbd_id_list
+ echo "Resource Bundle Definition not stored"
+ exit 1
+fi
+
+print_msg "Create Resource Bundle Profile Metadata"
+kubeversion=$(kubectl version | grep 'Server Version' | awk -F '"' '{print $6}')
+payload_raw="
+{
+ \"name\": \"test-rbprofile\",
+ \"namespace\": \"$namespace\",
+ \"rbdid\": \"$definition_id\",
+ \"uuid\": \"$profile_id\",
+ \"kubernetesversion\": \"$kubeversion\"
+}
+"
+payload=$(echo $payload_raw | tr '\n' ' ')
+rbp_id=$(curl -s -d "$payload" -X POST "${base_url}/v1/rb/profile" | jq -r '.uuid')
+
+print_msg "Upload Resource Bundle Profile Content"
+curl -s --data-binary @${CSAR_DIR}/${rbd_csar_id}/${rbp_content_tarball}.gz -X POST "${base_url}/v1/rb/profile/$rbp_id/content"
+
+print_msg "Listing Resource Bundle Profiles"
+rbp_id_list=$(curl -s -X GET "${base_url}/v1/rb/profile")
+if [[ "$rbp_id_list" != *"${rbp_id}"* ]]; then
+ echo $rbd_id_list
+ echo "Resource Bundle Profile not stored"
+ exit 1
+fi
+
+print_msg "Instantiate Profile"
payload_raw="
{
\"cloud_region_id\": \"$cloud_region_id\",
@@ -65,30 +119,40 @@ payload_raw="
}
"
payload=$(echo $payload_raw | tr '\n' ' ')
-echo "Creating VNF Instance"
-vnf_id=$(curl -s -d "$payload" "${base_url}" | jq -r '.vnf_id')
-echo "=== Validating Kubernetes ==="
+vnf_id=$(curl -s -d "$payload" "${base_url}/v1/vnf_instances/" | jq -r '.vnf_id')
+
+print_msg "Validating Kubernetes"
kubectl get --no-headers=true --namespace=${namespace} deployment ${cloud_region_id}-${namespace}-${vnf_id}-${plugin_deployment_name}
kubectl get --no-headers=true --namespace=${namespace} service ${cloud_region_id}-${namespace}-${vnf_id}-${plugin_service_name}
echo "VNF Instance created succesfully with id: $vnf_id"
-vnf_id_list=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}" | jq -r '.vnf_id_list')
+print_msg "Listing VNF Instances"
+vnf_id_list=$(curl -s -X GET "${base_url}/v1/vnf_instances/${cloud_region_id}/${namespace}" | jq -r '.vnf_id_list')
if [[ "$vnf_id_list" != *"${vnf_id}"* ]]; then
echo $vnf_id_list
echo "VNF Instance not stored"
exit 1
fi
-vnf_details=$(curl -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}")
+print_msg "Getting $vnf_id VNF Instance information"
+vnf_details=$(curl -s -X GET "${base_url}/v1/vnf_instances/${cloud_region_id}/${namespace}/${vnf_id}")
if [[ -z "$vnf_details" ]]; then
echo "Cannot retrieved VNF Instance details"
exit 1
fi
echo "VNF details $vnf_details"
-echo "Deleting $vnf_id VNF Instance"
-curl -X DELETE "${base_url}${cloud_region_id}/${namespace}/${vnf_id}"
-if [[ 200 -eq $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}") ]]; then
+print_msg "Deleting $rbd_id Resource Bundle Definition"
+curl -X DELETE "${base_url}/v1/rb/definition/$rbd_id"
+if [[ 500 -ne $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}/v1/rb/definition/$rbd_id") ]]; then
+ echo "Resource Bundle Definition not deleted"
+# TODO: Change the HTTP code for 404 when the resource is not found in the API
+ exit 1
+fi
+
+print_msg "Deleting $vnf_id VNF Instance"
+curl -X DELETE "${base_url}/v1/vnf_instances/${cloud_region_id}/${namespace}/${vnf_id}"
+if [[ 404 -ne $(curl -o /dev/null -w %{http_code} -s -X GET "${base_url}${cloud_region_id}/${namespace}/${vnf_id}") ]]; then
echo "VNF Instance not deleted"
exit 1
fi
diff --git a/vagrant/tests/vnfs/testrb/helm/profile/manifest.yaml b/vagrant/tests/vnfs/testrb/helm/profile/manifest.yaml
new file mode 100644
index 00000000..ef260633
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/profile/manifest.yaml
@@ -0,0 +1,7 @@
+---
+version: v1
+type:
+ values: "override_values.yaml"
+ configresource:
+ - filepath: testfol/subdir/deployment.yaml
+ chartpath: vault-consul-dev/templates/deployment.yaml
diff --git a/vagrant/tests/vnfs/testrb/helm/profile/override_values.yaml b/vagrant/tests/vnfs/testrb/helm/profile/override_values.yaml
new file mode 100644
index 00000000..c9f29a31
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/profile/override_values.yaml
@@ -0,0 +1,7 @@
+service:
+ type: NodePort
+ name: override-vault-consul
+ portName: override-port-vault-consul
+ internalPort: 8222
+ nodePort: 44
+
diff --git a/vagrant/tests/vnfs/testrb/helm/profile/testfol/subdir/deployment.yaml b/vagrant/tests/vnfs/testrb/helm/profile/testfol/subdir/deployment.yaml
new file mode 100644
index 00000000..938e1843
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/profile/testfol/subdir/deployment.yaml
@@ -0,0 +1,51 @@
+# Copyright 2018 Intel Corporation, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ app: {{ include "common.name" . }}
+ template:
+ metadata:
+ labels:
+ app: {{ include "common.name" . }}
+ release: {{ .Release.Name }}
+ spec:
+ containers:
+ - image: "{{ .Values.image.vault }}"
+ name: {{ include "common.name" . }}
+ imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+ command: ["vault","server","-dev"]
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
+ volumeMounts:
+ - mountPath: /etc/localtime
+ name: localtime
+ readOnly: true
+
+ volumes:
+ - name: localtime
+ hostPath:
+ path: /etc/localtime
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/Chart.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/Chart.yaml
new file mode 100644
index 00000000..86643c9d
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/Chart.yaml
@@ -0,0 +1,19 @@
+# Copyright 2018 Intel Corporation, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: v1
+description: Chart to launch Vault and consul in dev mode
+name: vault-consul-dev
+appVersion: 0.9.5
+version: 2.0.0
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/Chart.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/Chart.yaml
new file mode 100644
index 00000000..7d58e53d
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/Chart.yaml
@@ -0,0 +1,18 @@
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: v1
+description: Common templates for inclusion in other charts
+name: common
+version: 2.0.0
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_name.tpl b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_name.tpl
new file mode 100644
index 00000000..42999846
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_name.tpl
@@ -0,0 +1,31 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+
+{{/*
+ Expand the name of a chart.
+*/}}
+{{- define "common.name" -}}
+ {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+ Create a default fully qualified application name.
+ Truncated at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+*/}}
+{{- define "common.fullname" -}}
+ {{- $name := default .Chart.Name .Values.nameOverride -}}
+ {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}} \ No newline at end of file
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_namespace.tpl b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_namespace.tpl
new file mode 100644
index 00000000..94c9ee72
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_namespace.tpl
@@ -0,0 +1,26 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+
+{{/*
+ Resolve the namespace to apply to a chart. The default namespace suffix
+ is the name of the chart. This can be overridden if necessary (eg. for subcharts)
+ using the following value:
+
+ - .Values.nsPrefix : override namespace prefix
+*/}}
+{{- define "common.namespace" -}}
+ {{- default .Release.Namespace .Values.nsPrefix -}}
+{{- end -}}
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_repository.tpl b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_repository.tpl
new file mode 100644
index 00000000..364ba7dc
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_repository.tpl
@@ -0,0 +1,48 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+
+{{/*
+ Resolve the name of the common image repository.
+ The value for .Values.repository is used by default,
+ unless either override mechanism is used.
+
+ - .Values.global.repository : override default image repository for all images
+ - .Values.repositoryOverride : override global and default image repository on a per image basis
+*/}}
+{{- define "common.repository" -}}
+ {{if .Values.repositoryOverride }}
+ {{- printf "%s" .Values.repositoryOverride -}}
+ {{else}}
+ {{- default .Values.repository .Values.global.repository -}}
+ {{end}}
+{{- end -}}
+
+
+{{/*
+ Resolve the image repository secret token.
+ The value for .Values.global.repositoryCred is used:
+ repositoryCred:
+ user: user
+ password: password
+ mail: email (optional)
+*/}}
+{{- define "common.repository.secret" -}}
+ {{- $repo := include "common.repository" . }}
+ {{- $cred := .Values.global.repositoryCred }}
+ {{- $mail := default "@" $cred.mail }}
+ {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }}
+ {{- printf "{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}" $repo $cred.user $cred.password $mail $auth | b64enc -}}
+{{- end -}}
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_service.tpl b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_service.tpl
new file mode 100644
index 00000000..77b77d05
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/templates/_service.tpl
@@ -0,0 +1,31 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+
+{{/*
+ Resolve the name of a chart's service.
+
+ The default will be the chart name (or .Values.nameOverride if set).
+ And the use of .Values.service.name overrides all.
+
+ - .Values.service.name : override default service (ie. chart) name
+*/}}
+{{/*
+ Expand the service name for a chart.
+*/}}
+{{- define "common.servicename" -}}
+ {{- $name := default .Chart.Name .Values.nameOverride -}}
+ {{- default $name .Values.service.name | trunc 63 | trimSuffix "-" -}}
+{{- end -}} \ No newline at end of file
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/values.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/values.yaml
new file mode 100644
index 00000000..f7098ee8
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/charts/common/values.yaml
@@ -0,0 +1,44 @@
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#################################################################
+# Global configuration default values that can be inherited by
+# all subcharts.
+#################################################################
+global:
+ # Change to an unused port prefix range to prevent port conflicts
+ # with other instances running within the same k8s cluster
+ nodePortPrefix: 302
+
+ # image repositories
+ repository: nexus3.onap.org:10001
+
+ # readiness check
+ readinessRepository: oomk8s
+ readinessImage: readiness-check:2.0.0
+
+ # logging agent
+ loggingRepository: docker.elastic.co
+ loggingImage: beats/filebeat:5.5.0
+
+ # image pull policy
+ pullPolicy: Always
+
+ # default mount path root directory referenced
+ # by persistent volumes and log files
+ persistence:
+ mountPath: /dockerdata-nfs
+
+ # flag to enable debugging - application support required
+ debugEnabled: true
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/deployment.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/deployment.yaml
new file mode 100644
index 00000000..66b2e747
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/deployment.yaml
@@ -0,0 +1,62 @@
+# Copyright 2018 Intel Corporation, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ app: {{ include "common.name" . }}
+ template:
+ metadata:
+ labels:
+ app: {{ include "common.name" . }}
+ release: {{ .Release.Name }}
+ spec:
+ containers:
+ - image: "{{ .Values.image.vault }}"
+ name: {{ include "common.name" . }}
+ imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+ command: ["vault","server","-dev"]
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
+ volumeMounts:
+ - mountPath: /etc/localtime
+ name: localtime
+ readOnly: true
+
+ - image: "{{ .Values.image.consul }}"
+ name: {{ include "common.name" . }}-backend
+ imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+ command: ["consul","agent","-dev"]
+ ports:
+ - name: http
+ containerPort: 8500
+ volumeMounts:
+ - mountPath: /etc/localtime
+ name: localtime
+ readOnly: true
+ volumes:
+ - name: localtime
+ hostPath:
+ path: /etc/localtime
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/service.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/service.yaml
new file mode 100644
index 00000000..04e9a5a9
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/templates/service.yaml
@@ -0,0 +1,39 @@
+# Copyright 2018 Intel Corporation, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "common.servicename" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.fullname" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - name: {{ .Values.service.portName }}
+ {{if eq .Values.service.type "NodePort" -}}
+ port: {{ .Values.service.internalPort }}
+ nodePort: {{ .Values.global.nodePortPrefix | default "302" }}{{ .Values.service.nodePort }}
+ {{- else -}}
+ port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ {{- end}}
+ protocol: TCP
+ selector:
+ app: {{ include "common.name" . }}
+ release: {{ .Release.Name }}
diff --git a/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/values.yaml b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/values.yaml
new file mode 100644
index 00000000..87c64026
--- /dev/null
+++ b/vagrant/tests/vnfs/testrb/helm/vault-consul-dev/values.yaml
@@ -0,0 +1,90 @@
+# Copyright 2018 Intel Corporation, Inc
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#################################################################
+# Global configuration defaults.
+#################################################################
+global:
+ nodePortPrefix: 302
+ persistence: {}
+
+# application image
+image:
+ consul: consul:1.0.6
+ vault: vault:0.10.0
+pullPolicy: Always
+
+# flag to enable debugging - application support required
+debugEnabled: false
+
+#################################################################
+# Application configuration defaults.
+#################################################################
+config:
+ consul:
+ server: true
+ log_level: INFO
+ server: true
+ data_dir: '/consul/data'
+ ports:
+ http: 8500
+ https: -1
+
+ vault:
+ storage:
+ consul:
+ address: localhost:8500
+ path: vault
+ listener:
+ tcp:
+ address: '[::]:8200'
+ tls_disable: true
+ disable_mlock: true
+
+# default number of instances
+replicaCount: 1
+
+nodeSelector: {}
+
+affinity: {}
+
+# probe configuration parameters
+liveness:
+ initialDelaySeconds: 10
+ periodSeconds: 10
+ # necessary to disable liveness probe when setting breakpoints
+ # in debugger so K8s doesn't restart unresponsive container
+ enabled: true
+
+readiness:
+ initialDelaySeconds: 10
+ periodSeconds: 10
+
+persistence:
+ enabled: true
+ volumeReclaimPolicy: Retain
+ accessMode: ReadWriteOnce
+ size: 2Gi
+ mountPath: /dockerdata-nfs
+ mountSubPath: sms/consul/data
+
+service:
+ type: NodePort
+ name: vault-consul
+ portName: vault-consul
+ internalPort: 8200
+ nodePort: 44
+
+ingress:
+ enabled: false