summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/index.rst1
-rw-r--r--kud/deployment_infra/playbooks/configure-virtlet.yml4
-rw-r--r--kud/deployment_infra/playbooks/kud-vars.yml3
-rw-r--r--kud/hosting_providers/vagrant/Vagrantfile8
-rw-r--r--kud/hosting_providers/vagrant/config/default.yml2
-rw-r--r--kud/hosting_providers/vagrant/config/samples/pdf.yml.aio2
-rwxr-xr-xkud/tests/plugin_collection_v2.sh85
-rw-r--r--kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml3
-rw-r--r--kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml4
-rw-r--r--kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml6
-rw-r--r--kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml2
-rw-r--r--src/Makefile8
-rw-r--r--src/dcm/Makefile37
-rw-r--r--src/dcm/api/api.go156
-rw-r--r--src/dcm/api/clusterHandler.go162
-rw-r--r--src/dcm/api/keyValueHandler.go161
-rw-r--r--src/dcm/api/logicalCloudHandler.go195
-rw-r--r--src/dcm/api/quotaHandler.go162
-rw-r--r--src/dcm/api/userPermissionsHandler.go162
-rw-r--r--src/dcm/cmd/main.go78
-rw-r--r--src/dcm/go.mod22
-rw-r--r--src/dcm/go.sum468
-rw-r--r--src/dcm/pkg/module/apply.go451
-rw-r--r--src/dcm/pkg/module/cluster.go205
-rw-r--r--src/dcm/pkg/module/cluster_test.go115
-rw-r--r--src/dcm/pkg/module/keyvalue.go205
-rw-r--r--src/dcm/pkg/module/keyvalue_test.go115
-rw-r--r--src/dcm/pkg/module/logicalcloud.go291
-rw-r--r--src/dcm/pkg/module/logicalcloud_test.go157
-rw-r--r--src/dcm/pkg/module/module.go39
-rw-r--r--src/dcm/pkg/module/quota.go222
-rw-r--r--src/dcm/pkg/module/quota_test.go115
-rw-r--r--src/dcm/pkg/module/userpermissions.go193
-rw-r--r--src/dcm/pkg/module/userpermissions_test.go110
-rwxr-xr-xsrc/dcm/test/dcm_call_api.sh147
-rw-r--r--src/k8splugin/api/api.go9
-rw-r--r--src/k8splugin/api/brokerhandler_test.go8
-rw-r--r--src/ncm/api/api.go52
-rw-r--r--src/ncm/api/clusterhandler.go47
-rw-r--r--src/ncm/api/clusterhandler_test.go27
-rw-r--r--src/ncm/api/netcontrolintenthandler.go230
-rw-r--r--src/ncm/api/workloadifintenthandler.go251
-rw-r--r--src/ncm/api/workloadintenthandler.go218
-rw-r--r--src/ncm/go.mod15
-rw-r--r--src/ncm/pkg/module/cluster.go255
-rw-r--r--src/ncm/pkg/module/module.go14
-rw-r--r--src/ncm/pkg/module/module_definitions.go58
-rw-r--r--src/ncm/pkg/module/netcontrolintent.go295
-rw-r--r--src/ncm/pkg/module/network.go14
-rw-r--r--src/ncm/pkg/module/providernet.go18
-rw-r--r--src/ncm/pkg/module/resources.go273
-rw-r--r--src/ncm/pkg/module/workloadifintent.go188
-rw-r--r--src/ncm/pkg/module/workloadintent.go181
-rw-r--r--src/orchestrator/api/add_intents_handler.go71
-rw-r--r--src/orchestrator/api/api.go22
-rw-r--r--src/orchestrator/api/app_intent_handler.go77
-rw-r--r--src/orchestrator/api/app_profilehandler.go8
-rw-r--r--src/orchestrator/api/composite_profilehandler_test.go4
-rw-r--r--src/orchestrator/api/controllerhandler.go106
-rw-r--r--src/orchestrator/api/controllerhandler_test.go63
-rw-r--r--src/orchestrator/api/instantiation_handler.go47
-rw-r--r--src/orchestrator/api/projecthandler_test.go10
-rw-r--r--src/orchestrator/cmd/main.go2
-rw-r--r--src/orchestrator/go.mod4
-rw-r--r--src/orchestrator/go.sum113
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml17
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml35
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt1
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart1/values.yaml55
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml17
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml4
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml15
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml35
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt1
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml22
-rw-r--r--src/orchestrator/mock_files/mock_charts/testchart2/values.yaml55
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml8
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml7
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml9
-rw-r--r--src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml22
-rw-r--r--src/orchestrator/pkg/appcontext/appcontext.go34
-rw-r--r--src/orchestrator/pkg/appcontext/appcontext_test.go6
-rw-r--r--src/orchestrator/pkg/gpic/gpic.go120
-rw-r--r--src/orchestrator/pkg/infra/contextdb/mock.go2
-rw-r--r--src/orchestrator/pkg/infra/db/mongo.go32
-rw-r--r--src/orchestrator/pkg/infra/db/store.go5
-rw-r--r--src/orchestrator/pkg/infra/validation/validation.go67
-rw-r--r--src/orchestrator/pkg/infra/validation/validation_test.go37
-rw-r--r--src/orchestrator/pkg/module/add_intents.go90
-rw-r--r--src/orchestrator/pkg/module/app_intent.go133
-rw-r--r--src/orchestrator/pkg/module/app_intent_test.go69
-rw-r--r--src/orchestrator/pkg/module/app_profile.go2
-rw-r--r--src/orchestrator/pkg/module/composite_profile.go6
-rw-r--r--src/orchestrator/pkg/module/controller.go75
-rw-r--r--src/orchestrator/pkg/module/controller_test.go39
-rw-r--r--src/orchestrator/pkg/module/instantiation.go188
-rw-r--r--src/orchestrator/pkg/module/module.go45
-rw-r--r--src/orchestrator/pkg/rtcontext/rtcontext_test.go4
-rw-r--r--src/orchestrator/utils/helm/helm.go331
-rw-r--r--src/orchestrator/utils/helm/helm_test.go203
-rw-r--r--src/orchestrator/utils/helm/profile_yaml.go109
-rw-r--r--src/orchestrator/utils/utils.go116
114 files changed, 8669 insertions, 246 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 7a49b6d1..62c5da00 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,5 +1,6 @@
MultiCloud Kubernetes Plugin
============================
+.. _master_index:
This plugin is a part of the MultiCloud component in ONAP.
It will allow ONAP to deploy/manage VM and container based VNFs
diff --git a/kud/deployment_infra/playbooks/configure-virtlet.yml b/kud/deployment_infra/playbooks/configure-virtlet.yml
index 18d3740a..d2461f73 100644
--- a/kud/deployment_infra/playbooks/configure-virtlet.yml
+++ b/kud/deployment_infra/playbooks/configure-virtlet.yml
@@ -40,7 +40,7 @@
- regexp: 'centos/(\d+)-(\d+)'
url: 'https://cloud.centos.org/centos/$1/images/CentOS-$1-x86_64-GenericCloud-$2.qcow2'
- name: fedora
- url: https://dl.fedoraproject.org/pub/fedora/linux/releases/29/Cloud/x86_64/images/Fedora-Cloud-Base-29-1.2.x86_64.qcow2
+ url: https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2
{% if lookup('env','http_proxy') != "" %}
transports:
"":
@@ -207,11 +207,13 @@
chdir: "{{ criproxy_dest }}"
when: criproxy_source_type == "source"
- name: download CRIproxy package
+ become: yes
get_url:
url: "{{ criproxy_url }}"
dest: "{{ criproxy_dest }}/criproxy"
when: criproxy_source_type == "binary"
- name: set criproxy execution permissions
+ become: yes
file:
path: "{{ criproxy_dest }}/criproxy"
mode: "+x"
diff --git a/kud/deployment_infra/playbooks/kud-vars.yml b/kud/deployment_infra/playbooks/kud-vars.yml
index a592a909..0fdfafeb 100644
--- a/kud/deployment_infra/playbooks/kud-vars.yml
+++ b/kud/deployment_infra/playbooks/kud-vars.yml
@@ -18,10 +18,11 @@ ovn_kubernetes_url: "https://github.com/openvswitch/ovn-kubernetes/archive/v{{ o
#ovn_kubernetes_version: 456a0857956988f968bb08644c650ba826592ec1
#ovn_kubernetes_url: "https://github.com/openvswitch/ovn-kubernetes"
-criproxy_dest: "{{ base_dest }}/criproxy"
+criproxy_dest: "/usr/local/bin"
criproxy_source_type: "binary"
criproxy_version: 0.14.0
criproxy_url: "https://github.com/Mirantis/criproxy/releases/download/v{{ criproxy_version }}/criproxy"
+#criproxy_dest: "{{ base_dest }}/criproxy"
#criproxy_source_type: "source"
#criproxy_version: b5ca5a6cec278e2054dface4f7a3e111fb9ab84b
#criproxy_url: "https://github.com/Mirantis/criproxy"
diff --git a/kud/hosting_providers/vagrant/Vagrantfile b/kud/hosting_providers/vagrant/Vagrantfile
index 2d1b5ab4..eb5e5cdc 100644
--- a/kud/hosting_providers/vagrant/Vagrantfile
+++ b/kud/hosting_providers/vagrant/Vagrantfile
@@ -10,8 +10,8 @@
##############################################################################
box = {
- :virtualbox => { :name => 'elastic/ubuntu-16.04-x86_64', :version => '20180708.0.0' },
- :libvirt => { :name => 'elastic/ubuntu-16.04-x86_64', :version=> '20180210.0.0'}
+ :virtualbox => { :name => 'elastic/ubuntu-18.04-x86_64', :version => '20191013.0.0'},
+ :libvirt => { :name => 'intergratedcloudnative/ubuntu1804', :version => '1.0.0'}
}
require 'yaml'
@@ -122,8 +122,8 @@ Vagrant.configure("2") do |config|
installer.vm.provision 'shell', privileged: false do |sh|
sh.env = {'KUD_PLUGIN_ENABLED': 'false', 'OVN_CENTRAL_INTERFACE': 'eth1'}
sh.inline = <<-SHELL
- cp /vagrant/insecure_keys/key.pub /home/vagrant/.ssh/id_rsa.pub
- cp /vagrant/insecure_keys/key /home/vagrant/.ssh/id_rsa
+ cp /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/insecure_keys/key.pub /home/vagrant/.ssh/id_rsa.pub
+ cp /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/insecure_keys/key /home/vagrant/.ssh/id_rsa
chown vagrant /home/vagrant/.ssh/id_rsa
chmod 400 /home/vagrant/.ssh/id_rsa
cd /home/vagrant/multicloud-k8s/kud/hosting_providers/vagrant/ && ./installer.sh | tee kud_installer.log
diff --git a/kud/hosting_providers/vagrant/config/default.yml b/kud/hosting_providers/vagrant/config/default.yml
index 10b93663..094c3594 100644
--- a/kud/hosting_providers/vagrant/config/default.yml
+++ b/kud/hosting_providers/vagrant/config/default.yml
@@ -37,7 +37,7 @@
memory: 32768
cpus: 16
volumes:
- - name: sda
+ - name: sdb
size: 50
mount: /var/lib/docker/
roles:
diff --git a/kud/hosting_providers/vagrant/config/samples/pdf.yml.aio b/kud/hosting_providers/vagrant/config/samples/pdf.yml.aio
index 48a3c938..a87f967e 100644
--- a/kud/hosting_providers/vagrant/config/samples/pdf.yml.aio
+++ b/kud/hosting_providers/vagrant/config/samples/pdf.yml.aio
@@ -13,7 +13,7 @@
memory: 32768
cpus: 16
volumes:
- - name: sda
+ - name: sdb
size: 50
mount: /var/lib/docker/
roles:
diff --git a/kud/tests/plugin_collection_v2.sh b/kud/tests/plugin_collection_v2.sh
index 068864d7..09dec5c4 100755
--- a/kud/tests/plugin_collection_v2.sh
+++ b/kud/tests/plugin_collection_v2.sh
@@ -42,7 +42,7 @@ project_description="test_project_description"
userData1="user1"
userData2="user2"
-composite_app_name="test_composite_app"
+composite_app_name="test_composite_app_collection"
composite_app_description="test_project_description"
composite_app_version="test_composite_app_version"
app1_helm_path="$CSAR_DIR/$csar_id/collectd.tar.gz"
@@ -58,12 +58,19 @@ app2_desc="prometheus_desc"
main_composite_profile_name="main_composite_profile"
sub_composite_profile_name1="test_composite_profile1"
sub_composite_profile_name2="test_composite_profile2"
-composite_profile_description="test_composite_profile_description"
+main_composite_profile_description="main_composite_profile_description"
+sub_composite_profile_description="sub_composite_profile_description"
-genericPlacementIntentName1="test_gen_placement_intent1"
-genericPlacementIntentName2="test_gen_placement_intent2"
+genericPlacementIntentName="test_gen_placement_intent1"
genericPlacementIntentDesc="test_gen_placement_intent_desc"
logicalCloud="logical_cloud_name"
+
+appIntentNameForApp1="appIntentForApp1"
+appIntentForApp1Desc="AppIntentForApp1Desc"
+appIntentNameForApp2="appIntentForApp2"
+appIntentForApp2Desc="AppIntentForApp2Desc"
+providerName1="aws"
+providerName2="azure"
clusterName1="edge1"
clusterName2="edge2"
clusterLabelName1="east-us1"
@@ -71,6 +78,9 @@ clusterLabelName2="east-us2"
deploymentIntentGroupName="test_deployment_intent_group"
deploymentIntentGroupNameDesc="test_deployment_intent_group_desc"
+releaseName="test"
+intentToBeAddedinDeploymentIntentGroup="name_of_intent_to_be_added_in_deployment_group"
+intentToBeAddedinDeploymentIntentGroupDesc="desc_of_intent_to_be_added_in_deployment_group"
chart_name="edgex"
profile_name="test_profile"
@@ -166,7 +176,7 @@ payload="$(cat <<EOF
{
"metadata":{
"name":"${main_composite_profile_name}",
- "description":"${composite_profile_description}",
+ "description":"${main_composite_profile_description}",
"userData1":"${userData1}",
"userData2":"${userData2}"
}
@@ -183,7 +193,7 @@ payload="$(cat <<EOF
{
"metadata":{
"name":"${sub_composite_profile_name1}",
- "description":"${composite_profile_description}",
+ "description":"${sub_composite_profile_description}",
"userData1":"${userData1}",
"userData2":"${userData2}"
},
@@ -203,7 +213,7 @@ payload="$(cat <<EOF
{
"metadata":{
"name":"${sub_composite_profile_name2}",
- "description":"${composite_profile_description}",
+ "description":"${sub_composite_profile_description}",
"userData1":"${userData1}",
"userData2":"${userData2}"
},
@@ -224,25 +234,7 @@ print_msg "Registering GenericPlacementIntent for app1"
payload="$(cat <<EOF
{
"metadata":{
- "name":"${genericPlacementIntentName1}",
- "description":"${genericPlacementIntentDesc}",
- "userData1":"${userData1}",
- "userData2":"${userData2}"
- },
- "spec":{
- "logical-cloud":"${logicalCloud}"
- }
-}
-EOF
-)"
-call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents"
-
-
-print_msg "Registering GenericPlacementIntent for app2"
-payload="$(cat <<EOF
-{
- "metadata":{
- "name":"${genericPlacementIntentName2}",
+ "name":"${genericPlacementIntentName}",
"description":"${genericPlacementIntentDesc}",
"userData1":"${userData1}",
"userData2":"${userData2}"
@@ -261,8 +253,8 @@ print_msg "Adding placement intent for app1(collectd)"
payload="$(cat <<EOF
{
"metadata":{
- "name":"${genericPlacementIntentName1}",
- "description":"${genericPlacementIntentDesc}",
+ "name":"${appIntentNameForApp1}",
+ "description":"${appIntentForApp1Desc}",
"userData1":"${userData1}",
"userData2":"${userData2}"
},
@@ -270,18 +262,21 @@ payload="$(cat <<EOF
"app-name":"${app1_name}",
"intent":{
"allOf":[
- {
+ { "provider-name":"${providerName1}",
"cluster-name":"${clusterName1}"
},
{
+ "provider-name":"${providerName2}",
"cluster-name":"${clusterName2}"
},
{
"anyOf":[
{
+ "provider-name":"${providerName1}",
"cluster-label-name":"${clusterLabelName1}"
},
{
+ "provider-name":"${providerName2}",
"cluster-label-name":"${clusterLabelName2}"
}
]
@@ -292,14 +287,14 @@ payload="$(cat <<EOF
}
EOF
)"
-call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName1}/app-intents"
+call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName}/app-intents"
print_msg "Adding placement intent for app2(prometheus)"
payload="$(cat <<EOF
{
"metadata":{
- "name":"${genericPlacementIntentName2}",
- "description":"${genericPlacementIntentDesc}",
+ "name":"${appIntentNameForApp2}",
+ "description":"${appIntentForApp2Desc}",
"userData1":"${userData1}",
"userData2":"${userData2}"
},
@@ -308,17 +303,21 @@ payload="$(cat <<EOF
"intent":{
"allOf":[
{
+ "provider-name":"${providerName1}",
"cluster-name":"${clusterName1}"
},
{
+ "provider-name":"${providerName2}",
"cluster-name":"${clusterName2}"
},
{
"anyOf":[
{
+ "provider-name":"${providerName1}",
"cluster-label-name":"${clusterLabelName1}"
},
{
+ "provider-name":"${providerName2}",
"cluster-label-name":"${clusterLabelName2}"
}
]
@@ -329,7 +328,7 @@ payload="$(cat <<EOF
}
EOF
)"
-call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName2}/app-intents"
+call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/generic-placement-intents/${genericPlacementIntentName}/app-intents"
# END: Adding placement intent for each app in the composite app.
# BEGIN: Registering DeploymentIntentGroup in the database
@@ -344,20 +343,20 @@ payload="$(cat <<EOF
},
"spec":{
"profile":"${main_composite_profile_name}",
- "version":"${composite_app_version}",
+ "version":"${releaseName}",
"override-values":[
{
"app-name":"${app1_name}",
"values":
{
- "imageRepository":"registry.hub.docker.com"
+ "collectd_prometheus.service.targetPort":"9104"
}
},
{
"app-name":"${app2_name}",
"values":
{
- "imageRepository":"registry.hub.docker.com"
+ "prometheus.service.nameOfPort":"WebPort9090"
}
}
]
@@ -369,19 +368,18 @@ call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${
# END: Registering DeploymentIntentGroup in the database
# BEGIN: Adding intents to an intent group
-print_msg "Adding two intents to the intent group"
+print_msg "Adding the genericPlacement intent to the deploymentIntent group"
payload="$(cat <<EOF
{
"metadata":{
- "name":"${deploymentIntentGroupName}",
- "description":"${deploymentIntentGroupNameDesc}",
+ "name":"${intentToBeAddedinDeploymentIntentGroup}",
+ "description":"${intentToBeAddedinDeploymentIntentGroupDesc}",
"userData1":"${userData1}",
"userData2":"${userData2}"
},
"spec":{
"intent":{
- "generic-placement-intent":"${genericPlacementIntentName1}",
- "generic-placement-intent":"${genericPlacementIntentName2}"
+ "generic-placement-intent":"${genericPlacementIntentName}"
}
}
}
@@ -390,3 +388,8 @@ EOF
call_api -d "${payload}" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups/${deploymentIntentGroupName}/intents"
# END: Adding intents to an intent group
+#BEGIN: Instantiation
+print_msg "Getting the sorted templates for each of the apps.."
+call_api -d "" "${base_url}/projects/${project_name}/composite-apps/${composite_app_name}/${composite_app_version}/deployment-intent-groups/${deploymentIntentGroupName}/instantiate"
+# END: Instantiation
+
diff --git a/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml b/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml
index 304ae5de..b3c36804 100644
--- a/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml
+++ b/kud/tests/vnfs/comp-app/collection/app1/profile/override_values.yaml
@@ -1,8 +1,7 @@
collectd_prometheus:
service:
type: ClusterIP
- name: collectd-override
- port: 9103
+ port: 9104
targetPort: 9103
selector:
app: collectd
diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml
index 0114ed2e..56fbb5f4 100644
--- a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml
+++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/templates/service.yaml
@@ -26,12 +26,12 @@ spec:
{{- end }}
{{- end }}
ports:
- - name: web
+ - name: {{ .Values.prometheus.service.nameOfPort }}
{{- if eq .Values.prometheus.service.type "NodePort" }}
nodePort: {{ .Values.global.nodePortPrefix }}{{ .Values.prometheus.service.nodePort }}
{{- end }}
port: 9090
- targetPort: web
+ targetPort: {{ .Values.prometheus.service.nameOfPort }}
selector:
app: prometheus
prometheus: {{ template "prometheus.fullname" . }}-prometheus
diff --git a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml
index e35c6735..fa528900 100644
--- a/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml
+++ b/kud/tests/vnfs/comp-app/collection/app2/helm/prometheus/values.yaml
@@ -37,9 +37,10 @@ prometheus:
- port: cadvisor-prometheus
interval: 10s
path: /metrics
-
+
resources: {}
service:
+ nameOfPort: web
type: ClusterIP
annotations: {}
labels: {}
@@ -67,3 +68,6 @@ prometheus:
#type: NodePort
sessionAffinity: ""
+
+global:
+ imagePullSecrets: "" \ No newline at end of file
diff --git a/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml b/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml
index 6743ac5b..041fc40d 100644
--- a/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml
+++ b/kud/tests/vnfs/comp-app/collection/app2/profile/override_values.yaml
@@ -1,6 +1,6 @@
service:
type: ClusterIP
- name: Prometheus
+ nameOfPort: webPort
annotations: {}
labels: {}
clusterIP: "" \ No newline at end of file
diff --git a/src/Makefile b/src/Makefile
index 8d856563..36a981a9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2,18 +2,26 @@ build:
$(MAKE) -C monitor build
$(MAKE) -C k8splugin build
$(MAKE) -C orchestrator build
+ $(MAKE) -C ncm build
+ $(MAKE) -C dcm build
deploy:
$(MAKE) -C monitor deploy
$(MAKE) -C k8splugin deploy
$(MAKE) -C orchestrator deploy
+ $(MAKE) -C ncm deploy
+ $(MAKE) -C dcm deploy
all:
$(MAKE) -C monitor all
$(MAKE) -C k8splugin all
$(MAKE) -C orchestrator all
+ $(MAKE) -C ncm all
+ $(MAKE) -C dcm all
clean:
$(MAKE) -C monitor clean
$(MAKE) -C k8splugin clean
$(MAKE) -C orchestrator clean
+ $(MAKE) -C ncm clean
+ $(MAKE) -C dcm clean
diff --git a/src/dcm/Makefile b/src/dcm/Makefile
new file mode 100644
index 00000000..62b82a5f
--- /dev/null
+++ b/src/dcm/Makefile
@@ -0,0 +1,37 @@
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2020 Intel Corporation
+# 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
+##############################################################################
+
+export GO111MODULE=on
+
+all: clean
+ CGO_ENABLED=1 GOOS=linux GOARCH=amd64
+ @go build -tags netgo -o ./dcm ./cmd/main.go
+
+# The following is done this way as each patch on CI runs build and each merge runs deploy. So for build we don't need to build binary and hence
+# no need to create a static binary with additional flags. However, for generating binary, additional build flags are necessary. This if used with
+# mock plugin errors out for unit tests. So the seperation avoids the error.
+
+build: clean test cover
+deploy: build
+
+.PHONY: test
+test: clean
+ @go test -race ./...
+
+format:
+ @go fmt ./...
+
+clean:
+ @find . -name "*so" -delete
+ @rm -f dcm coverage.html coverage.out
+
+.PHONY: cover
+cover:
+ @go test -race ./... -coverprofile=coverage.out
+ @go tool cover -html=coverage.out -o coverage.html
diff --git a/src/dcm/api/api.go b/src/dcm/api/api.go
new file mode 100644
index 00000000..87ad77b5
--- /dev/null
+++ b/src/dcm/api/api.go
@@ -0,0 +1,156 @@
+/*
+Copyright 2020 Intel Corporation.
+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 api
+
+import (
+
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+
+ "github.com/gorilla/mux"
+)
+
+// NewRouter creates a router that registers the various urls that are
+// supported
+
+func NewRouter(
+ logicalCloudClient module.LogicalCloudManager,
+ clusterClient module.ClusterManager,
+ userPermissionClient module.UserPermissionManager,
+ quotaClient module.QuotaManager,
+ keyValueClient module.KeyValueManager) *mux.Router {
+
+ router := mux.NewRouter()
+
+ // Set up Logical Cloud handler routes
+ if logicalCloudClient == nil {
+ logicalCloudClient = module.NewLogicalCloudClient()
+ }
+
+ if clusterClient == nil {
+ clusterClient = module.NewClusterClient()
+ }
+
+ if quotaClient == nil {
+ quotaClient = module.NewQuotaClient()
+ }
+
+ logicalCloudHandler := logicalCloudHandler{client: logicalCloudClient,
+ clusterClient: clusterClient,
+ quotaClient: quotaClient,
+ }
+ lcRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
+ lcRouter.HandleFunc(
+ "/logical-clouds",
+ logicalCloudHandler.createHandler).Methods("POST")
+ lcRouter.HandleFunc(
+ "/logical-clouds",
+ logicalCloudHandler.getHandler).Methods("GET")
+ lcRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}",
+ logicalCloudHandler.getHandler).Methods("GET")
+ lcRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}",
+ logicalCloudHandler.deleteHandler).Methods("DELETE")
+ lcRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}",
+ logicalCloudHandler.updateHandler).Methods("PUT")
+ lcRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/apply",
+ logicalCloudHandler.applyHandler).Methods("POST")
+ // To Do
+ // get kubeconfig
+ /*lcRouter.HandleFunc(
+ "/logical-clouds/{name}/kubeconfig?cluster-reference={cluster}",
+ logicalCloudHandler.getConfigHandler).Methods("GET")
+ //get status
+ lcRouter.HandleFunc(
+ "/logical-clouds/{name}/cluster-references/",
+ logicalCloudHandler.associateHandler).Methods("GET")*/
+
+ // Set up Cluster API
+
+ clusterHandler := clusterHandler{client: clusterClient}
+ clusterRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
+ clusterRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-references",
+ clusterHandler.createHandler).Methods("POST")
+ clusterRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-references",
+ clusterHandler.getHandler).Methods("GET")
+ clusterRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-references/{cluster-reference}",
+ clusterHandler.getHandler).Methods("GET")
+ clusterRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-references/{cluster-reference}",
+ clusterHandler.updateHandler).Methods("PUT")
+ clusterRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-references/{cluster-reference}",
+ clusterHandler.deleteHandler).Methods("DELETE")
+
+ // Set up User Permission API
+ if userPermissionClient == nil {
+ userPermissionClient = module.NewUserPermissionClient()
+ }
+ userPermissionHandler := userPermissionHandler{client: userPermissionClient}
+ upRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
+ upRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/user-permissions",
+ userPermissionHandler.createHandler).Methods("POST")
+ upRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/user-permissions/{permission-name}",
+ userPermissionHandler.getHandler).Methods("GET")
+ upRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/user-permissions/{permission-name}",
+ userPermissionHandler.updateHandler).Methods("PUT")
+ upRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/user-permissions/{permission-name}",
+ userPermissionHandler.deleteHandler).Methods("DELETE")
+
+ // Set up Quota API
+
+ quotaHandler := quotaHandler{client: quotaClient}
+ quotaRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
+ quotaRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-quotas",
+ quotaHandler.createHandler).Methods("POST")
+ quotaRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-quotas/{quota-name}",
+ quotaHandler.getHandler).Methods("GET")
+ quotaRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-quotas/{quota-name}",
+ quotaHandler.updateHandler).Methods("PUT")
+ quotaRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/cluster-quotas/{quota-name}",
+ quotaHandler.deleteHandler).Methods("DELETE")
+
+ // Set up Key Value API
+ if keyValueClient == nil {
+ keyValueClient = module.NewKeyValueClient()
+ }
+ keyValueHandler := keyValueHandler{client: keyValueClient}
+ kvRouter := router.PathPrefix("/v2/projects/{project-name}").Subrouter()
+ kvRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/kv-pairs",
+ keyValueHandler.createHandler).Methods("POST")
+ kvRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/kv-pairs/{kv-pair-name}",
+ keyValueHandler.getHandler).Methods("GET")
+ kvRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/kv-pairs/{kv-pair-name}",
+ keyValueHandler.updateHandler).Methods("PUT")
+ kvRouter.HandleFunc(
+ "/logical-clouds/{logical-cloud-name}/kv-pairs/{kv-pair-name}",
+ keyValueHandler.deleteHandler).Methods("DELETE")
+ return router
+}
diff --git a/src/dcm/api/clusterHandler.go b/src/dcm/api/clusterHandler.go
new file mode 100644
index 00000000..3e483f06
--- /dev/null
+++ b/src/dcm/api/clusterHandler.go
@@ -0,0 +1,162 @@
+/*
+* Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "net/http"
+ "io"
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+
+ "github.com/gorilla/mux"
+)
+
+
+// clusterHandler is used to store backend implementations objects
+type clusterHandler struct {
+ client module.ClusterManager
+}
+
+// CreateHandler handles creation of the cluster reference entry in the database
+
+func (h clusterHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ var v module.Cluster
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Cluster Reference Name is required.
+ if v.MetaData.ClusterReference == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateCluster(project, logicalCloud, v)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// getHandler handle GET operations on a particular name
+// Returns a Cluster Reference
+func (h clusterHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["cluster-reference"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetAllClusters(project, logicalCloud)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetCluster(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// UpdateHandler handles Update operations on a particular cluster reference
+func (h clusterHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
+ var v module.Cluster
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["cluster-reference"]
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+// Name is required.
+ if v.MetaData.ClusterReference == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.UpdateCluster(project, logicalCloud, name, v)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+}
+
+//deleteHandler handles DELETE operations on a particular record
+func (h clusterHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["cluster-reference"]
+
+ err := h.client.DeleteCluster(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/dcm/api/keyValueHandler.go b/src/dcm/api/keyValueHandler.go
new file mode 100644
index 00000000..57df6556
--- /dev/null
+++ b/src/dcm/api/keyValueHandler.go
@@ -0,0 +1,161 @@
+/*
+* Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "net/http"
+ "io"
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+ "github.com/gorilla/mux"
+)
+
+
+// keyValueHandler is used to store backend implementations objects
+type keyValueHandler struct {
+ client module.KeyValueManager
+}
+
+// CreateHandler handles creation of the key value entry in the database
+
+func (h keyValueHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ var v module.KeyValue
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Key Value Name is required.
+ if v.MetaData.KeyValueName == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateKVPair(project, logicalCloud, v)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// getHandler handle GET operations on a particular name
+// Returns a Key Value
+func (h keyValueHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["kv-pair-name"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetAllKVPairs(project, logicalCloud)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetKVPair(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// UpdateHandler handles Update operations on a particular Key Value
+func (h keyValueHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
+ var v module.KeyValue
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["kv-pair-name"]
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if v.MetaData.KeyValueName == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.UpdateKVPair(project, logicalCloud, name, v)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+}
+
+//deleteHandler handles DELETE operations on a particular record
+func (h keyValueHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["kv-pair-name"]
+
+ err := h.client.DeleteKVPair(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/dcm/api/logicalCloudHandler.go b/src/dcm/api/logicalCloudHandler.go
new file mode 100644
index 00000000..d8fcf268
--- /dev/null
+++ b/src/dcm/api/logicalCloudHandler.go
@@ -0,0 +1,195 @@
+/*
+* Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "net/http"
+ "io"
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+ "github.com/gorilla/mux"
+)
+
+
+// logicalCloudHandler is used to store backend implementations objects
+type logicalCloudHandler struct {
+ client module.LogicalCloudManager
+ clusterClient module.ClusterManager
+ quotaClient module.QuotaManager
+}
+
+// CreateHandler handles creation of the logical cloud entry in the database
+
+func (h logicalCloudHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ var v module.LogicalCloud
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Logical Cloud Name is required.
+ if v.MetaData.LogicalCloudName == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.Create(project, v)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// getHandler handle GET operations on a particular name
+// Returns a Logical Cloud
+func (h logicalCloudHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ name := vars["logical-cloud-name"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetAll(project)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.Get(project, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// UpdateHandler handles Update operations on a particular logical cloud
+func (h logicalCloudHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
+ var v module.LogicalCloud
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ name := vars["logical-cloud-name"]
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ if v.MetaData.LogicalCloudName == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.Update(project, name, v)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+}
+
+func (h logicalCloudHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ name := vars["logical-cloud-name"]
+
+ err := h.client.Delete(project, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
+
+func (h logicalCloudHandler) applyHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ name := vars["logical-cloud-name"]
+
+ // Get logical cloud
+ lc, err := h.client.Get(project, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ // Get Clusters
+ clusters, err := h.clusterClient.GetAllClusters(project, name)
+
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+
+ //Get Quotas
+ quotas, err := h.quotaClient.GetAllQuotas(project, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ err = module.CreateEtcdContext(lc, clusters, quotas)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ return
+}
diff --git a/src/dcm/api/quotaHandler.go b/src/dcm/api/quotaHandler.go
new file mode 100644
index 00000000..bca5206a
--- /dev/null
+++ b/src/dcm/api/quotaHandler.go
@@ -0,0 +1,162 @@
+/*
+* Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "net/http"
+ "io"
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+
+ "github.com/gorilla/mux"
+)
+
+
+// quotaHandler is used to store backend implementations objects
+type quotaHandler struct {
+ client module.QuotaManager
+}
+
+// CreateHandler handles creation of the quota entry in the database
+
+func (h quotaHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ var v module.Quota
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Quota Name is required.
+ if v.MetaData.QuotaName == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateQuota(project, logicalCloud, v)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// getHandler handle GET operations on a particular name
+// Returns a quota
+func (h quotaHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["quota-name"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetAllQuotas(project, logicalCloud)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetQuota(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// UpdateHandler handles Update operations on a particular quota
+func (h quotaHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
+ var v module.Quota
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["quota-name"]
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if v.MetaData.QuotaName == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.UpdateQuota(project, logicalCloud, name, v)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+}
+
+//deleteHandler handles DELETE operations on a particular record
+func (h quotaHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["quota-name"]
+
+ err := h.client.DeleteQuota(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/dcm/api/userPermissionsHandler.go b/src/dcm/api/userPermissionsHandler.go
new file mode 100644
index 00000000..48ab3d8e
--- /dev/null
+++ b/src/dcm/api/userPermissionsHandler.go
@@ -0,0 +1,162 @@
+/*
+* Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "net/http"
+ "io"
+ "github.com/onap/multicloud-k8s/src/dcm/pkg/module"
+ "github.com/gorilla/mux"
+)
+
+
+// userPermissionHandler is used to store backend implementations objects
+type userPermissionHandler struct {
+ client module.UserPermissionManager
+}
+
+// CreateHandler handles creation of the user permission entry in the database
+
+func (h userPermissionHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ var v module.UserPermission
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // User-Permission Name is required.
+ if v.UserPermissionName == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateUserPerm(project, logicalCloud, v)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// getHandler handle GET operations on a particular name
+// Returns a User Permission
+func (h userPermissionHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["permission-name"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetAllUserPerms(project, logicalCloud)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetAllUserPerms(project, logicalCloud)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// UpdateHandler handles Update operations on a particular user permission
+func (h userPermissionHandler) updateHandler(w http.ResponseWriter, r *http.Request) {
+ var v module.UserPermission
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["permission-name"]
+
+ err := json.NewDecoder(r.Body).Decode(&v)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if v.UserPermissionName == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.UpdateUserPerm(project, logicalCloud, name, v)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(),
+ http.StatusInternalServerError)
+ return
+ }
+}
+
+//deleteHandler handles DELETE operations on a particular record
+func (h userPermissionHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ project := vars["project-name"]
+ logicalCloud := vars["logical-cloud-name"]
+ name := vars["permission-name"]
+
+ err := h.client.DeleteUserPerm(project, logicalCloud, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/dcm/cmd/main.go b/src/dcm/cmd/main.go
new file mode 100644
index 00000000..77d5348b
--- /dev/null
+++ b/src/dcm/cmd/main.go
@@ -0,0 +1,78 @@
+/*
+Copyright 2020 Intel Corporation.
+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 main
+
+import (
+ "context"
+ "log"
+ "math/rand"
+ "net/http"
+ "os"
+ "os/signal"
+ "time"
+
+ "github.com/onap/multicloud-k8s/src/dcm/api"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/auth"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/config"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ contextDb "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/contextdb"
+ "github.com/gorilla/handlers"
+)
+
+func main() {
+
+ rand.Seed(time.Now().UnixNano())
+
+ err := db.InitializeDatabaseConnection("mco")
+ if err != nil {
+ log.Println("Unable to initialize database connection...")
+ log.Println(err)
+ log.Fatalln("Exiting...")
+ }
+
+ err = contextDb.InitializeContextDatabase()
+ if err != nil {
+ log.Println("Unable to initialize database connection...")
+ log.Println(err)
+ log.Fatalln("Exiting...")
+ }
+
+ httpRouter := api.NewRouter(nil, nil, nil, nil, nil)
+ loggedRouter := handlers.LoggingHandler(os.Stdout, httpRouter)
+ log.Println("Starting Distributed Cloud Manager API")
+
+ httpServer := &http.Server{
+ Handler: loggedRouter,
+ Addr: ":" + config.GetConfiguration().ServicePort,
+ }
+
+ connectionsClose := make(chan struct{})
+ go func() {
+ c := make(chan os.Signal, 1)
+ signal.Notify(c, os.Interrupt)
+ <-c
+ httpServer.Shutdown(context.Background())
+ close(connectionsClose)
+ }()
+
+ tlsConfig, err := auth.GetTLSConfig("ca.cert", "server.cert", "server.key")
+ if err != nil {
+ log.Println("Error Getting TLS Configuration. Starting without TLS...")
+ log.Fatal(httpServer.ListenAndServe())
+ } else {
+ httpServer.TLSConfig = tlsConfig
+
+ err = httpServer.ListenAndServeTLS("", "")
+ }
+}
diff --git a/src/dcm/go.mod b/src/dcm/go.mod
new file mode 100644
index 00000000..4d73085d
--- /dev/null
+++ b/src/dcm/go.mod
@@ -0,0 +1,22 @@
+module github.com/onap/multicloud-k8s/src/dcm
+
+require (
+ github.com/gorilla/handlers v1.3.0
+ github.com/gorilla/mux v1.6.2
+ github.com/onap/multicloud-k8s/src/orchestrator v0.0.0-20200413204718-f853b30cdc26
+ github.com/pkg/errors v0.8.1
+ github.com/stretchr/testify v1.4.0
+ gopkg.in/yaml.v2 v2.2.2
+)
+
+replace (
+ k8s.io/api => k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b
+ k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8
+ k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d
+ k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190409021813-1ec86e4da56c
+ k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190409023024-d644b00f3b79
+ k8s.io/client-go => k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
+ k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190409023720-1bc0c81fa51d
+)
+
+go 1.13
diff --git a/src/dcm/go.sum b/src/dcm/go.sum
new file mode 100644
index 00000000..aa3a769e
--- /dev/null
+++ b/src/dcm/go.sum
@@ -0,0 +1,468 @@
+cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
+cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+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/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08=
+github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
+github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
+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/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
+github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
+github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+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/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
+github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
+github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
+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/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
+github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
+github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=
+github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
+github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/etcd v3.3.12+incompatible h1:pAWNwdf7QiT1zfaWyqCtNZQWCLByQyA3JrSQyuYAqnQ=
+github.com/coreos/etcd v3.3.12+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
+github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
+github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
+github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=
+github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
+github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
+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 v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
+github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+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.20190912223608-ad718029b705 h1:up4REDeXtcm77SlkowEGUuakgjpdNR2N9TkGTZSL4rM=
+github.com/docker/docker v0.7.3-0.20190912223608-ad718029b705/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
+github.com/docker/engine v0.0.0-20190620014054-c513a4c6c298/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY=
+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/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 h1:yY9rWGoXv1U5pl4gxqlULARMQD7x0QG85lqEXTWysik=
+github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
+github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
+github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
+github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
+github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
+github.com/evanphx/json-patch v4.5.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/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
+github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
+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-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
+github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
+github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
+github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
+github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
+github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
+github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
+github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
+github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
+github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc=
+github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
+github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
+github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
+github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
+github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
+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/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
+github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
+github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
+github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
+github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
+github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
+github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk=
+github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
+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.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
+github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
+github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
+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/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
+github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
+github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
+github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+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-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
+github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
+github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
+github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
+github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
+github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
+github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
+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=
+github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
+github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI=
+github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
+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/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
+github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+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-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=
+github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE=
+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/grpc-ecosystem/grpc-gateway v1.11.1 h1:/dBYI+n4xIL+Y9SKXQrjlKTmJJDwCSlNLRwZ5nBhIek=
+github.com/grpc-ecosystem/grpc-gateway v1.11.1/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/hashicorp/consul v1.4.0/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI=
+github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
+github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
+github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
+github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
+github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90/go.mod h1:o4zcYY1e0GEZI6eSEr+43QDYmuGglw1qSO6qdHUHCgg=
+github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
+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/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/hashicorp/memberlist v0.1.5/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
+github.com/hashicorp/serf v0.8.1/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
+github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
+github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+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/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
+github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
+github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
+github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
+github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
+github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
+github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/json-iterator/go v1.1.8 h1:QiWkFLKq0T7mpzwOTu6BzNDbfTE8OLrYhVKYMLF46Ok=
+github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
+github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
+github.com/karrick/godirwalk v1.10.12/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
+github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
+github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
+github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
+github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
+github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
+github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
+github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+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/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+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/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
+github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
+github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
+github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
+github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
+github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
+github.com/onap/multicloud-k8s/src/k8splugin v0.0.0-20191115005109-f168ebb73d8d/go.mod h1:EnQd/vQGZR1/55IihaHxiux4ZUig/zfXZux7bfmU0S8=
+github.com/onap/multicloud-k8s/src/orchestrator v0.0.0-20200413204718-f853b30cdc26 h1:78c4pv5dNEraV53mNIPJAbO3IElR5Ulgfj83WOFq5kY=
+github.com/onap/multicloud-k8s/src/orchestrator v0.0.0-20200413204718-f853b30cdc26/go.mod h1:l+McjmNmpsgUku+EAqVvrHnsnwBOytDVlskzkAA7LK8=
+github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
+github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
+github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
+github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+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/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
+github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
+github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
+github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+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.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
+github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
+github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+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/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
+github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
+github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rubenv/sql-migrate v0.0.0-20190902133344-8926f37f0bc1 h1:G7j/gxkXAL80NMLOWi6EEctDET1Iuxl3sBMJXDnu2z0=
+github.com/rubenv/sql-migrate v0.0.0-20190902133344-8926f37f0bc1/go.mod h1:WS0rl9eEliYI8DPnr3TOwz4439pay+qNgzJoVya/DmY=
+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/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
+github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
+github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
+github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
+github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
+github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
+github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
+github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
+github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
+github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
+github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
+github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+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/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
+github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
+github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
+github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
+github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
+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=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1 h1:j2hhcujLRHAg872RWAV5yaUrEjHEObwDv3aImCaNLek=
+github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=
+github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
+github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
+go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
+go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
+go.etcd.io/etcd v3.3.12+incompatible h1:V6PRYRGpU4k5EajJaaj/GL3hqIdzyPnBU8aPUp+35yw=
+go.etcd.io/etcd v3.3.12+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
+go.mongodb.org/mongo-driver v1.0.0 h1:KxPRDyfB2xXnDE2My8acoOWBQkfv3tz0SaWTRZjJR0c=
+go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
+go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
+go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
+go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
+go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
+golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
+golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
+golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 h1:ydJNl0ENAG67pFbB+9tfhiL2pYqLhfoaZFw/cjLhY4A=
+golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
+golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
+golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
+golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
+golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
+golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190515120540-06a5c4944438/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
+golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
+golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
+golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
+golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
+golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
+google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
+google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
+google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
+google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
+google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
+google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
+google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
+gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/gorp.v1 v1.7.2 h1:j3DWlAyGVv8whO7AcIWznQ2Yj7yJkn34B8s63GViAAw=
+gopkg.in/gorp.v1 v1.7.2/go.mod h1:Wo3h+DBQZIxATwftsglhdD/62zRFPhGhTiu5jUJmCaw=
+gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
+gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
+gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+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/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
+gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
+gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
+gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
+gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
+honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b h1:aBGgKJUM9Hk/3AE8WaZIApnTxG35kbuQba2w+SXqezo=
+k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
+k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA=
+k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
+k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d h1:Jmdtdt1ZnoGfWWIIik61Z7nKYgO3J+swQJtPYsP9wHA=
+k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apiserver v0.0.0-20190409021813-1ec86e4da56c h1:k7ALUVzrOEgz4hOF+pr4pePn7TqZ9lB/8Z8ndMSsWSU=
+k8s.io/apiserver v0.0.0-20190409021813-1ec86e4da56c/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
+k8s.io/cli-runtime v0.0.0-20190409023024-d644b00f3b79 h1:bZyxc0wzVA5KgUfAXZA6z872zDWmyslwfvrr175VF68=
+k8s.io/cli-runtime v0.0.0-20190409023024-d644b00f3b79/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM=
+k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible h1:U5Bt+dab9K8qaUmXINrkXO135kA11/i5Kg1RUydgaMQ=
+k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
+k8s.io/cloud-provider v0.0.0-20190409023720-1bc0c81fa51d h1:ad7UpNUGRx6FbYoK4+xIYyeS2CUShjNKY45YN1ipjLI=
+k8s.io/cloud-provider v0.0.0-20190409023720-1bc0c81fa51d/go.mod h1:LlIffnLBu+GG7d4ppPzC8UnA1Ex8S+ntmSRVsnr7Xy4=
+k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
+k8s.io/helm v2.14.3+incompatible h1:uzotTcZXa/b2SWVoUzM1xiCXVjI38TuxMujS/1s+3Gw=
+k8s.io/helm v2.14.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
+k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
+k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
+k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
+k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
+k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ=
+k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
+k8s.io/kubernetes v1.14.1 h1:I9F52h5sqVxBmoSsBlNQ0YygNcukDilkpGxUbJRoBoY=
+k8s.io/kubernetes v1.14.1/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
+k8s.io/utils v0.0.0-20190907131718-3d4f5b7dea0b h1:eMM0sTvh3KBVGwJfuNcU86P38TJhlVMAICbFPDG3t0M=
+k8s.io/utils v0.0.0-20190907131718-3d4f5b7dea0b/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
+sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
+sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
+sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
+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/dcm/pkg/module/apply.go b/src/dcm/pkg/module/apply.go
new file mode 100644
index 00000000..c918f749
--- /dev/null
+++ b/src/dcm/pkg/module/apply.go
@@ -0,0 +1,451 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ "strings"
+ "fmt"
+ "crypto/rsa"
+ "crypto/rand"
+ "crypto/x509"
+ "crypto/x509/pkix"
+ "encoding/json"
+ "encoding/pem"
+ "encoding/base64"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ "gopkg.in/yaml.v2"
+ pkgerrors "github.com/pkg/errors"
+
+)
+
+type Resource struct {
+ ApiVersion string `yaml:"apiVersion"`
+ Kind string `yaml:"kind"`
+ MetaData MetaDatas `yaml:"metadata"`
+ Specification Specs `yaml:"spec,omitempty"`
+ Rules []RoleRules `yaml:"rules,omitempty"`
+ Subjects []RoleSubjects `yaml:"subjects,omitempty"`
+ RoleRefs RoleRef `yaml:"roleRef,omitempty"`
+}
+
+type MetaDatas struct {
+ Name string `yaml:"name"`
+ Namespace string `yaml:"namespace,omitempty"`
+}
+
+type Specs struct {
+ Request string `yaml:"request,omitempty"`
+ Usages []string `yaml:"usages,omitempty"`
+ //Hard logicalcloud.QSpec `yaml:"hard,omitempty"`
+ Hard QSpec `yaml:"hard,omitempty"`
+}
+
+type RoleRules struct {
+ ApiGroups []string `yaml:"apiGroups"`
+ Resources []string `yaml:"resources"`
+ Verbs []string `yaml:"verbs"`
+}
+
+type RoleSubjects struct {
+ Kind string `yaml:"kind"`
+ Name string `yaml:"name"`
+ ApiGroup string `yaml:"apiGroup"`
+}
+
+type RoleRef struct {
+ Kind string `yaml:"kind"`
+ Name string `yaml:"name"`
+ ApiGroup string `yaml:"apiGroup"`
+}
+
+
+func createNamespace(logicalcloud LogicalCloud) (string, error) {
+
+ namespace := Resource{
+ ApiVersion: "v1",
+ Kind: "Namespace",
+ MetaData: MetaDatas{
+ Name: logicalcloud.Specification.NameSpace,
+ },
+ }
+
+ nsData, err := yaml.Marshal(&namespace)
+ if err != nil {
+ return "", err
+ }
+
+
+ return string(nsData), nil
+}
+
+func createRole(logicalcloud LogicalCloud) (string, error) {
+
+ userPermissions := logicalcloud.Specification.User.UserPermissions[0]
+
+ role := Resource{
+ ApiVersion: "rbac.authorization.k8s.io/v1beta1",
+ Kind: "Role",
+ MetaData: MetaDatas{
+ Name: strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "-role"}, ""),
+ Namespace: logicalcloud.Specification.NameSpace,
+ },
+ Rules: []RoleRules{ RoleRules{
+ ApiGroups: userPermissions.APIGroups,
+ Resources: userPermissions.Resources,
+ Verbs: userPermissions.Verbs,
+ },
+ },
+
+ }
+
+ roleData, err := yaml.Marshal(&role)
+ if err != nil {
+ return "", err
+ }
+
+ return string(roleData), nil
+}
+
+func createRoleBinding(logicalcloud LogicalCloud) (string, error) {
+
+ roleBinding := Resource{
+ ApiVersion: "rbac.authorization.k8s.io/v1beta1",
+ Kind: "RoleBinding",
+ MetaData: MetaDatas{
+ Name: strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "-roleBinding"}, ""),
+ Namespace: logicalcloud.Specification.NameSpace,
+ },
+ Subjects: []RoleSubjects{ RoleSubjects{
+ Kind: "User",
+ Name: logicalcloud.Specification.User.UserName,
+ ApiGroup: "",
+ },
+ },
+
+ RoleRefs: RoleRef{
+ Kind: "Role",
+ Name: strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "-role"}, ""),
+ ApiGroup: "",
+ },
+ }
+
+ rBData, err := yaml.Marshal(&roleBinding)
+ if err != nil {
+ return "", err
+ }
+
+
+ return string(rBData), nil
+
+}
+
+func createQuota(quota []Quota, namespace string) (string, error) {
+ lcQuota := quota[0]
+
+ q := Resource{
+ ApiVersion: "v1",
+ Kind: "ResourceQuota",
+ MetaData: MetaDatas{
+ Name: lcQuota.MetaData.QuotaName,
+ Namespace: namespace,
+ },
+ Specification: Specs{
+ Hard: lcQuota.Specification,
+ },
+ }
+
+ qData, err := yaml.Marshal(&q)
+ if err != nil {
+ return "", err
+ }
+
+
+
+ return string(qData), nil
+
+}
+
+func createUserCSR(logicalcloud LogicalCloud) (string, error) {
+ KEYSIZE := 4096
+ userName := logicalcloud.Specification.User.UserName
+
+ key, err := rsa.GenerateKey(rand.Reader, KEYSIZE)
+ if err != nil {
+ return "", err
+ }
+
+ csrTemplate := x509.CertificateRequest{Subject: pkix.Name{CommonName: userName,},
+ }
+
+ csrCert, err := x509.CreateCertificateRequest(rand.Reader, &csrTemplate, key)
+ if err != nil {
+ return "", err
+ }
+
+ //Encode csr
+ csr := pem.EncodeToMemory(&pem.Block{
+ Type: "CERTIFICATE REQUEST",
+ Bytes: csrCert,
+ })
+
+ csrObj := Resource{
+ ApiVersion: "certificates.k8s.io/v1beta1",
+ Kind: "CertificateSigningRequest",
+ MetaData: MetaDatas{
+ Name: strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "-user-csr"}, ""),
+ Namespace: logicalcloud.Specification.NameSpace,
+ },
+ Specification: Specs{
+ Request: base64.StdEncoding.EncodeToString(csr),
+ Usages: []string{"digital signature", "key encipherment"},
+ },
+ }
+
+ csrData, err := yaml.Marshal(&csrObj)
+ if err != nil {
+ return "", err
+ }
+
+
+ return string(csrData), nil
+
+
+}
+
+// TODO:
+// Install istio
+// Store user key for user creation
+// Code to run kubectl commands for user
+// kubectl certificate approve lc1-user-cert
+// kubectl get csr lc1-user-cert -o jsonpath='{.status.certificate}' | base64 --decode > user.crt
+// kubectl config set-credentials user --client-certificate=<user.crt> --client-key=<user.key>
+// kubectl config set-context user-context --cluster=cluster-name --namespace=lc1 --user=user
+
+
+func CreateEtcdContext(logicalcloud LogicalCloud, clusterList []Cluster,
+ quotaList []Quota ) error {
+
+ APP := "logical-cloud"
+ logicalCloudName := logicalcloud.MetaData.LogicalCloudName
+
+
+ //Resource Names
+ namespaceName := strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "+namespace"}, "")
+ roleName := strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "+role"}, "")
+ roleBindingName := strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "+roleBinding"}, "")
+ quotaName := strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "+quota"}, "")
+ csrName := strings.Join([]string{logicalcloud.MetaData.LogicalCloudName, "+CertificateSigningRequest"}, "")
+
+ // Get resources to be added
+ namespace, err := createNamespace(logicalcloud)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error Creating Namespace YAML for logical cloud")
+ }
+
+ role, err := createRole(logicalcloud)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error Creating Role YAML for logical cloud")
+ }
+
+ roleBinding, err := createRoleBinding(logicalcloud)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error Creating RoleBinding YAML for logical cloud")
+ }
+
+ quota, err := createQuota(quotaList, logicalcloud.Specification.NameSpace)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error Creating Quota YAML for logical cloud")
+ }
+
+ csr, err := createUserCSR(logicalcloud)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error Creating User CSR for logical cloud")
+ }
+
+
+ context := appcontext.AppContext{}
+ ctxVal, err := context.InitAppContext()
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating AppContext")
+ }
+
+ fmt.Printf("%v\n", ctxVal)
+
+ handle, err := context.CreateCompositeApp()
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating AppContext CompositeApp")
+ }
+
+
+ appHandle, err := context.AddApp(handle, APP)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext CompositeApp create failure", log.Fields{
+ "logical-cloud": logicalCloudName,
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding App to AppContext")
+ }
+
+
+ // Iterate through cluster list and add all the clusters
+ for _, cluster:= range clusterList {
+ clusterName := strings.Join([]string{cluster.Specification.ClusterProvider, "+", cluster.Specification.ClusterName, }, "")
+ clusterHandle, err := context.AddCluster(appHandle, clusterName)
+
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add cluster failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding Cluster to AppContext")
+ }
+
+ // Add namespace resource to each cluster
+ _, err = context.AddResource(clusterHandle, namespaceName, namespace)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add namespace resource failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding Namespace Resource to AppContext")
+ }
+
+ // Add csr resource to each cluster
+ _, err = context.AddResource(clusterHandle, csrName, csr)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add CSR resource failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding CSR Resource to AppContext")
+ }
+
+
+
+ // Add Role resource to each cluster
+ _, err = context.AddResource(clusterHandle, roleName, role)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add role resource failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding role Resource to AppContext")
+ }
+
+ // Add RoleBinding resource to each cluster
+ _, err = context.AddResource(clusterHandle, roleBindingName, roleBinding)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add roleBinding resource failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding roleBinding Resource to AppContext")
+ }
+
+ // Add quota resource to each cluster
+ _, err = context.AddResource(clusterHandle, quotaName, quota)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add quota resource failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding quota Resource to AppContext")
+ }
+
+ // Add Resource Order and Resource Dependency
+ resOrder, err := json.Marshal(map[string][]string{"resorder" : []string{namespaceName, quotaName, csrName, roleName, roleBindingName}})
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating resource order JSON")
+ }
+
+ resDependency, err := json.Marshal(map[string]map[string]string{"resdependency" : map[string]string{namespaceName : "go",
+ quotaName : strings.Join([]string{"wait on ", namespaceName}, ""), csrName: strings.Join([]string{"wait on ", quotaName}, ""),
+ roleName : strings.Join([]string{"wait on ", csrName}, ""), roleBindingName: strings.Join([]string{"wait on ", roleName}, ""),}})
+
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating resource dependency JSON")
+ }
+
+ _, err = context.AddInstruction(clusterHandle, "resource", "order", string(resOrder))
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add instruction failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding instruction order to AppContext")
+ }
+
+ _, err = context.AddInstruction(clusterHandle, "resource", "dependency", string(resDependency))
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add instruction failure", log.Fields{
+ "cluster-provider": cluster.Specification.ClusterProvider,
+ "cluster": cluster.Specification.ClusterName,
+ "logical-cloud": logicalCloudName,
+
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding instruction dependency to AppContext")
+ }
+
+
+
+ }
+
+ return nil
+
+
+}
diff --git a/src/dcm/pkg/module/cluster.go b/src/dcm/pkg/module/cluster.go
new file mode 100644
index 00000000..38848990
--- /dev/null
+++ b/src/dcm/pkg/module/cluster.go
@@ -0,0 +1,205 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ pkgerrors "github.com/pkg/errors"
+)
+
+// Cluster contains the parameters needed for a Cluster
+type Cluster struct {
+ MetaData ClusterMeta `json:"metadata"`
+ Specification ClusterSpec `json:"spec"`
+}
+
+type ClusterMeta struct {
+ ClusterReference string `json:"name"`
+ Description string `json:"description"`
+ UserData1 string `json:"userData1"`
+ UserData2 string `json:"userData2"`
+}
+
+type ClusterSpec struct {
+ ClusterProvider string `json:"cluster-provider"`
+ ClusterName string `json:"cluster-name"`
+ LoadBalancerIP string `json:"loadbalancer-ip"`
+}
+
+
+type ClusterKey struct {
+ Project string `json:"project"`
+ LogicalCloudName string `json:"logical-cloud-name"`
+ ClusterReference string `json:"clname"`
+}
+
+// ClusterManager is an interface that exposes the connection
+// functionality
+type ClusterManager interface {
+ CreateCluster(project, logicalCloud string, c Cluster) (Cluster, error)
+ GetCluster(project, logicalCloud, name string) (Cluster, error)
+ GetAllClusters(project, logicalCloud string) ([]Cluster, error)
+ DeleteCluster(project, logicalCloud, name string) error
+ UpdateCluster(project, logicalCloud, name string, c Cluster) (Cluster, error)
+}
+
+// ClusterClient implements the ClusterManager
+// It will also be used to maintain some localized state
+type ClusterClient struct {
+ storeName string
+ tagMeta string
+ util Utility
+}
+
+// ClusterClient returns an instance of the ClusterClient
+// which implements the ClusterManager
+func NewClusterClient() *ClusterClient {
+ service := DBService{}
+ return &ClusterClient{
+ storeName: "orchestrator",
+ tagMeta: "cluster",
+ util: service,
+ }
+}
+
+// Create entry for the cluster reference resource in the database
+func (v *ClusterClient) CreateCluster(project, logicalCloud string, c Cluster) (Cluster, error) {
+
+ //Construct key consisting of name
+ key := ClusterKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ ClusterReference: c.MetaData.ClusterReference,
+ }
+
+ //Check if project exists
+ err := v.util.CheckProject(project)
+ if err != nil {
+ return Cluster{}, pkgerrors.New("Unable to find the project")
+ }
+ //check if logical cloud exists
+ err = v.util.CheckLogicalCloud(project, logicalCloud)
+ if err != nil {
+ return Cluster{}, pkgerrors.New("Unable to find the logical cloud")
+ }
+ //Check if this Cluster reference already exists
+ _, err = v.GetCluster(project, logicalCloud, c.MetaData.ClusterReference)
+ if err == nil {
+ return Cluster{}, pkgerrors.New("Cluster reference already exists")
+ }
+
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return Cluster{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return c, nil
+}
+
+// Get returns Cluster for corresponding cluster reference
+func (v *ClusterClient) GetCluster(project, logicalCloud, clusterReference string)(Cluster, error) {
+
+ //Construct the composite key to select the entry
+ key := ClusterKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ ClusterReference: clusterReference,
+ }
+
+ value, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return Cluster{}, pkgerrors.Wrap(err, "Get Cluster reference")
+ }
+
+ //value is a byte array
+ if value != nil {
+ cl := Cluster{}
+ err = v.util.DBUnmarshal(value[0], &cl)
+ if err != nil {
+ return Cluster{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ return cl, nil
+ }
+
+ return Cluster{}, pkgerrors.New("Error getting Cluster")
+}
+
+
+// GetAll returns all cluster references in the logical cloud
+func (v *ClusterClient) GetAllClusters(project, logicalCloud string)([]Cluster, error) {
+ //Construct the composite key to select clusters
+ key := ClusterKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ ClusterReference: "",
+ }
+ var resp []Cluster
+ values, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []Cluster{}, pkgerrors.Wrap(err, "Get All Cluster references")
+ }
+
+ for _, value := range values {
+ cl := Cluster{}
+ err = v.util.DBUnmarshal(value, &cl)
+ if err != nil {
+ return []Cluster{}, pkgerrors.Wrap(err, "Unmarshaling values")
+ }
+ resp = append(resp, cl)
+ }
+
+ return resp, nil
+}
+
+// Delete the Cluster reference entry from database
+func (v *ClusterClient) DeleteCluster(project, logicalCloud, clusterReference string) error {
+ //Construct the composite key to select the entry
+ key := ClusterKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ ClusterReference: clusterReference,
+ }
+ err := v.util.DBRemove(v.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete Cluster Reference")
+ }
+ return nil
+}
+
+// Update an entry for the Cluster reference in the database
+func (v *ClusterClient) UpdateCluster(project, logicalCloud, clusterReference string, c Cluster) (Cluster, error) {
+
+ key := ClusterKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ ClusterReference: clusterReference,
+ }
+
+ //Check for name mismatch in cluster reference
+ if c.MetaData.ClusterReference != clusterReference {
+ return Cluster{}, pkgerrors.New("Update Error - Cluster reference mismatch")
+ }
+ //Check if this Cluster reference exists
+ _, err := v.GetCluster(project, logicalCloud, clusterReference)
+ if err != nil {
+ return Cluster{}, pkgerrors.New("Update Error - Cluster reference doesn't exist")
+ }
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return Cluster{}, pkgerrors.Wrap(err, "Updating DB Entry")
+ }
+ return c, nil
+}
diff --git a/src/dcm/pkg/module/cluster_test.go b/src/dcm/pkg/module/cluster_test.go
new file mode 100644
index 00000000..d42935db
--- /dev/null
+++ b/src/dcm/pkg/module/cluster_test.go
@@ -0,0 +1,115 @@
+package module
+
+import (
+ "testing"
+
+ "github.com/pkg/errors"
+
+)
+
+
+func TestCreateCluster(t *testing.T) {
+
+ mData := ClusterMeta{
+ ClusterReference: "test_cluster",
+ }
+
+ cl := Cluster {
+ MetaData: mData,
+ }
+ data1 := [][]byte{}
+
+
+ key := ClusterKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ ClusterReference: "test_cluster",
+ }
+ myMocks := new(mockValues)
+ // just to get an error value
+ err1 := errors.New("math: square root of negative number")
+
+ myMocks.On("CheckProject", "test_project").Return(nil)
+ myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil)
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", cl).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
+
+ clClient := ClusterClient{"test_dcm", "test_meta", myMocks}
+ _, err := clClient.CreateCluster("test_project", "test_asdf", cl)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestGetCluster(t *testing.T) {
+ key := ClusterKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ ClusterReference: "test_cluster",
+ }
+
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ clClient := ClusterClient{"test_dcm", "test_meta", myMocks}
+ _, err := clClient.GetCluster("test_project", "test_asdf", "test_cluster")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestDeleteCluster(t *testing.T) {
+
+ key := ClusterKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ ClusterReference: "test_cluster",
+ }
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBRemove", "test_dcm", key).Return(nil)
+
+ clClient := ClusterClient{"test_dcm", "test_meta", myMocks}
+ err := clClient.DeleteCluster("test_project", "test_asdf", "test_cluster")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+
+}
+
+func TestUpdateCluster(t *testing.T) {
+ key := ClusterKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ ClusterReference: "test_cluster",
+ }
+ mData := ClusterMeta{
+ ClusterReference: "test_cluster",
+ }
+ cl := Cluster{
+ MetaData: mData,
+ }
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", cl).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ clClient := ClusterClient{"test_dcm", "test_meta", myMocks}
+ _, err := clClient.UpdateCluster("test_project", "test_asdf", "test_cluster", cl)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
diff --git a/src/dcm/pkg/module/keyvalue.go b/src/dcm/pkg/module/keyvalue.go
new file mode 100644
index 00000000..4e3e0fab
--- /dev/null
+++ b/src/dcm/pkg/module/keyvalue.go
@@ -0,0 +1,205 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ pkgerrors "github.com/pkg/errors"
+)
+
+// KeyValue contains the parameters needed for a key value
+type KeyValue struct {
+ MetaData KVMetaDataList `json:"metadata"`
+ Specification KVSpec `json:"spec"`
+}
+
+
+// MetaData contains the parameters needed for metadata
+type KVMetaDataList struct {
+ KeyValueName string `json:"name"`
+ Description string `json:"description"`
+ UserData1 string `json:"userData1"`
+ UserData2 string `json:"userData2"`
+}
+
+// Spec contains the parameters needed for spec
+type KVSpec struct {
+ Kv []map[string]interface{} `json:"kv"`
+}
+
+// KeyValueKey is the key structure that is used in the database
+type KeyValueKey struct {
+ Project string `json:"project"`
+ LogicalCloudName string `json:"logical-cloud-name"`
+ KeyValueName string `json:"kvname"`
+}
+
+// KeyValueManager is an interface that exposes the connection
+// functionality
+type KeyValueManager interface {
+ CreateKVPair(project, logicalCloud string, c KeyValue) (KeyValue, error)
+ GetKVPair(project, logicalCloud, name string) (KeyValue, error)
+ GetAllKVPairs(project, logicalCloud string) ([]KeyValue, error)
+ DeleteKVPair(project, logicalCloud, name string) error
+ UpdateKVPair(project, logicalCloud, name string, c KeyValue) (KeyValue, error)
+}
+
+// KeyValueClient implements the KeyValueManager
+// It will also be used to maintain some localized state
+type KeyValueClient struct {
+ storeName string
+ tagMeta string
+ util Utility
+}
+
+// KeyValueClient returns an instance of the KeyValueClient
+// which implements the KeyValueManager
+func NewKeyValueClient() *KeyValueClient {
+ service := DBService{}
+ return &KeyValueClient{
+ storeName: "orchestrator",
+ tagMeta: "keyvalue",
+ util: service,
+ }
+}
+
+// Create entry for the key value resource in the database
+func (v *KeyValueClient) CreateKVPair(project, logicalCloud string, c KeyValue) (KeyValue, error) {
+
+ //Construct key consisting of name
+ key := KeyValueKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ KeyValueName: c.MetaData.KeyValueName,
+ }
+
+ //Check if project exist
+ err := v.util.CheckProject(project)
+ if err != nil {
+ return KeyValue{}, pkgerrors.New("Unable to find the project")
+ }
+ //check if logical cloud exists
+ err = v.util.CheckLogicalCloud(project, logicalCloud)
+ if err != nil {
+ return KeyValue{}, pkgerrors.New("Unable to find the logical cloud")
+ }
+ //Check if this Key Value already exists
+ _, err = v.GetKVPair(project, logicalCloud, c.MetaData.KeyValueName)
+ if err == nil {
+ return KeyValue{}, pkgerrors.New("Key Value already exists")
+ }
+
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return KeyValue{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return c, nil
+}
+
+// Get returns Key Value for correspondin name
+func (v *KeyValueClient) GetKVPair(project, logicalCloud, kvPairName string) (KeyValue, error) {
+
+ //Construct the composite key to select the entry
+ key := KeyValueKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ KeyValueName: kvPairName,
+ }
+ value, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return KeyValue{}, pkgerrors.Wrap(err, "Get Key Value")
+ }
+
+ //value is a byte array
+ if value != nil {
+ kv := KeyValue{}
+ err = v.util.DBUnmarshal(value[0], &kv)
+ if err != nil {
+ return KeyValue{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ return kv, nil
+ }
+
+ return KeyValue{}, pkgerrors.New("Error getting Key Value")
+}
+
+// Get All lists all key value pairs
+func (v *KeyValueClient) GetAllKVPairs(project, logicalCloud string) ([]KeyValue, error) {
+
+ //Construct the composite key to select the entry
+ key := KeyValueKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ KeyValueName: "",
+ }
+ var resp []KeyValue
+ values, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []KeyValue{}, pkgerrors.Wrap(err, "Get Key Value")
+ }
+
+ for _, value := range values {
+ kv := KeyValue{}
+ err = v.util.DBUnmarshal(value, &kv)
+ if err != nil {
+ return []KeyValue{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ resp = append(resp, kv)
+ }
+
+ return resp, nil
+}
+
+// Delete the Key Value entry from database
+func (v *KeyValueClient) DeleteKVPair(project, logicalCloud, kvPairName string) error {
+
+ //Construct the composite key to select the entry
+ key := KeyValueKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ KeyValueName: kvPairName,
+ }
+ err := v.util.DBRemove(v.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete Key Value")
+ }
+ return nil
+}
+
+// Update an entry for the Key Value in the database
+func (v *KeyValueClient) UpdateKVPair(project, logicalCloud, kvPairName string, c KeyValue) (KeyValue, error) {
+
+ key := KeyValueKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ KeyValueName: kvPairName,
+ }
+ //Check if KV pair URl name is the same name in json
+ if c.MetaData.KeyValueName != kvPairName {
+ return KeyValue{}, pkgerrors.New("Update Error - KV pair name mismatch")
+ }
+ //Check if this Key Value exists
+ _, err := v.GetKVPair(project, logicalCloud, kvPairName)
+ if err != nil {
+ return KeyValue{}, pkgerrors.New("Update Error - Key Value Pair doesn't exist")
+ }
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return KeyValue{}, pkgerrors.Wrap(err, "Updating DB Entry")
+ }
+ return c, nil
+}
diff --git a/src/dcm/pkg/module/keyvalue_test.go b/src/dcm/pkg/module/keyvalue_test.go
new file mode 100644
index 00000000..9faceda4
--- /dev/null
+++ b/src/dcm/pkg/module/keyvalue_test.go
@@ -0,0 +1,115 @@
+package module
+
+import (
+ "testing"
+
+ "github.com/pkg/errors"
+
+)
+
+
+func TestCreateKVPair(t *testing.T) {
+
+ mData := KVMetaDataList{
+ KeyValueName: "test_kv_pair",
+ }
+
+ kv := KeyValue {
+ MetaData: mData,
+ }
+ data1 := [][]byte{}
+
+
+ key := KeyValueKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ KeyValueName: "test_kv_pair",
+ }
+ myMocks := new(mockValues)
+ // just to get an error value
+ err1 := errors.New("math: square root of negative number")
+
+ myMocks.On("CheckProject", "test_project").Return(nil)
+ myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil)
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", kv).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
+
+ kvClient := KeyValueClient{"test_dcm", "test_meta", myMocks}
+ _, err := kvClient.CreateKVPair("test_project", "test_asdf", kv)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestGetKVPair(t *testing.T) {
+ key := KeyValueKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ KeyValueName: "test_kv_pair",
+ }
+
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ kvClient := KeyValueClient{"test_dcm", "test_meta", myMocks}
+ _, err := kvClient.GetKVPair("test_project", "test_asdf", "test_kv_pair")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestDeleteKVPair(t *testing.T) {
+
+ key := KeyValueKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ KeyValueName: "test_kv_pair",
+ }
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBRemove", "test_dcm", key).Return(nil)
+
+ kvClient := KeyValueClient{"test_dcm", "test_meta", myMocks}
+ err := kvClient.DeleteKVPair("test_project", "test_asdf", "test_kv_pair")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+
+}
+
+func TestUpdateKVPair(t *testing.T) {
+ key := KeyValueKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ KeyValueName: "test_kv_pair",
+ }
+ mData := KVMetaDataList{
+ KeyValueName: "test_kv_pair",
+ }
+ kv := KeyValue{
+ MetaData: mData,
+ }
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", kv).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ kvClient := KeyValueClient{"test_dcm", "test_meta", myMocks}
+ _, err := kvClient.UpdateKVPair("test_project", "test_asdf", "test_kv_pair", kv)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
diff --git a/src/dcm/pkg/module/logicalcloud.go b/src/dcm/pkg/module/logicalcloud.go
new file mode 100644
index 00000000..9fb1b6fb
--- /dev/null
+++ b/src/dcm/pkg/module/logicalcloud.go
@@ -0,0 +1,291 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+// LogicalCloud contains the parameters needed for a Logical Cloud
+type LogicalCloud struct {
+ MetaData MetaDataList `json:"metadata"`
+ Specification Spec `json:"spec"`
+}
+
+
+// MetaData contains the parameters needed for metadata
+type MetaDataList struct {
+ LogicalCloudName string `json:"name"`
+ Description string `json:"description"`
+ UserData1 string `json:"userData1"`
+ UserData2 string `json:"userData2"`
+}
+
+// Spec contains the parameters needed for spec
+type Spec struct {
+ NameSpace string `json:"namespace"`
+ User UserData `json:"user"`
+
+}
+
+// UserData contains the parameters needed for user
+type UserData struct {
+ UserName string `json:"user-name"`
+ Type string `json:"type"`
+ UserPermissions []UserPerm `json:"user-permissions"`
+}
+
+// UserPerm contains the parameters needed for user permissions
+type UserPerm struct {
+ PermName string `json:"permission-name"`
+ APIGroups []string `json:"apiGroups"`
+ Resources []string `json:"resources"`
+ Verbs []string `json:"verbs"`
+}
+
+// LogicalCloudKey is the key structure that is used in the database
+type LogicalCloudKey struct {
+ Project string `json:"project"`
+ LogicalCloudName string `json:"logical-cloud-name"`
+}
+
+// LogicalCloudManager is an interface that exposes the connection
+// functionality
+type LogicalCloudManager interface {
+ Create(project string, c LogicalCloud) (LogicalCloud, error)
+ Get(project, name string) (LogicalCloud, error)
+ GetAll(project string) ([]LogicalCloud, error)
+ Delete(project, name string) error
+ Update(project, name string, c LogicalCloud) (LogicalCloud, error)
+
+}
+
+// Interface facilitates unit testing by mocking functions
+type Utility interface {
+ DBInsert(storeName string, key db.Key, query interface{}, meta string, c interface{}) error
+ DBFind(storeName string, key db.Key, meta string) ([][]byte, error)
+ DBUnmarshal(value []byte, out interface{}) error
+ DBRemove(storeName string, key db.Key) error
+ CheckProject(project string) error
+ CheckLogicalCloud(project, logicalCloud string) error
+}
+
+// LogicalCloudClient implements the LogicalCloudManager
+// It will also be used to maintain some localized state
+type LogicalCloudClient struct {
+ storeName string
+ tagMeta string
+ util Utility
+}
+
+// Added for unit testing; implements Utility interface
+type DBService struct {}
+
+// LogicalCloudClient returns an instance of the LogicalCloudClient
+// which implements the LogicalCloudManager
+func NewLogicalCloudClient() *LogicalCloudClient {
+ service := DBService{}
+ return &LogicalCloudClient{
+ storeName: "orchestrator",
+ tagMeta: "logicalcloud",
+ util: service,
+ }
+}
+
+// Create entry for the logical cloud resource in the database
+func (v *LogicalCloudClient) Create(project string, c LogicalCloud) (LogicalCloud, error) {
+
+ //Construct key consisting of name
+ key := LogicalCloudKey{
+ Project: project,
+ LogicalCloudName: c.MetaData.LogicalCloudName,
+ }
+
+ //Check if project exists
+ err := v.util.CheckProject(project)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.New("Unable to find the project")
+ }
+
+ //Check if this Logical Cloud already exists
+ _, err = v.Get(project, c.MetaData.LogicalCloudName)
+ if err == nil {
+ return LogicalCloud{}, pkgerrors.New("Logical Cloud already exists")
+ }
+
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return c, nil
+}
+
+// Get returns Logical Cloud corresponding to logical cloud name
+func (v *LogicalCloudClient) Get(project, logicalCloudName string) (LogicalCloud, error) {
+
+ //Construct the composite key to select the entry
+ key := LogicalCloudKey{
+ Project: project,
+ LogicalCloudName: logicalCloudName,
+ }
+ value, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.Wrap(err, "Get Logical Cloud")
+ }
+
+ //value is a byte array
+ if value != nil {
+ lc := LogicalCloud{}
+ err = v.util.DBUnmarshal(value[0], &lc)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ return lc, nil
+ }
+
+ return LogicalCloud{}, pkgerrors.New("Error getting Logical Cloud")
+}
+
+// GetAll returns Logical Clouds in the project
+func (v *LogicalCloudClient) GetAll(project string) ([]LogicalCloud, error) {
+
+ //Construct the composite key to select the entry
+ key := LogicalCloudKey{
+ Project: project,
+ LogicalCloudName: "",
+ }
+
+ var resp []LogicalCloud
+ values, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []LogicalCloud{}, pkgerrors.Wrap(err, "Get Logical Clouds")
+ }
+
+ for _, value := range values {
+ lc := LogicalCloud{}
+ err = v.util.DBUnmarshal(value, &lc)
+ if err != nil {
+ return []LogicalCloud{}, pkgerrors.Wrap(err, "Unmarshaling values")
+ }
+ resp = append(resp, lc)
+ }
+
+ return resp, nil
+}
+
+// Delete the Logical Cloud entry from database
+func (v *LogicalCloudClient) Delete(project, logicalCloudName string) error {
+
+ //Construct the composite key to select the entry
+ key := LogicalCloudKey{
+ Project: project,
+ LogicalCloudName: logicalCloudName,
+ }
+ err := v.util.DBRemove(v.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete Logical Cloud")
+ }
+
+ return nil
+}
+
+// Update an entry for the Logical Cloud in the database
+func (v *LogicalCloudClient) Update(project, logicalCloudName string, c LogicalCloud) (LogicalCloud, error) {
+
+ key := LogicalCloudKey{
+ Project: project,
+ LogicalCloudName: logicalCloudName,
+ }
+ // Check for mismatch, logicalCloudName and payload logical cloud name
+ if c.MetaData.LogicalCloudName != logicalCloudName {
+ return LogicalCloud{}, pkgerrors.New("Update Error - Logical Cloud name mismatch")
+ }
+ //Check if this Logical Cloud exists
+ _, err := v.Get(project, logicalCloudName)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.New("Update Error - Logical Cloud doesn't exist")
+ }
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return LogicalCloud{}, pkgerrors.Wrap(err, "Updating DB Entry")
+ }
+ return c, nil
+}
+
+func (d DBService) DBInsert(storeName string, key db.Key, query interface{}, meta string, c interface{}) error {
+
+ err := db.DBconn.Insert(storeName, key, nil, meta, c)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return nil
+}
+
+func (d DBService) DBFind(storeName string, key db.Key, meta string) ([][]byte, error) {
+
+ value, err := db.DBconn.Find(storeName, key, meta)
+ if err != nil {
+ return [][]byte{}, pkgerrors.Wrap(err, "Get Resource")
+ }
+
+ return value, nil
+}
+
+func (d DBService) DBUnmarshal(value []byte, out interface{}) error {
+
+ err := db.DBconn.Unmarshal(value, out)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Unmarshaling Value")
+ }
+
+ return nil
+}
+
+func (d DBService) DBRemove(storeName string, key db.Key) error {
+
+ err := db.DBconn.Remove(storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete Resource")
+ }
+
+ return nil
+}
+
+func (d DBService) CheckProject(project string) error {
+ // Check if project exists
+ _, err := module.NewProjectClient().GetProject(project)
+ if err != nil {
+ return pkgerrors.New("Unable to find the project")
+ }
+
+ return nil
+}
+
+func (d DBService) CheckLogicalCloud(project, logicalCloud string) error {
+ // Check if logical cloud exists
+ _, err := NewLogicalCloudClient().Get(project, logicalCloud)
+ if err != nil {
+ return pkgerrors.New("Unable to find the logical cloud")
+ }
+
+ return nil
+}
diff --git a/src/dcm/pkg/module/logicalcloud_test.go b/src/dcm/pkg/module/logicalcloud_test.go
new file mode 100644
index 00000000..882cc292
--- /dev/null
+++ b/src/dcm/pkg/module/logicalcloud_test.go
@@ -0,0 +1,157 @@
+package module
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ "github.com/stretchr/testify/mock"
+ "github.com/pkg/errors"
+
+)
+
+type mockValues struct {
+ mock.Mock
+}
+
+func (m *mockValues) DBInsert(name string, key db.Key, query interface {}, meta string, c interface {}) error{
+ fmt.Println("Mocked Insert operation in Mongo")
+ args := m.Called(name, key, nil, meta, c)
+
+ return args.Error(0)
+}
+
+func (m *mockValues) DBFind(name string, key db.Key, meta string) ([][]byte, error) {
+ fmt.Println("Mocked Mongo DB Find Operation")
+ args := m.Called(name, key, meta)
+
+ return args.Get(0).([][]byte), args.Error(1)
+}
+
+func (m *mockValues) DBUnmarshal(value []byte, out interface{}) error {
+ fmt.Println("Mocked Mongo DB Unmarshal Operation")
+ args := m.Called(value)
+
+ return args.Error(0)
+}
+
+func (m *mockValues) DBRemove(name string, key db.Key) error {
+ fmt.Println("Mocked Mongo DB Remove operation")
+ args := m.Called(name, key)
+
+ return args.Error(0)
+}
+
+func (m *mockValues) CheckProject(project string) error {
+ fmt.Println("Mocked Check Project exists")
+ args := m.Called(project)
+
+ return args.Error(0)
+}
+
+func (m *mockValues) CheckLogicalCloud(project, logicalCloud string) error {
+ fmt.Println("Mocked Check Logical Cloud exists")
+ args := m.Called(project, logicalCloud)
+
+ return args.Error(0)
+}
+
+func TestCreateLogicalCloud(t *testing.T) {
+
+ mData := MetaDataList{
+ LogicalCloudName: "test_asdf",
+ }
+
+ lc := LogicalCloud {
+ MetaData: mData,
+ }
+ data1 := [][]byte{}
+
+ key := LogicalCloudKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ }
+ myMocks := new(mockValues)
+ // just to get an error value
+ err1 := errors.New("math: square root of negative number")
+
+ myMocks.On("CheckProject", "test_project").Return(nil)
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", lc).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
+
+ lcClient := LogicalCloudClient{"test_dcm", "test_meta", myMocks}
+ _, err := lcClient.Create("test_project", lc)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestGetLogicalCloud(t *testing.T) {
+ key := LogicalCloudKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ }
+
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ lcClient := LogicalCloudClient{"test_dcm", "test_meta", myMocks}
+ _, err := lcClient.Get("test_project", "test_asdf")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestDeleteLogicalCloud(t *testing.T) {
+
+ key := LogicalCloudKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ }
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBRemove", "test_dcm", key).Return(nil)
+
+ lcClient := LogicalCloudClient{"test_dcm", "test_meta", myMocks}
+ err := lcClient.Delete("test_project", "test_asdf")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+
+}
+
+func TestUpdateLogicalCloud(t *testing.T) {
+ key := LogicalCloudKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ }
+ mData := MetaDataList{
+ LogicalCloudName: "test_asdf",
+ }
+ lc := LogicalCloud{
+ MetaData: mData,
+ }
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", lc).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ lcClient := LogicalCloudClient{"test_dcm", "test_meta", myMocks}
+ _, err := lcClient.Update("test_project", "test_asdf", lc)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
diff --git a/src/dcm/pkg/module/module.go b/src/dcm/pkg/module/module.go
new file mode 100644
index 00000000..293f6dd5
--- /dev/null
+++ b/src/dcm/pkg/module/module.go
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2020 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 module
+
+// Client for using the services in the orchestrator
+type Client struct {
+ LogicalCloud *LogicalCloudClient
+ Cluster *ClusterClient
+ Quota *QuotaClient
+ UserPermission *UserPermissionClient
+ KeyValue *KeyValueClient
+ // Add Clients for API's here
+}
+
+// NewClient creates a new client for using the services
+func NewClient() *Client {
+ c := &Client{}
+ c.LogicalCloud = NewLogicalCloudClient()
+ c.Cluster = NewClusterClient()
+ c.Quota = NewQuotaClient()
+ c.UserPermission = NewUserPermissionClient()
+ c.KeyValue = NewKeyValueClient()
+ // Add Client API handlers here
+ return c
+}
diff --git a/src/dcm/pkg/module/quota.go b/src/dcm/pkg/module/quota.go
new file mode 100644
index 00000000..1a7012f6
--- /dev/null
+++ b/src/dcm/pkg/module/quota.go
@@ -0,0 +1,222 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ pkgerrors "github.com/pkg/errors"
+)
+
+// Quota contains the parameters needed for a Quota
+type Quota struct {
+ MetaData QMetaDataList `json:"metadata"`
+ Specification QSpec `json:"spec"`
+}
+
+
+// MetaData contains the parameters needed for metadata
+type QMetaDataList struct {
+ QuotaName string `json:"name"`
+ Description string `json:"description"`
+}
+
+// Spec contains the parameters needed for spec
+type QSpec struct {
+ LimitsCPU string `json:"limits.cpu"`
+ LimitsMemory string `json:"limits.memory"`
+ RequestsCPU string `json:"requests.cpu"`
+ RequestsMemory string `json:"requests.memory"`
+ RequestsStorage string `json:"requests.storage"`
+ LimitsEphemeralStorage string `json:"limits.ephemeral.storage"`
+ PersistentVolumeClaims string `json:"persistentvolumeclaims"`
+ Pods string `json:"pods"`
+ ConfigMaps string `json:"configmaps"`
+ ReplicationControllers string `json:"replicationcontrollers"`
+ ResourceQuotas string `json:"resourcequotas"`
+ Services string `json:"services"`
+ ServicesLoadBalancers string `json:"services.loadbalancers"`
+ ServicesNodePorts string `json:"services.nodeports"`
+ Secrets string `json:"secrets"`
+ CountReplicationControllers string `json:"count/replicationcontrollers"`
+ CountDeploymentsApps string `json:"count/deployments.apps"`
+ CountReplicasetsApps string `json:"count/replicasets.apps"`
+ CountStatefulSets string `json:"count/statefulsets.apps"`
+ CountJobsBatch string `json:"count/jobs.batch"`
+ CountCronJobsBatch string `json:"count/cronjobs.batch"`
+ CountDeploymentsExtensions string `json:"count/deployments.extensions"`
+}
+
+// QuotaKey is the key structure that is used in the database
+type QuotaKey struct {
+ Project string `json:"project"`
+ LogicalCloudName string `json:"logical-cloud-name"`
+ QuotaName string `json:"qname"`
+}
+
+// QuotaManager is an interface that exposes the connection
+// functionality
+type QuotaManager interface {
+ CreateQuota(project, logicalCloud string, c Quota) (Quota, error)
+ GetQuota(project, logicalCloud, name string) (Quota, error)
+ GetAllQuotas(project, logicalCloud string) ([]Quota, error)
+ DeleteQuota(project, logicalCloud, name string) error
+ UpdateQuota(project, logicalCloud, name string, c Quota) (Quota, error)
+}
+
+// QuotaClient implements the QuotaManager
+// It will also be used to maintain some localized state
+type QuotaClient struct {
+ storeName string
+ tagMeta string
+ util Utility
+}
+
+// QuotaClient returns an instance of the QuotaClient
+// which implements the QuotaManager
+func NewQuotaClient() *QuotaClient {
+ service := DBService{}
+ return &QuotaClient{
+ storeName: "orchestrator",
+ tagMeta: "quota",
+ util: service,
+ }
+}
+
+// Create entry for the quota resource in the database
+func (v *QuotaClient) CreateQuota(project, logicalCloud string, c Quota) (Quota, error) {
+
+ //Construct key consisting of name
+ key := QuotaKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ QuotaName: c.MetaData.QuotaName,
+ }
+
+ //Check if project exists
+ err := v.util.CheckProject(project)
+ if err != nil {
+ return Quota{}, pkgerrors.New("Unable to find the project")
+ }
+ //check if logical cloud exists
+ err = v.util.CheckLogicalCloud(project, logicalCloud)
+ if err != nil {
+ return Quota{}, pkgerrors.New("Unable to find the logical cloud")
+ }
+ //Check if this Quota already exists
+ _, err = v.GetQuota(project, logicalCloud, c.MetaData.QuotaName)
+ if err == nil {
+ return Quota{}, pkgerrors.New("Quota already exists")
+ }
+
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return Quota{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return c, nil
+}
+
+// Get returns Quota for corresponding quota name
+func (v *QuotaClient) GetQuota(project, logicalCloud, quotaName string) (Quota, error) {
+
+ //Construct the composite key to select the entry
+ key := QuotaKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ QuotaName: quotaName,
+ }
+ value, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return Quota{}, pkgerrors.Wrap(err, "Quota")
+ }
+
+ //value is a byte array
+ if value != nil {
+ q := Quota{}
+ err = v.util.DBUnmarshal(value[0], &q)
+ if err != nil {
+ return Quota{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ return q, nil
+ }
+
+ return Quota{}, pkgerrors.New("Error getting Quota")
+}
+
+// GetAll returns all cluster quotas in the logical cloud
+func (v *QuotaClient) GetAllQuotas(project, logicalCloud string) ([]Quota, error) {
+ //Construct the composite key to select the entry
+ key := QuotaKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ QuotaName: "",
+ }
+ var resp []Quota
+ values, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []Quota{}, pkgerrors.Wrap(err, "Get All Quotas")
+ }
+
+ for _, value := range values {
+ q := Quota{}
+ err = v.util.DBUnmarshal(value, &q)
+ if err != nil {
+ return []Quota{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ resp = append(resp, q)
+ }
+
+ return resp, nil
+}
+
+// Delete the Quota entry from database
+func (v *QuotaClient) DeleteQuota(project, logicalCloud, quotaName string) error {
+ //Construct the composite key to select the entry
+ key := QuotaKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ QuotaName: quotaName,
+ }
+ err := v.util.DBRemove(v.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete Quota")
+ }
+ return nil
+}
+
+// Update an entry for the Quota in the database
+func (v *QuotaClient) UpdateQuota(project, logicalCloud, quotaName string, c Quota) (Quota, error) {
+
+ key := QuotaKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ QuotaName: quotaName,
+ }
+ //Check quota URL name against the quota json name
+ if c.MetaData.QuotaName != quotaName {
+ return Quota{}, pkgerrors.New("Update Error - Quota name mismatch")
+ }
+ //Check if this Quota exists
+ _, err := v.GetQuota(project, logicalCloud, quotaName)
+ if err != nil {
+ return Quota{}, pkgerrors.New("Update Error - Quota doesn't exist")
+ }
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return Quota{}, pkgerrors.Wrap(err, "Updating DB Entry")
+ }
+ return c, nil
+}
diff --git a/src/dcm/pkg/module/quota_test.go b/src/dcm/pkg/module/quota_test.go
new file mode 100644
index 00000000..87a60d71
--- /dev/null
+++ b/src/dcm/pkg/module/quota_test.go
@@ -0,0 +1,115 @@
+package module
+
+import (
+ "testing"
+
+ "github.com/pkg/errors"
+
+)
+
+
+func TestCreateQuota(t *testing.T) {
+
+ mData := QMetaDataList{
+ QuotaName: "test_quota",
+ }
+
+ q := Quota {
+ MetaData: mData,
+ }
+ data1 := [][]byte{}
+
+
+ key := QuotaKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ QuotaName: "test_quota",
+ }
+ myMocks := new(mockValues)
+ // just to get an error value
+ err1 := errors.New("math: square root of negative number")
+
+ myMocks.On("CheckProject", "test_project").Return(nil)
+ myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil)
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
+
+ qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
+ _, err := qClient.CreateQuota("test_project", "test_asdf", q)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestGetQuota(t *testing.T) {
+ key := QuotaKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ QuotaName: "test_quota",
+ }
+
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
+ _, err := qClient.GetQuota("test_project", "test_asdf", "test_quota")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestDeleteQuota(t *testing.T) {
+
+ key := QuotaKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ QuotaName: "test_quota",
+ }
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBRemove", "test_dcm", key).Return(nil)
+
+ qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
+ err := qClient.DeleteQuota("test_project", "test_asdf", "test_quota")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+
+}
+
+func TestUpdateQuota(t *testing.T) {
+ key := QuotaKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ QuotaName: "test_quota",
+ }
+ mData := QMetaDataList{
+ QuotaName: "test_quota",
+ }
+ q := Quota{
+ MetaData: mData,
+ }
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", q).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ qClient := QuotaClient{"test_dcm", "test_meta", myMocks}
+ _, err := qClient.UpdateQuota("test_project", "test_asdf", "test_quota", q)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
diff --git a/src/dcm/pkg/module/userpermissions.go b/src/dcm/pkg/module/userpermissions.go
new file mode 100644
index 00000000..cf961a65
--- /dev/null
+++ b/src/dcm/pkg/module/userpermissions.go
@@ -0,0 +1,193 @@
+/*
+* Copyright 2020 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 module
+
+import (
+ pkgerrors "github.com/pkg/errors"
+)
+
+// UserPermission contains the parameters needed for a user permission
+type UserPermission struct {
+ UserPermissionName string `json:"name"`
+ APIGroups []string `json:"apiGroups"`
+ Resources []string `json:"resources"`
+ Verbs []string `json:"verbs"`
+}
+
+// UserPermissionKey is the key structure that is used in the database
+type UserPermissionKey struct {
+ Project string `json:"project"`
+ LogicalCloudName string `json:"logical-cloud-name"`
+ UserPermissionName string `json:"upname"`
+}
+
+// UserPermissionManager is an interface that exposes the connection
+// functionality
+type UserPermissionManager interface {
+ CreateUserPerm(project, logicalCloud string, c UserPermission) (UserPermission, error)
+ GetUserPerm(project, logicalCloud, name string) (UserPermission, error)
+ GetAllUserPerms(project, logicalCloud string) ([]UserPermission, error)
+ DeleteUserPerm(project, logicalCloud, name string) error
+ UpdateUserPerm(project, logicalCloud, name string, c UserPermission) (UserPermission, error)
+}
+
+// UserPermissionClient implements the UserPermissionManager
+// It will also be used to maintain some localized state
+type UserPermissionClient struct {
+ storeName string
+ tagMeta string
+ util Utility
+}
+
+// UserPermissionClient returns an instance of the UserPermissionClient
+// which implements the UserPermissionManager
+func NewUserPermissionClient() *UserPermissionClient {
+ service := DBService{}
+ return &UserPermissionClient{
+ storeName: "orchestrator",
+ tagMeta: "userpermission",
+ util: service,
+ }
+}
+
+// Create entry for the User Permission resource in the database
+func (v *UserPermissionClient) CreateUserPerm(project, logicalCloud string, c UserPermission) (UserPermission, error) {
+
+ //Construct key consisting of name
+ key := UserPermissionKey {
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ UserPermissionName: c.UserPermissionName,
+ }
+
+ //Check if project exists
+ err := v.util.CheckProject(project)
+ if err != nil {
+ return UserPermission{}, pkgerrors.New("Unable to find the project")
+ }
+ //check if logical cloud exists
+ err = v.util.CheckLogicalCloud(project, logicalCloud)
+ if err != nil {
+ return UserPermission{}, pkgerrors.New("Unable to find the logical cloud")
+ }
+
+ //Check if this User Permission already exists
+ _, err = v.GetUserPerm(project, logicalCloud, c.UserPermissionName)
+ if err == nil {
+ return UserPermission{}, pkgerrors.New("User Permission already exists")
+ }
+
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return UserPermission{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return c, nil
+}
+
+// Get returns User Permission for corresponding name
+func (v *UserPermissionClient) GetUserPerm(project, logicalCloud, userPermName string) (UserPermission, error) {
+
+ //Construct the composite key to select the entry
+ key := UserPermissionKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ UserPermissionName: userPermName,
+ }
+
+ value, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return UserPermission{}, pkgerrors.Wrap(err, "Get User Permission")
+ }
+
+ //value is a byte array
+ if value != nil {
+ up := UserPermission{}
+ err = v.util.DBUnmarshal(value[0], &up)
+ if err != nil {
+ return UserPermission{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ return up, nil
+ }
+
+ return UserPermission{}, pkgerrors.New("Error getting User Permission")
+}
+
+// GetAll lists all user permissions
+func (v *UserPermissionClient) GetAllUserPerms(project, logicalCloud string) ([]UserPermission, error) {
+ //Construct the composite key to select the entry
+ key := UserPermissionKey {
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ UserPermissionName: "",
+ }
+ var resp []UserPermission
+ values, err := v.util.DBFind(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []UserPermission{}, pkgerrors.Wrap(err, "Get All User Permissions")
+ }
+
+ for _, value := range values {
+ up := UserPermission{}
+ err = v.util.DBUnmarshal(value, &up)
+ if err != nil {
+ return []UserPermission{}, pkgerrors.Wrap(err, "Unmarshaling value")
+ }
+ resp = append(resp, up)
+ }
+ return resp, nil
+}
+// Delete the User Permission entry from database
+func (v *UserPermissionClient) DeleteUserPerm(project, logicalCloud, userPermName string) error {
+ //Construct the composite key to select the entry
+ key := UserPermissionKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ UserPermissionName: userPermName,
+ }
+ err := v.util.DBRemove(v.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete User Permission")
+ }
+ return nil
+}
+
+// Update an entry for the User Permission in the database
+func (v *UserPermissionClient) UpdateUserPerm(project, logicalCloud, userPermName string, c UserPermission) (
+ UserPermission, error) {
+
+ key := UserPermissionKey{
+ Project: project,
+ LogicalCloudName: logicalCloud,
+ UserPermissionName: userPermName,
+ }
+ //Check for URL name and json permission name mismatch
+ if c.UserPermissionName != userPermName {
+ return UserPermission{}, pkgerrors.New("Update Error - Permission name mismatch")
+ }
+ //Check if this User Permission exists
+ _, err := v.GetUserPerm(project, logicalCloud, userPermName)
+ if err != nil {
+ return UserPermission{}, pkgerrors.New(
+ "Update Error - User Permission doesn't exist")
+ }
+ err = v.util.DBInsert(v.storeName, key, nil, v.tagMeta, c)
+ if err != nil {
+ return UserPermission{}, pkgerrors.Wrap(err, "Updating DB Entry")
+ }
+ return c, nil
+}
diff --git a/src/dcm/pkg/module/userpermissions_test.go b/src/dcm/pkg/module/userpermissions_test.go
new file mode 100644
index 00000000..f134aa0f
--- /dev/null
+++ b/src/dcm/pkg/module/userpermissions_test.go
@@ -0,0 +1,110 @@
+package module
+
+import (
+ "testing"
+
+ "github.com/pkg/errors"
+
+)
+
+
+func TestCreateUserPerm(t *testing.T) {
+
+ up := UserPermission {
+ UserPermissionName: "test_user_perm",
+ }
+ data1 := [][]byte{}
+
+ // data2 := []byte("abc")
+
+ key := UserPermissionKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ UserPermissionName: "test_user_perm",
+ }
+ myMocks := new(mockValues)
+ // just to get an error value
+ err1 := errors.New("math: square root of negative number")
+
+ myMocks.On("CheckProject", "test_project").Return(nil)
+ myMocks.On("CheckLogicalCloud", "test_project", "test_asdf").Return(nil)
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", up).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, err1)
+ // myMocks.On("DBUnmarshal", data2).Return(nil)
+
+ upClient := UserPermissionClient{"test_dcm", "test_meta", myMocks}
+ _, err := upClient.CreateUserPerm("test_project", "test_asdf", up)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestGetUserPerm(t *testing.T) {
+ key := UserPermissionKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ UserPermissionName: "test_user_perm",
+ }
+
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ upClient := UserPermissionClient{"test_dcm", "test_meta", myMocks}
+ _, err := upClient.GetUserPerm("test_project", "test_asdf", "test_user_perm")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
+
+func TestDeleteUserPerm(t *testing.T) {
+
+ key := UserPermissionKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ UserPermissionName: "test_user_perm",
+ }
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBRemove", "test_dcm", key).Return(nil)
+
+ upClient := UserPermissionClient{"test_dcm", "test_meta", myMocks}
+ err := upClient.DeleteUserPerm("test_project", "test_asdf", "test_user_perm")
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+
+}
+
+func TestUpdateUserPerm(t *testing.T) {
+ key := UserPermissionKey{
+ Project: "test_project",
+ LogicalCloudName: "test_asdf",
+ UserPermissionName: "test_user_perm",
+ }
+ up := UserPermission{
+ UserPermissionName: "test_user_perm",
+ }
+ data1 := [][]byte{
+ []byte("abc"),
+ }
+ data2 := []byte("abc")
+
+ myMocks := new(mockValues)
+
+ myMocks.On("DBInsert", "test_dcm", key, nil, "test_meta", up).Return(nil)
+ myMocks.On("DBFind", "test_dcm", key, "test_meta").Return(data1, nil)
+ myMocks.On("DBUnmarshal", data2).Return(nil)
+ upClient := UserPermissionClient{"test_dcm", "test_meta", myMocks}
+ _, err := upClient.UpdateUserPerm("test_project", "test_asdf", "test_user_perm", up)
+ if err != nil {
+ t.Errorf("Some error occured!")
+ }
+}
diff --git a/src/dcm/test/dcm_call_api.sh b/src/dcm/test/dcm_call_api.sh
new file mode 100755
index 00000000..3bf27524
--- /dev/null
+++ b/src/dcm/test/dcm_call_api.sh
@@ -0,0 +1,147 @@
+# /*
+# * Copyright 2020 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.
+# */
+
+
+project="test-project"
+description="test-description"
+logical_cloud_name="lc1"
+logical_cloud_url="http://localhost:9015/v2/projects/${project}/logical-clouds"
+quota_name="quota-1"
+quota_url="${logical_cloud_url}/${logical_cloud_name}/cluster-quotas"
+cluster_url="${logical_cloud_url}/${logical_cloud_name}/cluster-references"
+
+
+logical_cloud_data="$(cat << EOF
+{
+ "metadata" : {
+ "name": "${logical_cloud_name}",
+ "description": "${test-description}",
+ "userData1":"<user data>",
+ "userData2":"<user data>"
+ },
+ "spec" : {
+ "namespace" : "ns-1",
+ "user" : {
+ "user-name" : "user-1",
+ "type" : "certificate",
+ "user-permissions" : [
+ { "permission-name" : "permission-1",
+ "apiGroups" : ["stable.example.com"],
+ "resources" : ["secrets", "pods"],
+ "verbs" : ["get", "watch", "list", "create"]
+ }
+ ]
+ }
+ }
+}
+EOF
+)"
+
+cluster_1_data="$(cat << EOF
+{
+ "metadata" : {
+ "name": "lc-cl-1",
+ "description": "${test-description}",
+ "userData1":"<user data>",
+ "userData2":"<user data>"
+ },
+
+ "spec" : {
+ "cluster-provider": "cp-1",
+ "cluster-name": "c1",
+ "loadbalancer-ip" : "0.0.0.0"
+ }
+}
+EOF
+)"
+
+cluster_2_data="$(cat << EOF
+{
+ "metadata" : {
+ "name": "lc-cl-2",
+ "description": "${test-description}",
+ "userData1":"<user data>",
+ "userData2":"<user data>"
+ },
+
+ "spec" : {
+ "cluster-provider": "cp-1",
+ "cluster-name": "c2",
+ "loadbalancer-ip" : "0.0.0.1"
+ }
+}
+EOF
+)"
+
+quota_data="$(cat << EOF
+{
+ "metadata" : {
+ "name" : "${quota_name}",
+ "description": "${test-description}"
+ },
+ "spec" : {
+ "limits.cpu": "400",
+ "limits.memory": "1000Gi",
+ "requests.cpu": "300",
+ "requests.memory": "900Gi",
+ "requests.storage" : "500Gi",
+ "requests.ephemeral-storage": "",
+ "limits.ephemeral-storage": "",
+ "persistentvolumeclaims" : " ",
+ "pods": "500",
+ "configmaps" : "",
+ "replicationcontrollers": "",
+ "resourcequotas" : "",
+ "services": "",
+ "services.loadbalancers" : "",
+ "services.nodeports" : "",
+ "secrets" : "",
+ "count/replicationcontrollers" : "",
+ "count/deployments.apps" : "",
+ "count/replicasets.apps" : "",
+ "count/statefulsets.apps" : "",
+ "count/jobs.batch" : "",
+ "count/cronjobs.batch" : "",
+ "count/deployments.extensions" : ""
+ }
+}
+EOF
+)"
+
+
+# Create logical cloud
+printf "\n\nCreating logical cloud data\n\n"
+curl -d "${logical_cloud_data}" -X POST ${logical_cloud_url}
+
+# Associate two clusters with the logical cloud
+printf "\n\nAdding two clusters to logical cloud\n\n"
+curl -d "${cluster_1_data}" -X POST ${cluster_url}
+curl -d "${cluster_2_data}" -X POST ${cluster_url}
+
+# Add resource quota for the logical cloud
+printf "\n\nAdding resource quota for the logical cloud\n\n"
+curl -d "${quota_data}" -X POST ${quota_url}
+
+
+# Get logical cloud data
+printf "\n\nGetting logical cloud\n\n"
+curl -X GET "${logical_cloud_url}/${logical_cloud_name}"
+
+printf "\n\nGetting clusters info for logical cloud\n\n"
+curl -X GET ${cluster_url}
+
+printf "\n\nGetting Quota info for the logical cloud\n\n"
+curl -X GET "${quota_url}/${quota_name}" \ No newline at end of file
diff --git a/src/k8splugin/api/api.go b/src/k8splugin/api/api.go
index c836fc65..ff2270ac 100644
--- a/src/k8splugin/api/api.go
+++ b/src/k8splugin/api/api.go
@@ -54,10 +54,11 @@ func NewRouter(defClient rb.DefinitionManager,
//Setup the broker handler here
//Use the base router without any path prefixes
brokerHandler := brokerInstanceHandler{client: instClient}
- router.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload", brokerHandler.createHandler).Methods("POST")
- router.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload/{instID}", brokerHandler.getHandler).Methods("GET")
- router.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload", brokerHandler.findHandler).Queries("name", "{name}").Methods("GET")
- router.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload/{instID}", brokerHandler.deleteHandler).Methods("DELETE")
+ brokerRouter := router.PathPrefix("/v1").Subrouter()
+ brokerRouter.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload", brokerHandler.createHandler).Methods("POST")
+ brokerRouter.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload/{instID}", brokerHandler.getHandler).Methods("GET")
+ brokerRouter.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload", brokerHandler.findHandler).Queries("name", "{name}").Methods("GET")
+ brokerRouter.HandleFunc("/{cloud-owner}/{cloud-region}/infra_workload/{instID}", brokerHandler.deleteHandler).Methods("DELETE")
//Setup the connectivity api handler here
if connectionClient == nil {
diff --git a/src/k8splugin/api/brokerhandler_test.go b/src/k8splugin/api/brokerhandler_test.go
index c822f6d1..12774eb8 100644
--- a/src/k8splugin/api/brokerhandler_test.go
+++ b/src/k8splugin/api/brokerhandler_test.go
@@ -312,7 +312,7 @@ func TestBrokerCreateHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
- request := httptest.NewRequest("POST", "/cloudowner/cloudregion/infra_workload", testCase.input)
+ request := httptest.NewRequest("POST", "/v1/cloudowner/cloudregion/infra_workload", testCase.input)
resp := executeRequest(request, NewRouter(nil, nil, testCase.instClient, nil, nil, nil))
defer resp.Body.Close()
@@ -408,7 +408,7 @@ func TestBrokerGetHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
- request := httptest.NewRequest("GET", "/cloudowner/cloudregion/infra_workload/"+testCase.input, nil)
+ request := httptest.NewRequest("GET", "/v1/cloudowner/cloudregion/infra_workload/"+testCase.input, nil)
resp := executeRequest(request, NewRouter(nil, nil, testCase.instClient, nil, nil, nil))
if testCase.expectedCode != resp.StatusCode {
@@ -488,7 +488,7 @@ func TestBrokerFindHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
- request := httptest.NewRequest("GET", "/cloudowner/cloudregion/infra_workload?name="+testCase.input, nil)
+ request := httptest.NewRequest("GET", "/v1/cloudowner/cloudregion/infra_workload?name="+testCase.input, nil)
resp := executeRequest(request, NewRouter(nil, nil, testCase.instClient, nil, nil, nil))
if testCase.expectedCode != resp.StatusCode {
@@ -550,7 +550,7 @@ func TestBrokerDeleteHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
- request := httptest.NewRequest("DELETE", "/cloudowner/cloudregion/infra_workload/"+testCase.input, nil)
+ request := httptest.NewRequest("DELETE", "/v1/cloudowner/cloudregion/infra_workload/"+testCase.input, nil)
resp := executeRequest(request, NewRouter(nil, nil, testCase.instClient, nil, nil, nil))
if testCase.expectedCode != resp.StatusCode {
diff --git a/src/ncm/api/api.go b/src/ncm/api/api.go
index 34b46c67..2b105716 100644
--- a/src/ncm/api/api.go
+++ b/src/ncm/api/api.go
@@ -51,6 +51,27 @@ func setClient(client, testClient interface{}) interface{} {
return c
}
}
+ case *moduleLib.NetControlIntentClient:
+ if testClient != nil && reflect.TypeOf(testClient).Implements(reflect.TypeOf((*moduleLib.NetControlIntentManager)(nil)).Elem()) {
+ c, ok := testClient.(moduleLib.NetControlIntentManager)
+ if ok {
+ return c
+ }
+ }
+ case *moduleLib.WorkloadIntentClient:
+ if testClient != nil && reflect.TypeOf(testClient).Implements(reflect.TypeOf((*moduleLib.WorkloadIntentManager)(nil)).Elem()) {
+ c, ok := testClient.(moduleLib.WorkloadIntentManager)
+ if ok {
+ return c
+ }
+ }
+ case *moduleLib.WorkloadIfIntentClient:
+ if testClient != nil && reflect.TypeOf(testClient).Implements(reflect.TypeOf((*moduleLib.WorkloadIfIntentManager)(nil)).Elem()) {
+ c, ok := testClient.(moduleLib.WorkloadIfIntentManager)
+ if ok {
+ return c
+ }
+ }
default:
fmt.Printf("unknown type %T\n", cl)
}
@@ -74,8 +95,11 @@ func NewRouter(testClient interface{}) *mux.Router {
router.HandleFunc("/cluster-providers/{name}", clusterHandler.deleteClusterProviderHandler).Methods("DELETE")
router.HandleFunc("/cluster-providers/{provider-name}/clusters", clusterHandler.createClusterHandler).Methods("POST")
router.HandleFunc("/cluster-providers/{provider-name}/clusters", clusterHandler.getClusterHandler).Methods("GET")
+ router.HandleFunc("/cluster-providers/{provider-name}/clusters", clusterHandler.getClusterHandler).Queries("label", "{label}")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{name}", clusterHandler.getClusterHandler).Methods("GET")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{name}", clusterHandler.deleteClusterHandler).Methods("DELETE")
+ router.HandleFunc("/cluster-providers/{provider-name}/clusters/{name}/apply", clusterHandler.applyClusterHandler).Methods("POST")
+ router.HandleFunc("/cluster-providers/{provider-name}/clusters/{name}/terminate", clusterHandler.terminateClusterHandler).Methods("POST")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{cluster-name}/labels", clusterHandler.createClusterLabelHandler).Methods("POST")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{cluster-name}/labels", clusterHandler.getClusterLabelHandler).Methods("GET")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{cluster-name}/labels/{label}", clusterHandler.getClusterLabelHandler).Methods("GET")
@@ -103,5 +127,33 @@ func NewRouter(testClient interface{}) *mux.Router {
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{cluster-name}/provider-networks/{name}", providernetHandler.getProviderNetHandler).Methods("GET")
router.HandleFunc("/cluster-providers/{provider-name}/clusters/{cluster-name}/provider-networks/{name}", providernetHandler.deleteProviderNetHandler).Methods("DELETE")
+ netcontrolintentHandler := netcontrolintentHandler{
+ client: setClient(moduleClient.NetControlIntent, testClient).(moduleLib.NetControlIntentManager),
+ }
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent", netcontrolintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}", netcontrolintentHandler.deleteHandler).Methods("DELETE")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{name}/apply", netcontrolintentHandler.applyHandler).Methods("POST")
+
+ workloadintentHandler := workloadintentHandler{
+ client: setClient(moduleClient.WorkloadIntent, testClient).(moduleLib.WorkloadIntentManager),
+ }
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents", workloadintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{name}", workloadintentHandler.deleteHandler).Methods("DELETE")
+
+ workloadifintentHandler := workloadifintentHandler{
+ client: setClient(moduleClient.WorkloadIfIntent, testClient).(moduleLib.WorkloadIfIntentManager),
+ }
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.createHandler).Methods("POST")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces", workloadifintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.putHandler).Methods("PUT")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.getHandler).Methods("GET")
+ router.HandleFunc("/projects/{project}/composite-apps/{composite-app-name}/{version}/network-controller-intent/{net-control-intent}/workload-intents/{workload-intent}/interfaces/{name}", workloadifintentHandler.deleteHandler).Methods("DELETE")
+
return router
}
diff --git a/src/ncm/api/clusterhandler.go b/src/ncm/api/clusterhandler.go
index cb147a8a..78453aa8 100644
--- a/src/ncm/api/clusterhandler.go
+++ b/src/ncm/api/clusterhandler.go
@@ -194,6 +194,23 @@ func (h clusterHandler) getClusterHandler(w http.ResponseWriter, r *http.Request
provider := vars["provider-name"]
name := vars["name"]
+ label := r.URL.Query().Get("label")
+ if len(label) != 0 {
+ ret, err := h.client.GetClustersWithLabel(provider, label)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ return
+ }
+
// handle the get all clusters case - return a list of only the json parts
if len(name) == 0 {
var retList []moduleLib.Cluster
@@ -307,6 +324,36 @@ func (h clusterHandler) deleteClusterHandler(w http.ResponseWriter, r *http.Requ
w.WriteHeader(http.StatusNoContent)
}
+// apply network intents associated with the cluster
+func (h clusterHandler) applyClusterHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ provider := vars["provider-name"]
+ name := vars["name"]
+
+ err := h.client.ApplyNetworkIntents(provider, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
+
+// terminate network intents associated with the cluster
+func (h clusterHandler) terminateClusterHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ provider := vars["provider-name"]
+ name := vars["name"]
+
+ err := h.client.TerminateNetworkIntents(provider, name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
+
// Create handles creation of the ClusterLabel entry in the database
func (h clusterHandler) createClusterLabelHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
diff --git a/src/ncm/api/clusterhandler_test.go b/src/ncm/api/clusterhandler_test.go
index af5bd160..b32df527 100644
--- a/src/ncm/api/clusterhandler_test.go
+++ b/src/ncm/api/clusterhandler_test.go
@@ -28,6 +28,7 @@ import (
"testing"
moduleLib "github.com/onap/multicloud-k8s/src/ncm/pkg/module"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
pkgerrors "github.com/pkg/errors"
)
@@ -41,8 +42,10 @@ type mockClusterManager struct {
ClusterProviderItems []moduleLib.ClusterProvider
ClusterItems []moduleLib.Cluster
ClusterContentItems []moduleLib.ClusterContent
+ ClusterContextItems []appcontext.AppContext
ClusterLabelItems []moduleLib.ClusterLabel
ClusterKvPairsItems []moduleLib.ClusterKvPairs
+ ClusterList []string
Err error
}
@@ -98,6 +101,14 @@ func (m *mockClusterManager) GetClusterContent(provider, name string) (moduleLib
return m.ClusterContentItems[0], nil
}
+func (m *mockClusterManager) GetClusterContext(provider, name string) (appcontext.AppContext, error) {
+ if m.Err != nil {
+ return appcontext.AppContext{}, m.Err
+ }
+
+ return m.ClusterContextItems[0], nil
+}
+
func (m *mockClusterManager) GetClusters(provider string) ([]moduleLib.Cluster, error) {
if m.Err != nil {
return []moduleLib.Cluster{}, m.Err
@@ -106,10 +117,26 @@ func (m *mockClusterManager) GetClusters(provider string) ([]moduleLib.Cluster,
return m.ClusterItems, nil
}
+func (m *mockClusterManager) GetClustersWithLabel(provider, label string) ([]string, error) {
+ if m.Err != nil {
+ return []string{}, m.Err
+ }
+
+ return m.ClusterList, nil
+}
+
func (m *mockClusterManager) DeleteCluster(provider, name string) error {
return m.Err
}
+func (m *mockClusterManager) ApplyNetworkIntents(provider, name string) error {
+ return m.Err
+}
+
+func (m *mockClusterManager) TerminateNetworkIntents(provider, name string) error {
+ return m.Err
+}
+
func (m *mockClusterManager) CreateClusterLabel(provider, cluster string, inp moduleLib.ClusterLabel) (moduleLib.ClusterLabel, error) {
if m.Err != nil {
return moduleLib.ClusterLabel{}, m.Err
diff --git a/src/ncm/api/netcontrolintenthandler.go b/src/ncm/api/netcontrolintenthandler.go
new file mode 100644
index 00000000..48ef1de2
--- /dev/null
+++ b/src/ncm/api/netcontrolintenthandler.go
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+
+ moduleLib "github.com/onap/multicloud-k8s/src/ncm/pkg/module"
+ pkgerrors "github.com/pkg/errors"
+
+ "github.com/gorilla/mux"
+)
+
+// Used to store backend implementations objects
+// Also simplifies mocking for unit testing purposes
+type netcontrolintentHandler struct {
+ // Interface that implements Cluster operations
+ // We will set this variable with a mock interface for testing
+ client moduleLib.NetControlIntentManager
+}
+
+// Check for valid format of input parameters
+func validateNetControlIntentInputs(nci moduleLib.NetControlIntent) error {
+ // validate metadata
+ err := moduleLib.IsValidMetadata(nci.Metadata)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Invalid network controller intent metadata")
+ }
+ return nil
+}
+
+// Create handles creation of the NetControlIntent entry in the database
+func (h netcontrolintentHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ var nci moduleLib.NetControlIntent
+ vars := mux.Vars(r)
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+
+ err := json.NewDecoder(r.Body).Decode(&nci)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if nci.Metadata.Name == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ err = validateNetControlIntentInputs(nci)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, false)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Put handles creation/update of the NetControlIntent entry in the database
+func (h netcontrolintentHandler) putHandler(w http.ResponseWriter, r *http.Request) {
+ var nci moduleLib.NetControlIntent
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+
+ err := json.NewDecoder(r.Body).Decode(&nci)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if nci.Metadata.Name == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ // Name in URL should match name in body
+ if nci.Metadata.Name != name {
+ fmt.Printf("bodyname = %v, name= %v\n", nci.Metadata.Name, name)
+ http.Error(w, "Mismatched name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ err = validateNetControlIntentInputs(nci)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateNetControlIntent(nci, project, compositeApp, compositeAppVersion, true)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Get handles GET operations on a particular NetControlIntent Name
+// Returns a NetControlIntent
+func (h netcontrolintentHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetNetControlIntents(project, compositeApp, compositeAppVersion)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetNetControlIntent(name, project, compositeApp, compositeAppVersion)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Delete handles DELETE operations on a particular NetControlIntent Name
+func (h netcontrolintentHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+
+ err := h.client.DeleteNetControlIntent(name, project, compositeApp, compositeAppVersion)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
+
+// Apply handles POST operations to Apply a particular NetControlIntent to the App Context
+func (h netcontrolintentHandler) applyHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+
+ var aci struct {
+ AppContextId string `json:"appContextId"`
+ }
+
+ err := json.NewDecoder(r.Body).Decode(&aci)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ err = h.client.ApplyNetControlIntent(name, project, compositeApp, compositeAppVersion, aci.AppContextId)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/ncm/api/workloadifintenthandler.go b/src/ncm/api/workloadifintenthandler.go
new file mode 100644
index 00000000..31472a5d
--- /dev/null
+++ b/src/ncm/api/workloadifintenthandler.go
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+
+ moduleLib "github.com/onap/multicloud-k8s/src/ncm/pkg/module"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ pkgerrors "github.com/pkg/errors"
+
+ "github.com/gorilla/mux"
+)
+
+// Used to store backend implementations objects
+// Also simplifies mocking for unit testing purposes
+type workloadifintentHandler struct {
+ // Interface that implements workload intent operations
+ // We will set this variable with a mock interface for testing
+ client moduleLib.WorkloadIfIntentManager
+}
+
+// Check for valid format of input parameters
+func validateWorkloadIfIntentInputs(wif moduleLib.WorkloadIfIntent) error {
+ // validate metadata
+ err := moduleLib.IsValidMetadata(wif.Metadata)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Invalid network controller intent metadata")
+ }
+
+ errs := validation.IsValidName(wif.Spec.IfName)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid interface name = [%v], errors: %v", wif.Spec.IfName, errs)
+ }
+
+ errs = validation.IsValidName(wif.Spec.NetworkName)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid network name = [%v], errors: %v", wif.Spec.NetworkName, errs)
+ }
+
+ // optional - only validate if supplied
+ if len(wif.Spec.DefaultGateway) > 0 {
+ errs = validation.IsValidName(wif.Spec.DefaultGateway)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid default interface = [%v], errors: %v", wif.Spec.DefaultGateway, errs)
+ }
+ }
+
+ // optional - only validate if supplied
+ if len(wif.Spec.IpAddr) > 0 {
+ err = validation.IsIp(wif.Spec.IpAddr)
+ if err != nil {
+ return pkgerrors.Errorf("Invalid IP address = [%v], errors: %v", wif.Spec.IpAddr, err)
+ }
+ }
+
+ // optional - only validate if supplied
+ if len(wif.Spec.MacAddr) > 0 {
+ err = validation.IsMac(wif.Spec.MacAddr)
+ if err != nil {
+ return pkgerrors.Errorf("Invalid MAC address = [%v], errors: %v", wif.Spec.MacAddr, err)
+ }
+ }
+ return nil
+}
+
+// Create handles creation of the Network entry in the database
+func (h workloadifintentHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ var wif moduleLib.WorkloadIfIntent
+ vars := mux.Vars(r)
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+ workloadIntent := vars["workload-intent"]
+
+ err := json.NewDecoder(r.Body).Decode(&wif)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if wif.Metadata.Name == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ // set default value
+ if len(wif.Spec.DefaultGateway) == 0 {
+ wif.Spec.DefaultGateway = "false" // set default value
+ }
+
+ err = validateWorkloadIfIntentInputs(wif)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, false)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Put handles creation/update of the Network entry in the database
+func (h workloadifintentHandler) putHandler(w http.ResponseWriter, r *http.Request) {
+ var wif moduleLib.WorkloadIfIntent
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+ workloadIntent := vars["workload-intent"]
+
+ err := json.NewDecoder(r.Body).Decode(&wif)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if wif.Metadata.Name == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ // Name in URL should match name in body
+ if wif.Metadata.Name != name {
+ fmt.Printf("bodyname = %v, name= %v\n", wif.Metadata.Name, name)
+ http.Error(w, "Mismatched name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ // set default value
+ if len(wif.Spec.DefaultGateway) == 0 {
+ wif.Spec.DefaultGateway = "false" // set default value
+ }
+
+ err = validateWorkloadIfIntentInputs(wif)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateWorkloadIfIntent(wif, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent, true)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Get handles GET operations on a particular Network Name
+// Returns a Network
+func (h workloadifintentHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+ workloadIntent := vars["workload-intent"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetWorkloadIfIntents(project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Delete handles DELETE operations on a particular Network Name
+func (h workloadifintentHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+ workloadIntent := vars["workload-intent"]
+
+ err := h.client.DeleteWorkloadIfIntent(name, project, compositeApp, compositeAppVersion, netControlIntent, workloadIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/ncm/api/workloadintenthandler.go b/src/ncm/api/workloadintenthandler.go
new file mode 100644
index 00000000..f1d0093d
--- /dev/null
+++ b/src/ncm/api/workloadintenthandler.go
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2020 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 api
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "net/http"
+
+ moduleLib "github.com/onap/multicloud-k8s/src/ncm/pkg/module"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ pkgerrors "github.com/pkg/errors"
+
+ "github.com/gorilla/mux"
+)
+
+// Used to store backend implementations objects
+// Also simplifies mocking for unit testing purposes
+type workloadintentHandler struct {
+ // Interface that implements workload intent operations
+ // We will set this variable with a mock interface for testing
+ client moduleLib.WorkloadIntentManager
+}
+
+// Check for valid format of input parameters
+func validateWorkloadIntentInputs(wi moduleLib.WorkloadIntent) error {
+ // validate metadata
+ err := moduleLib.IsValidMetadata(wi.Metadata)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Invalid network controller intent metadata")
+ }
+
+ errs := validation.IsValidName(wi.Spec.AppName)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid application name = [%v], errors: %v", wi.Spec.AppName, errs)
+ }
+
+ errs = validation.IsValidName(wi.Spec.WorkloadResource)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid workload resource = [%v], errors: %v", wi.Spec.WorkloadResource, errs)
+ }
+
+ errs = validation.IsValidName(wi.Spec.Type)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid workload type = [%v], errors: %v", wi.Spec.Type, errs)
+ }
+ return nil
+}
+
+// Create handles creation of the Network entry in the database
+func (h workloadintentHandler) createHandler(w http.ResponseWriter, r *http.Request) {
+ var wi moduleLib.WorkloadIntent
+ vars := mux.Vars(r)
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+
+ err := json.NewDecoder(r.Body).Decode(&wi)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if wi.Metadata.Name == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ err = validateWorkloadIntentInputs(wi)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, false)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Put handles creation/update of the Network entry in the database
+func (h workloadintentHandler) putHandler(w http.ResponseWriter, r *http.Request) {
+ var wi moduleLib.WorkloadIntent
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+
+ err := json.NewDecoder(r.Body).Decode(&wi)
+
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if wi.Metadata.Name == "" {
+ http.Error(w, "Missing name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ // Name in URL should match name in body
+ if wi.Metadata.Name != name {
+ fmt.Printf("bodyname = %v, name= %v\n", wi.Metadata.Name, name)
+ http.Error(w, "Mismatched name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ err = validateWorkloadIntentInputs(wi)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateWorkloadIntent(wi, project, compositeApp, compositeAppVersion, netControlIntent, true)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Get handles GET operations on a particular Network Name
+// Returns a Network
+func (h workloadintentHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+ var ret interface{}
+ var err error
+
+ if len(name) == 0 {
+ ret, err = h.client.GetWorkloadIntents(project, compositeApp, compositeAppVersion, netControlIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+ ret, err = h.client.GetWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Delete handles DELETE operations on a particular Network Name
+func (h workloadintentHandler) deleteHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["name"]
+ project := vars["project"]
+ compositeApp := vars["composite-app-name"]
+ compositeAppVersion := vars["version"]
+ netControlIntent := vars["net-control-intent"]
+
+ err := h.client.DeleteWorkloadIntent(name, project, compositeApp, compositeAppVersion, netControlIntent)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.WriteHeader(http.StatusNoContent)
+}
diff --git a/src/ncm/go.mod b/src/ncm/go.mod
index 32ff481a..8b45298f 100644
--- a/src/ncm/go.mod
+++ b/src/ncm/go.mod
@@ -1,21 +1,26 @@
module github.com/onap/multicloud-k8s/src/ncm
require (
- github.com/coreos/etcd v3.3.12+incompatible
- github.com/docker/engine v0.0.0-20190620014054-c513a4c6c298
+ github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/ghodss/yaml v1.0.0
+ github.com/google/gofuzz v1.1.0 // indirect
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
- github.com/hashicorp/consul v1.4.0
+ github.com/json-iterator/go v1.1.9 // indirect
+ github.com/k8snetworkplumbingwg/network-attachment-definition-client v0.0.0-20200127152046-0ee521d56061
github.com/pkg/errors v0.8.1
github.com/sirupsen/logrus v1.4.2
go.etcd.io/etcd v3.3.12+incompatible
go.mongodb.org/mongo-driver v1.0.0
- golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
+ golang.org/x/net v0.0.0-20190930134127-c5a3c61f89f3
+ gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.0.0-20190831074750-7364b6bdad65
k8s.io/apimachinery v0.0.0-20190831074630-461753078381
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
- k8s.io/helm v2.14.3+incompatible
+ k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
+ k8s.io/kubernetes v1.14.1
+ k8s.io/utils v0.0.0-20200414100711-2df71ebbae66 // indirect
+ sigs.k8s.io/yaml v1.2.0 // indirect
)
replace (
diff --git a/src/ncm/pkg/module/cluster.go b/src/ncm/pkg/module/cluster.go
index e3260b7e..2397a091 100644
--- a/src/ncm/pkg/module/cluster.go
+++ b/src/ncm/pkg/module/cluster.go
@@ -17,7 +17,10 @@
package module
import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ "gopkg.in/yaml.v2"
pkgerrors "github.com/pkg/errors"
)
@@ -66,6 +69,12 @@ type ClusterLabelKey struct {
ClusterLabelName string `json:"label"`
}
+// LabelKey is the key structure that is used in the database
+type LabelKey struct {
+ ClusterProviderName string `json:"provider"`
+ ClusterLabelName string `json:"label"`
+}
+
// ClusterKvPairsKey is the key structure that is used in the database
type ClusterKvPairsKey struct {
ClusterProviderName string `json:"provider"`
@@ -73,7 +82,11 @@ type ClusterKvPairsKey struct {
ClusterKvPairsName string `json:"kvname"`
}
-// Manager is an interface exposes the Cluster functionality
+const SEPARATOR = "+"
+const CONTEXT_CLUSTER_APP = "network-intents"
+const CONTEXT_CLUSTER_RESOURCE = "network-intents"
+
+// ClusterManager is an interface exposes the Cluster functionality
type ClusterManager interface {
CreateClusterProvider(pr ClusterProvider) (ClusterProvider, error)
GetClusterProvider(name string) (ClusterProvider, error)
@@ -82,8 +95,12 @@ type ClusterManager interface {
CreateCluster(provider string, pr Cluster, qr ClusterContent) (Cluster, error)
GetCluster(provider, name string) (Cluster, error)
GetClusterContent(provider, name string) (ClusterContent, error)
+ GetClusterContext(provider, name string) (appcontext.AppContext, error)
GetClusters(provider string) ([]Cluster, error)
+ GetClustersWithLabel(provider, label string) ([]string, error)
DeleteCluster(provider, name string) error
+ ApplyNetworkIntents(provider, name string) error
+ TerminateNetworkIntents(provider, name string) error
CreateClusterLabel(provider, cluster string, pr ClusterLabel) (ClusterLabel, error)
GetClusterLabel(provider, cluster, label string) (ClusterLabel, error)
GetClusterLabels(provider, cluster string) ([]ClusterLabel, error)
@@ -108,6 +125,7 @@ func NewClusterClient() *ClusterClient {
storeName: "cluster",
tagMeta: "clustermetadata",
tagContent: "clustercontent",
+ tagContext: "clustercontext",
},
}
}
@@ -287,6 +305,33 @@ func (v *ClusterClient) GetClusterContent(provider, name string) (ClusterContent
return ClusterContent{}, pkgerrors.New("Error getting Cluster Content")
}
+// GetClusterContext returns the AppContext for corresponding provider and name
+func (v *ClusterClient) GetClusterContext(provider, name string) (appcontext.AppContext, error) {
+ //Construct key and tag to select the entry
+ key := ClusterKey{
+ ClusterProviderName: provider,
+ ClusterName: name,
+ }
+
+ value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagContext)
+ if err != nil {
+ return appcontext.AppContext{}, pkgerrors.Wrap(err, "Get Cluster Context")
+ }
+
+ //value is a byte array
+ if value != nil {
+ ctxVal := string(value[0])
+ var cc appcontext.AppContext
+ _, err = cc.LoadAppContext(ctxVal)
+ if err != nil {
+ return appcontext.AppContext{}, pkgerrors.Wrap(err, "Reinitializing Cluster AppContext")
+ }
+ return cc, nil
+ }
+
+ return appcontext.AppContext{}, pkgerrors.New("Error getting Cluster AppContext")
+}
+
// GetClusters returns all the Clusters for corresponding provider
func (v *ClusterClient) GetClusters(provider string) ([]Cluster, error) {
//Construct key and tag to select the entry
@@ -314,6 +359,29 @@ func (v *ClusterClient) GetClusters(provider string) ([]Cluster, error) {
return resp, nil
}
+// GetClustersWithLabel returns all the Clusters with Labels for provider
+// Support Query like /cluster-providers/{Provider}/clusters?label={label}
+func (v *ClusterClient) GetClustersWithLabel(provider, label string) ([]string, error) {
+ //Construct key and tag to select the entry
+ key := LabelKey{
+ ClusterProviderName: provider,
+ ClusterLabelName: label,
+ }
+
+ values, err := db.DBconn.Find(v.db.storeName, key, "cluster")
+ if err != nil {
+ return []string{}, pkgerrors.Wrap(err, "Get Clusters by label")
+ }
+ var resp []string
+
+ for _, value := range values {
+ cp := string(value)
+ resp = append(resp, cp)
+ }
+
+ return resp, nil
+}
+
// DeleteCluster the Cluster from database
func (v *ClusterClient) DeleteCluster(provider, name string) error {
//Construct key and tag to select the entry
@@ -321,8 +389,12 @@ func (v *ClusterClient) DeleteCluster(provider, name string) error {
ClusterProviderName: provider,
ClusterName: name,
}
+ _, err := v.GetClusterContext(provider, name)
+ if err == nil {
+ return pkgerrors.Errorf("Cannot delete cluster until context is deleted: %v, %v", provider, name)
+ }
- err := db.DBconn.Remove(v.db.storeName, key)
+ err = db.DBconn.Remove(v.db.storeName, key)
if err != nil {
return pkgerrors.Wrap(err, "Delete Cluster Entry;")
}
@@ -330,6 +402,185 @@ func (v *ClusterClient) DeleteCluster(provider, name string) error {
return nil
}
+// Apply Network Intents associated with a cluster
+func (v *ClusterClient) ApplyNetworkIntents(provider, name string) error {
+
+ _, err := v.GetClusterContext(provider, name)
+ if err == nil {
+ return pkgerrors.Errorf("Cluster network intents have already been applied: %v, %v", provider, name)
+ }
+
+ type resource struct {
+ name string
+ value string
+ }
+
+ var resources []resource
+
+ // Find all Network Intents for this cluster
+ networkIntents, err := NewNetworkClient().GetNetworks(provider, name)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error finding Network Intents")
+ }
+ for _, intent := range networkIntents {
+ var crNetwork = CrNetwork{
+ ApiVersion: NETWORK_APIVERSION,
+ Kind: NETWORK_KIND,
+ }
+ crNetwork.Network = intent
+ // Produce the yaml CR document for each intent
+ y, err := yaml.Marshal(&crNetwork)
+ if err != nil {
+ log.Info("Error marshalling network intent to yaml", log.Fields{
+ "error": err,
+ "intent": intent,
+ })
+ continue
+ }
+ resources = append(resources, resource{
+ name: intent.Metadata.Name + SEPARATOR + NETWORK_KIND,
+ value: string(y),
+ })
+ }
+
+ // Find all Provider Network Intents for this cluster
+ providerNetworkIntents, err := NewProviderNetClient().GetProviderNets(provider, name)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error finding Provider Network Intents")
+ }
+ for _, intent := range providerNetworkIntents {
+ var crProviderNet = CrProviderNet{
+ ApiVersion: PROVIDER_NETWORK_APIVERSION,
+ Kind: PROVIDER_NETWORK_KIND,
+ }
+ crProviderNet.ProviderNet = intent
+ // Produce the yaml CR document for each intent
+ y, err := yaml.Marshal(&crProviderNet)
+ if err != nil {
+ log.Info("Error marshalling provider network intent to yaml", log.Fields{
+ "error": err,
+ "intent": intent,
+ })
+ continue
+ }
+ resources = append(resources, resource{
+ name: intent.Metadata.Name + SEPARATOR + PROVIDER_NETWORK_KIND,
+ value: string(y),
+ })
+ }
+
+ if len(resources) == 0 {
+ return nil
+ }
+
+ // Make an app context for the network intent resources
+ context := appcontext.AppContext{}
+ ctxVal, err := context.InitAppContext()
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating AppContext")
+ }
+ handle, err := context.CreateCompositeApp()
+ if err != nil {
+ return pkgerrors.Wrap(err, "Error creating AppContext CompositeApp")
+ }
+
+ // Add an app (fixed value) to the app context
+ apphandle, err := context.AddApp(handle, CONTEXT_CLUSTER_APP)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext CompositeApp create failure", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding App to AppContext")
+ }
+
+ // Add a cluster to the app
+ clusterhandle, err := context.AddCluster(apphandle, provider+SEPARATOR+name)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add cluster failure", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding Cluster to AppContext")
+ }
+
+ // add the resources to the app context
+ for _, resource := range resources {
+ _, err = context.AddResource(clusterhandle, resource.name, resource.value)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after add resource failure", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ "resource": resource.name,
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding Resource to AppContext")
+ }
+ }
+
+ // save the context in the cluster db record
+ key := ClusterKey{
+ ClusterProviderName: provider,
+ ClusterName: name,
+ }
+ err = db.DBconn.Insert(v.db.storeName, key, nil, v.db.tagContext, ctxVal)
+ if err != nil {
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error cleaning AppContext after DB insert failure", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ })
+ }
+ return pkgerrors.Wrap(err, "Error adding AppContext to DB")
+ }
+
+ // TODO: call resource synchronizer to instantiate the CRs in the cluster
+
+ return nil
+}
+
+// Terminate Network Intents associated with a cluster
+func (v *ClusterClient) TerminateNetworkIntents(provider, name string) error {
+ context, err := v.GetClusterContext(provider, name)
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error finding AppContext for cluster: %v, %v", provider, name)
+ }
+
+ // TODO: call resource synchronizer to terminate the CRs in the cluster
+
+ // remove the app context
+ cleanuperr := context.DeleteCompositeApp()
+ if cleanuperr != nil {
+ log.Warn("Error deleted AppContext", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ })
+ }
+
+ // remove the app context field from the cluster db record
+ key := ClusterKey{
+ ClusterProviderName: provider,
+ ClusterName: name,
+ }
+ err = db.DBconn.RemoveTag(v.db.storeName, key, v.db.tagContext)
+ if err != nil {
+ log.Warn("Error removing AppContext from Cluster document", log.Fields{
+ "cluster-provider": provider,
+ "cluster": name,
+ })
+ }
+ return nil
+}
+
// CreateClusterLabel - create a new Cluster Label mongo document for a cluster-provider/cluster
func (v *ClusterClient) CreateClusterLabel(provider string, cluster string, p ClusterLabel) (ClusterLabel, error) {
//Construct key and tag to select the entry
diff --git a/src/ncm/pkg/module/module.go b/src/ncm/pkg/module/module.go
index a9950901..9655c1de 100644
--- a/src/ncm/pkg/module/module.go
+++ b/src/ncm/pkg/module/module.go
@@ -16,11 +16,14 @@
package module
-// Client for using the services in the orchestrator
+// Client for using the services in the ncm
type Client struct {
- Cluster *ClusterClient
- Network *NetworkClient
- ProviderNet *ProviderNetClient
+ Cluster *ClusterClient
+ Network *NetworkClient
+ ProviderNet *ProviderNetClient
+ NetControlIntent *NetControlIntentClient
+ WorkloadIntent *WorkloadIntentClient
+ WorkloadIfIntent *WorkloadIfIntentClient
// Add Clients for API's here
}
@@ -30,6 +33,9 @@ func NewClient() *Client {
c.Cluster = NewClusterClient()
c.Network = NewNetworkClient()
c.ProviderNet = NewProviderNetClient()
+ c.NetControlIntent = NewNetControlIntentClient()
+ c.WorkloadIntent = NewWorkloadIntentClient()
+ c.WorkloadIfIntent = NewWorkloadIfIntentClient()
// Add Client API handlers here
return c
}
diff --git a/src/ncm/pkg/module/module_definitions.go b/src/ncm/pkg/module/module_definitions.go
index 1e839014..36c865a5 100644
--- a/src/ncm/pkg/module/module_definitions.go
+++ b/src/ncm/pkg/module/module_definitions.go
@@ -31,25 +31,32 @@ const CNI_TYPE_OVN4NFV string = "ovn4nfv"
var CNI_TYPES = [...]string{CNI_TYPE_OVN4NFV}
+const YAML_START = "---\n"
+const YAML_END = "...\n"
+
// It implements the interface for managing the ClusterProviders
+const MAX_DESCRIPTION_LEN int = 1024
+const MAX_USERDATA_LEN int = 4096
+
type Metadata struct {
- Name string `json:"name"`
- Description string `json:"description"`
- UserData1 string `json:"userData1"`
- UserData2 string `json:"userData2"`
+ Name string `json:"name" yaml:"name"`
+ Description string `json:"description" yaml:"-"`
+ UserData1 string `json:"userData1" yaml:"-"`
+ UserData2 string `json:"userData2" yaml:"-"`
}
type ClientDbInfo struct {
storeName string // name of the mongodb collection to use for client documents
tagMeta string // attribute key name for the json data of a client document
tagContent string // attribute key name for the file data of a client document
+ tagContext string // attribute key name for context object in App Context
}
type Ipv4Subnet struct {
- Subnet string `json:"subnet"` // CIDR notation, e.g. 172.16.33.0/24
- Name string `json:"name"`
- Gateway string `json:"gateway"` // IPv4 addre, e.g. 172.16.33.1/24
- Exclude string `json:"excludeIps"` // space separated list of single IPs or ranges e.g. "172.16.33.2 172.16.33.5..172.16.33.10"
+ Subnet string `json:"subnet" yaml:"subnet"` // CIDR notation, e.g. 172.16.33.0/24
+ Name string `json:"name" yaml:"name"`
+ Gateway string `json:"gateway" yaml:"gateway"` // IPv4 addre, e.g. 172.16.33.1/24
+ Exclude string `json:"excludeIps" yaml:"excludeIps"` // space separated list of single IPs or ranges e.g. "172.16.33.2 172.16.33.5..172.16.33.10"
}
const VLAN_NODE_ANY = "any"
@@ -58,11 +65,36 @@ const VLAN_NODE_SPECIFIC = "specific"
var VLAN_NODE_SELECTORS = [...]string{VLAN_NODE_ANY, VLAN_NODE_SPECIFIC}
type Vlan struct {
- VlanId int `json:"vlanID"`
- ProviderInterfaceName string `json:"providerInterfaceName"`
- LogicalInterfaceName string `json:"logicalInterfaceName"`
- VlanNodeSelector string `json:"vlanNodeSelector"`
- NodeLabelList []string `json:"nodeLabelList"`
+ VlanId int `json:"vlanID" yaml:"vlanId"`
+ ProviderInterfaceName string `json:"providerInterfaceName" yaml:"providerInterfaceName"`
+ LogicalInterfaceName string `json:"logicalInterfaceName" yaml:"logicalInterfaceName"`
+ VlanNodeSelector string `json:"vlanNodeSelector" yaml:"vlanNodeSelector"`
+ NodeLabelList []string `json:"nodeLabelList" yaml:"nodeLabelList"`
+}
+
+// Check for valid format Metadata
+func IsValidMetadata(metadata Metadata) error {
+ errs := validation.IsValidName(metadata.Name)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata name=[%v], errors: %v", metadata.Name, errs)
+ }
+
+ errs = validation.IsValidString(metadata.Description, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.Description, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData1, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData1, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData2, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData2, errs)
+ }
+
+ return nil
}
// Check for valid format of an Ipv4Subnet
diff --git a/src/ncm/pkg/module/netcontrolintent.go b/src/ncm/pkg/module/netcontrolintent.go
new file mode 100644
index 00000000..c005a935
--- /dev/null
+++ b/src/ncm/pkg/module/netcontrolintent.go
@@ -0,0 +1,295 @@
+/*
+ * Copyright 2020 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 module
+
+import (
+ "encoding/json"
+ "strings"
+
+ jyaml "github.com/ghodss/yaml"
+
+ nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ "k8s.io/apimachinery/pkg/runtime"
+ "k8s.io/client-go/kubernetes/scheme"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+// NetControlIntent contains the parameters needed for dynamic networks
+type NetControlIntent struct {
+ Metadata Metadata `json:"metadata"`
+}
+
+// NetControlIntentKey is the key structure that is used in the database
+type NetControlIntentKey struct {
+ NetControlIntent string `json:"netcontrolintent"`
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+}
+
+// Manager is an interface exposing the NetControlIntent functionality
+type NetControlIntentManager interface {
+ CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error)
+ GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error)
+ GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error)
+ DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error
+ ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error
+}
+
+// NetControlIntentClient implements the Manager
+// It will also be used to maintain some localized state
+type NetControlIntentClient struct {
+ db ClientDbInfo
+}
+
+// NewNetControlIntentClient returns an instance of the NetControlIntentClient
+// which implements the Manager
+func NewNetControlIntentClient() *NetControlIntentClient {
+ return &NetControlIntentClient{
+ db: ClientDbInfo{
+ storeName: "orchestrator",
+ tagMeta: "netcontrolintentmetadata",
+ },
+ }
+}
+
+// CreateNetControlIntent - create a new NetControlIntent
+func (v *NetControlIntentClient) CreateNetControlIntent(nci NetControlIntent, project, compositeapp, compositeappversion string, exists bool) (NetControlIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := NetControlIntentKey{
+ NetControlIntent: nci.Metadata.Name,
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ }
+
+ //Check if this NetControlIntent already exists
+ _, err := v.GetNetControlIntent(nci.Metadata.Name, project, compositeapp, compositeappversion)
+ if err == nil && !exists {
+ return NetControlIntent{}, pkgerrors.New("NetControlIntent already exists")
+ }
+
+ err = db.DBconn.Insert(v.db.storeName, key, nil, v.db.tagMeta, nci)
+ if err != nil {
+ return NetControlIntent{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return nci, nil
+}
+
+// GetNetControlIntent returns the NetControlIntent for corresponding name
+func (v *NetControlIntentClient) GetNetControlIntent(name, project, compositeapp, compositeappversion string) (NetControlIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := NetControlIntentKey{
+ NetControlIntent: name,
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ }
+
+ value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return NetControlIntent{}, pkgerrors.Wrap(err, "Get NetControlIntent")
+ }
+
+ //value is a byte array
+ if value != nil {
+ nci := NetControlIntent{}
+ err = db.DBconn.Unmarshal(value[0], &nci)
+ if err != nil {
+ return NetControlIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ return nci, nil
+ }
+
+ return NetControlIntent{}, pkgerrors.New("Error getting NetControlIntent")
+}
+
+// GetNetControlIntentList returns all of the NetControlIntent for corresponding name
+func (v *NetControlIntentClient) GetNetControlIntents(project, compositeapp, compositeappversion string) ([]NetControlIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := NetControlIntentKey{
+ NetControlIntent: "",
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ }
+
+ var resp []NetControlIntent
+ values, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return []NetControlIntent{}, pkgerrors.Wrap(err, "Get NetControlIntents")
+ }
+
+ for _, value := range values {
+ nci := NetControlIntent{}
+ err = db.DBconn.Unmarshal(value, &nci)
+ if err != nil {
+ return []NetControlIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ resp = append(resp, nci)
+ }
+
+ return resp, nil
+}
+
+// Delete the NetControlIntent from database
+func (v *NetControlIntentClient) DeleteNetControlIntent(name, project, compositeapp, compositeappversion string) error {
+
+ //Construct key and tag to select the entry
+ key := NetControlIntentKey{
+ NetControlIntent: name,
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ }
+
+ err := db.DBconn.Remove(v.db.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete NetControlIntent Entry;")
+ }
+
+ return nil
+}
+
+// (Test Routine) - Apply network-control-intent
+func (v *NetControlIntentClient) ApplyNetControlIntent(name, project, compositeapp, compositeappversion, appContextId string) error {
+ // TODO: Handle all Network Chain Intents for the Network Control Intent
+
+ // Handle all Workload Intents for the Network Control Intent
+ wis, err := NewWorkloadIntentClient().GetWorkloadIntents(project, compositeapp, compositeappversion, name)
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error getting Workload Intents for Network Control Intent %v for %v/%v%v not found", name, project, compositeapp, compositeappversion)
+ }
+
+ // Setup the AppContext
+ var context appcontext.AppContext
+ _, err = context.LoadAppContext(appContextId)
+ if err != nil {
+ return pkgerrors.Wrapf(err, "Error getting AppContext with Id: %v for %v/%v%v",
+ appContextId, project, compositeapp, compositeappversion)
+ }
+
+ // Handle all intents (currently just Interface intents) for each Workload Intent
+ for _, wi := range wis {
+ // The app/resource identified in the workload intent needs to be updated with two annotations.
+ // 1 - The "k8s.v1.cni.cncf.io/networks" annotation will have {"name": "ovn-networkobj", "namespace": "default"} added
+ // to it (preserving any existing values for this annotation.
+ // 2 - The "k8s.plugin.opnfv.org/nfn-network" annotation will add any network interfaces that are provided by the
+ // workload/interfaces intents.
+
+ // Prepare the list of interfaces from the workload intent
+ wifs, err := NewWorkloadIfIntentClient().GetWorkloadIfIntents(project,
+ compositeapp,
+ compositeappversion,
+ name,
+ wi.Metadata.Name)
+ if err != nil {
+ return pkgerrors.Wrapf(err,
+ "Error getting Workload Interface Intents for Workload Intent %v under Network Control Intent %v for %v/%v%v not found",
+ wi.Metadata.Name, name, project, compositeapp, compositeappversion)
+ }
+ if len(wifs) == 0 {
+ log.Warn("No interface intents provided for workload intent", log.Fields{
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "network control intent": name,
+ "workload intent": wi.Metadata.Name,
+ })
+ continue
+ }
+
+ // Get all clusters for the current App from the AppContext
+ clusters, err := context.GetClusterNames(wi.Spec.AppName)
+ for _, c := range clusters {
+ rh, err := context.GetResourceHandle(wi.Spec.AppName, c,
+ strings.Join([]string{wi.Spec.WorkloadResource, wi.Spec.Type}, "+"))
+ if err != nil {
+ log.Warn("App Context resource handle not found", log.Fields{
+ "project": project,
+ "composite app": compositeapp,
+ "composite app version": compositeappversion,
+ "network control intent": name,
+ "workload name": wi.Metadata.Name,
+ "app": wi.Spec.AppName,
+ "resource": wi.Spec.WorkloadResource,
+ "resource type": wi.Spec.Type,
+ })
+ continue
+ }
+ r, err := context.GetValue(rh)
+ if err != nil {
+ log.Error("Error retrieving resource from App Context", log.Fields{
+ "error": err,
+ "resource handle": rh,
+ })
+ }
+
+ // Unmarshal resource to K8S object
+ robj, err := runtime.Decode(scheme.Codecs.UniversalDeserializer(), []byte(r.(string)))
+
+ // Add network annotation to object
+ netAnnot := nettypes.NetworkSelectionElement{
+ Name: "ovn-networkobj",
+ Namespace: "default",
+ }
+ AddNetworkAnnotation(robj, netAnnot)
+
+ // Add nfn interface annotations to object
+ var newNfnIfs []WorkloadIfIntentSpec
+ for _, i := range wifs {
+ newNfnIfs = append(newNfnIfs, i.Spec)
+ }
+ AddNfnAnnotation(robj, newNfnIfs)
+
+ // Marshal object back to yaml format (via json - seems to eliminate most clutter)
+ j, err := json.Marshal(robj)
+ if err != nil {
+ log.Error("Error marshalling resource to JSON", log.Fields{
+ "error": err,
+ })
+ continue
+ }
+ y, err := jyaml.JSONToYAML(j)
+ if err != nil {
+ log.Error("Error marshalling resource to YAML", log.Fields{
+ "error": err,
+ })
+ continue
+ }
+
+ // Update resource in AppContext
+ err = context.UpdateResourceValue(rh, string(y))
+ if err != nil {
+ log.Error("Network updating app context resource handle", log.Fields{
+ "error": err,
+ "resource handle": rh,
+ })
+ }
+ }
+ }
+
+ return nil
+}
diff --git a/src/ncm/pkg/module/network.go b/src/ncm/pkg/module/network.go
index 2d4121e9..cfb414c5 100644
--- a/src/ncm/pkg/module/network.go
+++ b/src/ncm/pkg/module/network.go
@@ -24,8 +24,8 @@ import (
// Network contains the parameters needed for dynamic networks
type Network struct {
- Metadata Metadata `json:"metadata"`
- Spec NetworkSpec `json:"spec"`
+ Metadata Metadata `json:"metadata" yaml:"metadata"`
+ Spec NetworkSpec `json:"spec" yaml:"spec"`
}
type NetworkSpec struct {
@@ -40,6 +40,16 @@ type NetworkKey struct {
NetworkName string `json:"network"`
}
+// structure for the Network Custom Resource
+type CrNetwork struct {
+ ApiVersion string `yaml:"apiVersion"`
+ Kind string `yaml:"kind"`
+ Network Network
+}
+
+const NETWORK_APIVERSION = "k8s.plugin.opnfv.org/v1alpha1"
+const NETWORK_KIND = "Network"
+
// Manager is an interface exposing the Network functionality
type NetworkManager interface {
CreateNetwork(pr Network, clusterProvider, cluster string, exists bool) (Network, error)
diff --git a/src/ncm/pkg/module/providernet.go b/src/ncm/pkg/module/providernet.go
index 5e2c0343..0435f2ba 100644
--- a/src/ncm/pkg/module/providernet.go
+++ b/src/ncm/pkg/module/providernet.go
@@ -29,12 +29,22 @@ type ProviderNet struct {
}
type ProviderNetSpec struct {
- CniType string `json:"cniType"`
- Ipv4Subnets []Ipv4Subnet `json:"ipv4Subnets"`
- ProviderNetType string `json:"providerNetType"`
- Vlan Vlan `json:"vlan"`
+ CniType string `json:"cniType" yaml:"cniType"`
+ Ipv4Subnets []Ipv4Subnet `json:"ipv4Subnets" yaml:"ipv4Subnets"`
+ ProviderNetType string `json:"providerNetType" yaml:"providerNetType"`
+ Vlan Vlan `json:"vlan" yaml:"vlan"`
}
+// structure for the Network Custom Resource
+type CrProviderNet struct {
+ ApiVersion string `yaml:"apiVersion"`
+ Kind string `yaml:"kind"`
+ ProviderNet ProviderNet
+}
+
+const PROVIDER_NETWORK_APIVERSION = "k8s.plugin.opnfv.org/v1alpha1"
+const PROVIDER_NETWORK_KIND = "ProviderNetwork"
+
// ProviderNetKey is the key structure that is used in the database
type ProviderNetKey struct {
ClusterProviderName string `json:"provider"`
diff --git a/src/ncm/pkg/module/resources.go b/src/ncm/pkg/module/resources.go
new file mode 100644
index 00000000..24c9833e
--- /dev/null
+++ b/src/ncm/pkg/module/resources.go
@@ -0,0 +1,273 @@
+/*
+ * Copyright 2020 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 module
+
+import (
+ "encoding/json"
+ "fmt"
+
+ nettypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"
+ netutils "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/utils"
+ log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
+ v1 "k8s.io/api/apps/v1"
+ batch "k8s.io/api/batch/v1"
+ batchv1beta1 "k8s.io/api/batch/v1beta1"
+ v1core "k8s.io/api/core/v1"
+ _ "k8s.io/kubernetes/pkg/apis/apps/install"
+ _ "k8s.io/kubernetes/pkg/apis/batch/install"
+ _ "k8s.io/kubernetes/pkg/apis/core/install"
+ _ "k8s.io/kubernetes/pkg/apis/extensions/install"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+type NfnAnnotation struct {
+ CniType string
+ Interface []WorkloadIfIntentSpec
+}
+
+const NfnAnnotationKey = "k8s.plugin.opnfv.org/nfn-network"
+
+// ParsePodTemplateNetworkAnnotation parses Pod annotation in PodTemplate
+func ParsePodTemplateNetworkAnnotation(pt *v1core.PodTemplateSpec) ([]*nettypes.NetworkSelectionElement, error) {
+ netAnnot := pt.Annotations[nettypes.NetworkAttachmentAnnot]
+ defaultNamespace := pt.Namespace
+
+ if len(netAnnot) == 0 {
+ return nil, pkgerrors.Errorf("No kubernetes network annotation found")
+ }
+
+ networks, err := netutils.ParseNetworkAnnotation(netAnnot, defaultNamespace)
+ if err != nil {
+ return nil, err
+ }
+ return networks, nil
+}
+
+// GetPodTemplateNetworkAnnotation gets Pod Nfn annotation in PodTemplate
+func GetPodTemplateNfnAnnotation(pt *v1core.PodTemplateSpec) NfnAnnotation {
+ var nfn NfnAnnotation
+
+ nfnAnnot := pt.Annotations[NfnAnnotationKey]
+ if len(nfnAnnot) == 0 {
+ return nfn
+ }
+
+ err := json.Unmarshal([]byte(nfnAnnot), &nfn)
+ if err != nil {
+ log.Warn("Error unmarshalling nfn annotation", log.Fields{
+ "annotation": nfnAnnot,
+ })
+ }
+ return nfn
+}
+
+// GetPodNetworkAnnotation gets Pod Nfn annotation in PodTemplate
+func GetPodNfnAnnotation(p *v1core.Pod) NfnAnnotation {
+ var nfn NfnAnnotation
+
+ nfnAnnot := p.Annotations[NfnAnnotationKey]
+ if len(nfnAnnot) == 0 {
+ return nfn
+ }
+
+ err := json.Unmarshal([]byte(nfnAnnot), &nfn)
+ if err != nil {
+ log.Warn("Error unmarshalling nfn annotation", log.Fields{
+ "annotation": nfnAnnot,
+ })
+ }
+ return nfn
+}
+
+func addNetworkAnnotation(a nettypes.NetworkSelectionElement, as []*nettypes.NetworkSelectionElement) []*nettypes.NetworkSelectionElement {
+ var netElements []*nettypes.NetworkSelectionElement
+
+ found := false
+ for _, e := range as {
+ if e.Name == a.Name {
+ found = true
+ }
+ netElements = append(netElements, e)
+ }
+ if !found {
+ netElements = append(netElements, &a)
+ }
+
+ return netElements
+}
+
+// Add the interfaces in the 'new' parameter to the nfn annotation
+func newNfnIfs(nfn NfnAnnotation, new []WorkloadIfIntentSpec) NfnAnnotation {
+ // Prepare a new interface list - combining the original plus new ones
+ var newNfn NfnAnnotation
+
+ if nfn.CniType != CNI_TYPE_OVN4NFV {
+ if len(nfn.CniType) > 0 {
+ log.Warn("Error existing nfn cnitype is invalid", log.Fields{
+ "existing cnitype": nfn.CniType,
+ "using cnitype": CNI_TYPE_OVN4NFV,
+ })
+ }
+ }
+ newNfn.CniType = CNI_TYPE_OVN4NFV
+
+ // update any interfaces already in the list with the updated interface
+ for _, i := range nfn.Interface {
+ for _, j := range new {
+ if i.NetworkName == j.NetworkName && i.IfName == j.IfName {
+ i.DefaultGateway = j.DefaultGateway
+ i.IpAddr = j.IpAddr
+ i.MacAddr = j.MacAddr
+ break
+ }
+ }
+ newNfn.Interface = append(newNfn.Interface, i)
+ }
+
+ // add new interfaces not present in original list
+ for _, j := range new {
+ found := false
+ for _, i := range nfn.Interface {
+ if i.NetworkName == j.NetworkName && i.IfName == j.IfName {
+ found = true
+ break
+ }
+ }
+ if !found {
+ newNfn.Interface = append(newNfn.Interface, j)
+ }
+ }
+ return newNfn
+}
+
+func updatePodTemplateNetworkAnnotation(pt *v1core.PodTemplateSpec, a nettypes.NetworkSelectionElement) {
+ netAnnotation, _ := ParsePodTemplateNetworkAnnotation(pt)
+ elements := addNetworkAnnotation(a, netAnnotation)
+ j, err := json.Marshal(elements)
+ if err != nil {
+ log.Error("Existing network annotation has invalid format", log.Fields{
+ "error": err,
+ })
+ return
+ }
+ if pt.Annotations == nil {
+ pt.Annotations = make(map[string]string)
+ }
+ pt.Annotations[nettypes.NetworkAttachmentAnnot] = string(j)
+}
+
+// Add a network annotation to the resource
+func AddNetworkAnnotation(r interface{}, a nettypes.NetworkSelectionElement) {
+
+ switch o := r.(type) {
+ case *batch.Job:
+ updatePodTemplateNetworkAnnotation(&o.Spec.Template, a)
+ case *batchv1beta1.CronJob:
+ updatePodTemplateNetworkAnnotation(&o.Spec.JobTemplate.Spec.Template, a)
+ case *v1.DaemonSet:
+ updatePodTemplateNetworkAnnotation(&o.Spec.Template, a)
+ case *v1.Deployment:
+ updatePodTemplateNetworkAnnotation(&o.Spec.Template, a)
+ case *v1.ReplicaSet:
+ updatePodTemplateNetworkAnnotation(&o.Spec.Template, a)
+ case *v1.StatefulSet:
+ updatePodTemplateNetworkAnnotation(&o.Spec.Template, a)
+ case *v1core.Pod:
+ netAnnotation, _ := netutils.ParsePodNetworkAnnotation(o)
+ elements := addNetworkAnnotation(a, netAnnotation)
+ j, err := json.Marshal(elements)
+ if err != nil {
+ log.Error("Existing network annotation has invalid format", log.Fields{
+ "error": err,
+ })
+ break
+ }
+ if o.Annotations == nil {
+ o.Annotations = make(map[string]string)
+ }
+ o.Annotations[nettypes.NetworkAttachmentAnnot] = string(j)
+ return
+ case *v1core.ReplicationController:
+ updatePodTemplateNetworkAnnotation(o.Spec.Template, a)
+ default:
+ typeStr := fmt.Sprintf("%T", o)
+ log.Warn("Network annotations not supported for resource type", log.Fields{
+ "resource type": typeStr,
+ })
+ }
+}
+
+func updatePodTemplateNfnAnnotation(pt *v1core.PodTemplateSpec, new []WorkloadIfIntentSpec) {
+ nfnAnnotation := GetPodTemplateNfnAnnotation(pt)
+ newNfnAnnotation := newNfnIfs(nfnAnnotation, new)
+ j, err := json.Marshal(newNfnAnnotation)
+ if err != nil {
+ log.Error("Network nfn annotation has invalid format", log.Fields{
+ "error": err,
+ })
+ return
+ }
+ if pt.Annotations == nil {
+ pt.Annotations = make(map[string]string)
+ }
+ pt.Annotations[NfnAnnotationKey] = string(j)
+}
+
+// Add an nfn annotation to the resource
+func AddNfnAnnotation(r interface{}, new []WorkloadIfIntentSpec) {
+
+ switch o := r.(type) {
+ case *batch.Job:
+ updatePodTemplateNfnAnnotation(&o.Spec.Template, new)
+ case *batchv1beta1.CronJob:
+ updatePodTemplateNfnAnnotation(&o.Spec.JobTemplate.Spec.Template, new)
+ case *v1.DaemonSet:
+ updatePodTemplateNfnAnnotation(&o.Spec.Template, new)
+ return
+ case *v1.Deployment:
+ updatePodTemplateNfnAnnotation(&o.Spec.Template, new)
+ return
+ case *v1.ReplicaSet:
+ updatePodTemplateNfnAnnotation(&o.Spec.Template, new)
+ case *v1.StatefulSet:
+ updatePodTemplateNfnAnnotation(&o.Spec.Template, new)
+ case *v1core.Pod:
+ nfnAnnotation := GetPodNfnAnnotation(o)
+ newNfnAnnotation := newNfnIfs(nfnAnnotation, new)
+ j, err := json.Marshal(newNfnAnnotation)
+ if err != nil {
+ log.Error("Network nfn annotation has invalid format", log.Fields{
+ "error": err,
+ })
+ break
+ }
+ if o.Annotations == nil {
+ o.Annotations = make(map[string]string)
+ }
+ o.Annotations[NfnAnnotationKey] = string(j)
+ return
+ case *v1core.ReplicationController:
+ updatePodTemplateNfnAnnotation(o.Spec.Template, new)
+ return
+ default:
+ typeStr := fmt.Sprintf("%T", o)
+ log.Warn("Network nfn annotations not supported for resource type", log.Fields{
+ "resource type": typeStr,
+ })
+ }
+}
diff --git a/src/ncm/pkg/module/workloadifintent.go b/src/ncm/pkg/module/workloadifintent.go
new file mode 100644
index 00000000..55062564
--- /dev/null
+++ b/src/ncm/pkg/module/workloadifintent.go
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2020 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 module
+
+import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+// WorkloadIfIntent contains the parameters needed for dynamic networks
+type WorkloadIfIntent struct {
+ Metadata Metadata `json:"metadata"`
+ Spec WorkloadIfIntentSpec `json:"spec"`
+}
+
+type WorkloadIfIntentSpec struct {
+ IfName string `json:"interface"`
+ NetworkName string `json:"name"`
+ DefaultGateway string `json:"defaultGateway"` // optional, default value is "false"
+ IpAddr string `json:"ipAddress,omitempty"` // optional, if not provided then will be dynamically allocated
+ MacAddr string `json:"macAddress,omitempty"` // optional, if not provided then will be dynamically allocated
+}
+
+// WorkloadIfIntentKey is the key structure that is used in the database
+type WorkloadIfIntentKey struct {
+ Project string `json:"provider"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+ NetControlIntent string `json:"netcontrolintent"`
+ WorkloadIntent string `json:"workloadintent"`
+ WorkloadIfIntent string `json:"workloadifintent"`
+}
+
+// Manager is an interface exposing the WorkloadIfIntent functionality
+type WorkloadIfIntentManager interface {
+ CreateWorkloadIfIntent(wi WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error)
+ GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error)
+ GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error)
+ DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error
+}
+
+// WorkloadIfIntentClient implements the Manager
+// It will also be used to maintain some localized state
+type WorkloadIfIntentClient struct {
+ db ClientDbInfo
+}
+
+// NewWorkloadIfIntentClient returns an instance of the WorkloadIfIntentClient
+// which implements the Manager
+func NewWorkloadIfIntentClient() *WorkloadIfIntentClient {
+ return &WorkloadIfIntentClient{
+ db: ClientDbInfo{
+ storeName: "orchestrator",
+ tagMeta: "workloadifintentmetadata",
+ },
+ }
+}
+
+// CreateWorkloadIfIntent - create a new WorkloadIfIntent
+func (v *WorkloadIfIntentClient) CreateWorkloadIfIntent(wif WorkloadIfIntent, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string, exists bool) (WorkloadIfIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIfIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: workloadintent,
+ WorkloadIfIntent: wif.Metadata.Name,
+ }
+
+ //Check if the Workload Intent exists
+ _, err := NewWorkloadIntentClient().GetWorkloadIntent(workloadintent, project, compositeapp, compositeappversion, netcontrolintent)
+ if err != nil {
+ return WorkloadIfIntent{}, pkgerrors.Errorf("Workload Intent %v does not exist", workloadintent)
+ }
+
+ //Check if this WorkloadIfIntent already exists
+ _, err = v.GetWorkloadIfIntent(wif.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent)
+ if err == nil && !exists {
+ return WorkloadIfIntent{}, pkgerrors.New("WorkloadIfIntent already exists")
+ }
+
+ err = db.DBconn.Insert(v.db.storeName, key, nil, v.db.tagMeta, wif)
+ if err != nil {
+ return WorkloadIfIntent{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return wif, nil
+}
+
+// GetWorkloadIfIntent returns the WorkloadIfIntent for corresponding name
+func (v *WorkloadIfIntentClient) GetWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) (WorkloadIfIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIfIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: workloadintent,
+ WorkloadIfIntent: name,
+ }
+
+ value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return WorkloadIfIntent{}, pkgerrors.Wrap(err, "Get WorkloadIfIntent")
+ }
+
+ //value is a byte array
+ if value != nil {
+ wif := WorkloadIfIntent{}
+ err = db.DBconn.Unmarshal(value[0], &wif)
+ if err != nil {
+ return WorkloadIfIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ return wif, nil
+ }
+
+ return WorkloadIfIntent{}, pkgerrors.New("Error getting WorkloadIfIntent")
+}
+
+// GetWorkloadIfIntentList returns all of the WorkloadIfIntent for corresponding name
+func (v *WorkloadIfIntentClient) GetWorkloadIfIntents(project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) ([]WorkloadIfIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIfIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: workloadintent,
+ WorkloadIfIntent: "",
+ }
+
+ var resp []WorkloadIfIntent
+ values, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return []WorkloadIfIntent{}, pkgerrors.Wrap(err, "Get WorkloadIfIntents")
+ }
+
+ for _, value := range values {
+ wif := WorkloadIfIntent{}
+ err = db.DBconn.Unmarshal(value, &wif)
+ if err != nil {
+ return []WorkloadIfIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ resp = append(resp, wif)
+ }
+
+ return resp, nil
+}
+
+// Delete the WorkloadIfIntent from database
+func (v *WorkloadIfIntentClient) DeleteWorkloadIfIntent(name, project, compositeapp, compositeappversion, netcontrolintent, workloadintent string) error {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIfIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: workloadintent,
+ WorkloadIfIntent: name,
+ }
+
+ err := db.DBconn.Remove(v.db.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete WorkloadIfIntent Entry;")
+ }
+
+ return nil
+}
diff --git a/src/ncm/pkg/module/workloadintent.go b/src/ncm/pkg/module/workloadintent.go
new file mode 100644
index 00000000..e6916954
--- /dev/null
+++ b/src/ncm/pkg/module/workloadintent.go
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2020 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 module
+
+import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+// WorkloadIntent contains the parameters needed for dynamic networks
+type WorkloadIntent struct {
+ Metadata Metadata `json:"metadata"`
+ Spec WorkloadIntentSpec `json:"spec"`
+}
+
+type WorkloadIntentSpec struct {
+ AppName string `json:"application-name"`
+ WorkloadResource string `json:"workload-resource"`
+ Type string `json:"type"`
+}
+
+// WorkloadIntentKey is the key structure that is used in the database
+type WorkloadIntentKey struct {
+ Project string `json:"provider"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+ NetControlIntent string `json:"netcontrolintent"`
+ WorkloadIntent string `json:"workloadintent"`
+}
+
+// Manager is an interface exposing the WorkloadIntent functionality
+type WorkloadIntentManager interface {
+ CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error)
+ GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error)
+ GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error)
+ DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error
+}
+
+// WorkloadIntentClient implements the Manager
+// It will also be used to maintain some localized state
+type WorkloadIntentClient struct {
+ db ClientDbInfo
+}
+
+// NewWorkloadIntentClient returns an instance of the WorkloadIntentClient
+// which implements the Manager
+func NewWorkloadIntentClient() *WorkloadIntentClient {
+ return &WorkloadIntentClient{
+ db: ClientDbInfo{
+ storeName: "orchestrator",
+ tagMeta: "workloadintentmetadata",
+ },
+ }
+}
+
+// CreateWorkloadIntent - create a new WorkloadIntent
+func (v *WorkloadIntentClient) CreateWorkloadIntent(wi WorkloadIntent, project, compositeapp, compositeappversion, netcontrolintent string, exists bool) (WorkloadIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: wi.Metadata.Name,
+ }
+
+ //Check if the Network Control Intent exists
+ _, err := NewNetControlIntentClient().GetNetControlIntent(netcontrolintent, project, compositeapp, compositeappversion)
+ if err != nil {
+ return WorkloadIntent{}, pkgerrors.Errorf("Network Control Intent %v does not exist", netcontrolintent)
+ }
+
+ //Check if this WorkloadIntent already exists
+ _, err = v.GetWorkloadIntent(wi.Metadata.Name, project, compositeapp, compositeappversion, netcontrolintent)
+ if err == nil && !exists {
+ return WorkloadIntent{}, pkgerrors.New("WorkloadIntent already exists")
+ }
+
+ err = db.DBconn.Insert(v.db.storeName, key, nil, v.db.tagMeta, wi)
+ if err != nil {
+ return WorkloadIntent{}, pkgerrors.Wrap(err, "Creating DB Entry")
+ }
+
+ return wi, nil
+}
+
+// GetWorkloadIntent returns the WorkloadIntent for corresponding name
+func (v *WorkloadIntentClient) GetWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) (WorkloadIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: name,
+ }
+
+ value, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return WorkloadIntent{}, pkgerrors.Wrap(err, "Get WorkloadIntent")
+ }
+
+ //value is a byte array
+ if value != nil {
+ wi := WorkloadIntent{}
+ err = db.DBconn.Unmarshal(value[0], &wi)
+ if err != nil {
+ return WorkloadIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ return wi, nil
+ }
+
+ return WorkloadIntent{}, pkgerrors.New("Error getting WorkloadIntent")
+}
+
+// GetWorkloadIntentList returns all of the WorkloadIntent for corresponding name
+func (v *WorkloadIntentClient) GetWorkloadIntents(project, compositeapp, compositeappversion, netcontrolintent string) ([]WorkloadIntent, error) {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: "",
+ }
+
+ var resp []WorkloadIntent
+ values, err := db.DBconn.Find(v.db.storeName, key, v.db.tagMeta)
+ if err != nil {
+ return []WorkloadIntent{}, pkgerrors.Wrap(err, "Get WorkloadIntents")
+ }
+
+ for _, value := range values {
+ wi := WorkloadIntent{}
+ err = db.DBconn.Unmarshal(value, &wi)
+ if err != nil {
+ return []WorkloadIntent{}, pkgerrors.Wrap(err, "Unmarshalling Value")
+ }
+ resp = append(resp, wi)
+ }
+
+ return resp, nil
+}
+
+// Delete the WorkloadIntent from database
+func (v *WorkloadIntentClient) DeleteWorkloadIntent(name, project, compositeapp, compositeappversion, netcontrolintent string) error {
+
+ //Construct key and tag to select the entry
+ key := WorkloadIntentKey{
+ Project: project,
+ CompositeApp: compositeapp,
+ CompositeAppVersion: compositeappversion,
+ NetControlIntent: netcontrolintent,
+ WorkloadIntent: name,
+ }
+
+ err := db.DBconn.Remove(v.db.storeName, key)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Delete WorkloadIntent Entry;")
+ }
+
+ return nil
+}
diff --git a/src/orchestrator/api/add_intents_handler.go b/src/orchestrator/api/add_intents_handler.go
index dfe1a496..ac8b400d 100644
--- a/src/orchestrator/api/add_intents_handler.go
+++ b/src/orchestrator/api/add_intents_handler.go
@@ -21,6 +21,7 @@ import (
"io"
"net/http"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
"github.com/gorilla/mux"
@@ -70,6 +71,76 @@ func (h intentHandler) addIntentHandler(w http.ResponseWriter, r *http.Request)
}
}
+/*
+getIntentByNameHandler handles the URL
+URL: /v2/projects/{project-name}/composite-apps/{composite-app-name}/{version}/
+deployment-intent-groups/{deployment-intent-group-name}/intents?intent=<intent>
+*/
+func (h intentHandler) getIntentByNameHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ pList := []string{"project-name", "composite-app-name", "composite-app-version", "deployment-intent-group-name"}
+ err := validation.IsValidParameterPresent(vars, pList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ }
+ p := vars["project-name"]
+ ca := vars["composite-app-name"]
+ v := vars["composite-app-version"]
+ di := vars["deployment-intent-group-name"]
+
+ iN := r.URL.Query().Get("intent")
+ if iN == "" {
+ http.Error(w, "Missing appName in GET request", http.StatusBadRequest)
+ return
+ }
+
+ mapOfIntents, err := h.client.GetIntentByName(iN, p, ca, v, di)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(mapOfIntents)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+/*
+getAllIntentsHandler handles the URL
+URL: /v2/projects/{project-name}/composite-apps/{composite-app-name}/{version}/
+deployment-intent-groups/{deployment-intent-group-name}/intents
+*/
+func (h intentHandler) getAllIntentsHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ pList := []string{"project-name", "composite-app-name", "composite-app-version", "deployment-intent-group-name"}
+ err := validation.IsValidParameterPresent(vars, pList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ }
+
+ p := vars["project-name"]
+ ca := vars["composite-app-name"]
+ v := vars["composite-app-version"]
+ di := vars["deployment-intent-group-name"]
+
+ mapOfIntents, err := h.client.GetAllIntents(p, ca, v, di)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(mapOfIntents)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+}
+
func (h intentHandler) getIntentHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
diff --git a/src/orchestrator/api/api.go b/src/orchestrator/api/api.go
index 1d38f106..8b4b91a1 100644
--- a/src/orchestrator/api/api.go
+++ b/src/orchestrator/api/api.go
@@ -33,7 +33,8 @@ func NewRouter(projectClient moduleLib.ProjectManager,
deploymentIntentGrpClient moduleLib.DeploymentIntentGroupManager,
intentClient moduleLib.IntentManager,
compositeProfileClient moduleLib.CompositeProfileManager,
- appProfileClient moduleLib.AppProfileManager) *mux.Router {
+ appProfileClient moduleLib.AppProfileManager,
+ instantiationClient moduleLib.InstantiationManager) *mux.Router {
router := mux.NewRouter().PathPrefix("/v2").Subrouter()
@@ -110,7 +111,8 @@ func NewRouter(projectClient moduleLib.ProjectManager,
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/composite-profiles/{composite-profile-name}/profiles/{app-profile}", appProfileHandler.deleteAppProfileHandler).Methods("DELETE")
router.HandleFunc("/controllers", controlHandler.createHandler).Methods("POST")
- router.HandleFunc("/controllers", controlHandler.createHandler).Methods("PUT")
+ router.HandleFunc("/controllers", controlHandler.getHandler).Methods("GET")
+ router.HandleFunc("/controllers/{controller-name}", controlHandler.putHandler).Methods("PUT")
router.HandleFunc("/controllers/{controller-name}", controlHandler.getHandler).Methods("GET")
router.HandleFunc("/controllers/{controller-name}", controlHandler.deleteHandler).Methods("DELETE")
//setting routes for genericPlacementIntent
@@ -136,8 +138,9 @@ func NewRouter(projectClient moduleLib.ProjectManager,
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}/app-intents", appIntentHandler.createAppIntentHandler).Methods("POST")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}/app-intents/{app-intent-name}", appIntentHandler.getAppIntentHandler).Methods("GET")
+ router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}/app-intents", appIntentHandler.getAllAppIntentsHandler).Methods("GET")
+ router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}/app-intents/", appIntentHandler.getAllIntentsByAppHandler).Queries("app-name", "{app-name}")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/generic-placement-intents/{intent-name}/app-intents/{app-intent-name}", appIntentHandler.deleteAppIntentHandler).Methods("DELETE")
-
//setting routes for deploymentIntentGroup
if deploymentIntentGrpClient == nil {
deploymentIntentGrpClient = moduleClient.DeploymentIntentGroup
@@ -161,7 +164,20 @@ func NewRouter(projectClient moduleLib.ProjectManager,
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/intents", intentHandler.addIntentHandler).Methods("POST")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/intents/{intent-name}", intentHandler.getIntentHandler).Methods("GET")
+ router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/intents", intentHandler.getAllIntentsHandler).Methods("GET")
+ router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/intents/", intentHandler.getIntentByNameHandler).Queries("intent", "{intent}")
router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/intents/{intent-name}", intentHandler.deleteIntentHandler).Methods("DELETE")
+ // setting routes for Instantiation
+ if instantiationClient == nil {
+ instantiationClient = moduleClient.Instantiation
+ }
+
+ instantiationHandler := instantiationHandler{
+ client: instantiationClient,
+ }
+
+ router.HandleFunc("/projects/{project-name}/composite-apps/{composite-app-name}/{composite-app-version}/deployment-intent-groups/{deployment-intent-group-name}/instantiate", instantiationHandler.instantiateHandler).Methods("POST")
+
return router
}
diff --git a/src/orchestrator/api/app_intent_handler.go b/src/orchestrator/api/app_intent_handler.go
index ab510c8e..56811d2d 100644
--- a/src/orchestrator/api/app_intent_handler.go
+++ b/src/orchestrator/api/app_intent_handler.go
@@ -18,10 +18,12 @@ package api
import (
"encoding/json"
- "github.com/gorilla/mux"
- moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
"io"
"net/http"
+
+ "github.com/gorilla/mux"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
)
/* Used to store backend implementation objects
@@ -120,6 +122,77 @@ func (h appIntentHandler) getAppIntentHandler(w http.ResponseWriter, r *http.Req
}
+/*
+getAllIntentsByAppHandler handles the URL:
+/v2/project/{project-name}/composite-apps/{composite-app-name}/{version}/generic-placement-intent/{intent-name}/app-intents?app-name=<app-name>
+*/
+func (h appIntentHandler) getAllIntentsByAppHandler(w http.ResponseWriter, r *http.Request) {
+
+ vars := mux.Vars(r)
+ pList := []string{"project-name", "composite-app-name", "composite-app-version", "intent-name"}
+ err := validation.IsValidParameterPresent(vars, pList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ }
+ p := vars["project-name"]
+ ca := vars["composite-app-name"]
+ v := vars["composite-app-version"]
+ i := vars["intent-name"]
+ aN := r.URL.Query().Get("app-name")
+ if aN == "" {
+ http.Error(w, "Missing appName in GET request", http.StatusBadRequest)
+ return
+ }
+
+ specData, err := h.client.GetAllIntentsByApp(aN, p, ca, v, i)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(specData)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ return
+
+}
+
+/*
+getAllAppIntentsHandler handles the URL:
+/v2/project/{project-name}/composite-apps/{composite-app-name}/{version}/generic-placement-intent/{intent-name}/app-intents
+*/
+func (h appIntentHandler) getAllAppIntentsHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ pList := []string{"project-name", "composite-app-name", "composite-app-version", "intent-name"}
+ err := validation.IsValidParameterPresent(vars, pList)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ }
+ p := vars["project-name"]
+ ca := vars["composite-app-name"]
+ v := vars["composite-app-version"]
+ i := vars["intent-name"]
+
+ applicationsAndClusterInfo, err := h.client.GetAllAppIntents(p, ca, v, i)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+
+ w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusOK)
+ err = json.NewEncoder(w).Encode(applicationsAndClusterInfo)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ return
+
+}
+
func (h appIntentHandler) deleteAppIntentHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
diff --git a/src/orchestrator/api/app_profilehandler.go b/src/orchestrator/api/app_profilehandler.go
index ef7833de..f2475e23 100644
--- a/src/orchestrator/api/app_profilehandler.go
+++ b/src/orchestrator/api/app_profilehandler.go
@@ -210,12 +210,12 @@ func (h appProfileHandler) getAppProfileHandler(w http.ResponseWriter, r *http.R
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- kc_bytes, err := base64.StdEncoding.DecodeString(retAppProfileContent.Profile)
+ kcBytes, err := base64.StdEncoding.DecodeString(retAppProfileContent.Profile)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- _, err = pw.Write(kc_bytes)
+ _, err = pw.Write(kcBytes)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -231,12 +231,12 @@ func (h appProfileHandler) getAppProfileHandler(w http.ResponseWriter, r *http.R
case "application/octet-stream":
w.Header().Set("Content-Type", "application/octet-stream")
w.WriteHeader(http.StatusOK)
- kc_bytes, err := base64.StdEncoding.DecodeString(retAppProfileContent.Profile)
+ kcBytes, err := base64.StdEncoding.DecodeString(retAppProfileContent.Profile)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
- _, err = w.Write(kc_bytes)
+ _, err = w.Write(kcBytes)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
diff --git a/src/orchestrator/api/composite_profilehandler_test.go b/src/orchestrator/api/composite_profilehandler_test.go
index 360653c7..ec3ec24b 100644
--- a/src/orchestrator/api/composite_profilehandler_test.go
+++ b/src/orchestrator/api/composite_profilehandler_test.go
@@ -105,7 +105,7 @@ func Test_compositeProfileHandler_createHandler(t *testing.T) {
cProfClient: &mockCompositeProfileManager{
//Items that will be returned by the mocked Client
Items: []moduleLib.CompositeProfile{
- moduleLib.CompositeProfile{
+ {
Metadata: moduleLib.CompositeProfileMetadata{
Name: "testCompositeProfile",
Description: "Test CompositeProfile used for unit testing",
@@ -128,7 +128,7 @@ func Test_compositeProfileHandler_createHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("POST", "/v2/projects/{project-name}/composite-apps/{composite-app-name}/{version}/composite-profiles", testCase.reader)
- resp := executeRequest(request, NewRouter(nil, nil, nil, nil, nil, nil, nil, nil, testCase.cProfClient, nil))
+ resp := executeRequest(request, NewRouter(nil, nil, nil, nil, nil, nil, nil, nil, testCase.cProfClient, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
diff --git a/src/orchestrator/api/controllerhandler.go b/src/orchestrator/api/controllerhandler.go
index 4f98c023..1dad2bf8 100644
--- a/src/orchestrator/api/controllerhandler.go
+++ b/src/orchestrator/api/controllerhandler.go
@@ -22,7 +22,9 @@ import (
"net/http"
"github.com/gorilla/mux"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
+ pkgerrors "github.com/pkg/errors"
)
// Used to store backend implementations objects
@@ -33,6 +35,43 @@ type controllerHandler struct {
client moduleLib.ControllerManager
}
+// Check for valid format of input parameters
+func validateControllerInputs(c moduleLib.Controller) error {
+ // validate metadata
+ err := moduleLib.IsValidMetadata(c.Metadata)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Invalid controller metadata")
+ }
+
+ errs := validation.IsValidName(c.Spec.Host)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid host name for controller %v, errors: %v", c.Spec.Host, errs)
+ }
+
+ errs = validation.IsValidNumber(c.Spec.Port, 0, 65535)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid controller port [%v], errors: %v", c.Spec.Port, errs)
+ }
+
+ found := false
+ for _, val := range moduleLib.CONTROLLER_TYPES {
+ if c.Spec.Type == val {
+ found = true
+ break
+ }
+ }
+ if !found {
+ return pkgerrors.Errorf("Invalid controller type: %v", c.Spec.Type)
+ }
+
+ errs = validation.IsValidNumber(c.Spec.Priority, moduleLib.MinControllerPriority, moduleLib.MaxControllerPriority)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid controller priority = [%v], errors: %v", c.Spec.Priority, errs)
+ }
+
+ return nil
+}
+
// Create handles creation of the controller entry in the database
func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request) {
var m moduleLib.Controller
@@ -48,12 +87,12 @@ func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request)
}
// Name is required.
- if m.Name == "" {
+ if m.Metadata.Name == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
return
}
- ret, err := h.client.CreateController(m)
+ ret, err := h.client.CreateController(m, false)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
@@ -68,19 +107,74 @@ func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request)
}
}
-// Get handles GET operations on a particular controller Name
-// Returns a controller
-func (h controllerHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+// Put handles creation or update of the controller entry in the database
+func (h controllerHandler) putHandler(w http.ResponseWriter, r *http.Request) {
+ var m moduleLib.Controller
vars := mux.Vars(r)
name := vars["controller-name"]
- ret, err := h.client.GetController(name)
+ err := json.NewDecoder(r.Body).Decode(&m)
+ switch {
+ case err == io.EOF:
+ http.Error(w, "Empty body", http.StatusBadRequest)
+ return
+ case err != nil:
+ http.Error(w, err.Error(), http.StatusUnprocessableEntity)
+ return
+ }
+
+ // Name is required.
+ if m.Metadata.Name == "" {
+ http.Error(w, "Missing name in POST request", http.StatusBadRequest)
+ return
+ }
+
+ // name in URL should match name in body
+ if m.Metadata.Name != name {
+ http.Error(w, "Mismatched name in PUT request", http.StatusBadRequest)
+ return
+ }
+
+ ret, err := h.client.CreateController(m, true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
+ w.WriteHeader(http.StatusCreated)
+ err = json.NewEncoder(w).Encode(ret)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+}
+
+// Get handles GET operations on a particular controller Name
+// Returns a controller
+func (h controllerHandler) getHandler(w http.ResponseWriter, r *http.Request) {
+ vars := mux.Vars(r)
+ name := vars["controller-name"]
+ var ret interface{}
+ var err error
+
+ // handle the get all controllers case
+ if len(name) == 0 {
+ ret, err = h.client.GetControllers()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ } else {
+
+ ret, err = h.client.GetController(name)
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ }
+
+ w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
err = json.NewEncoder(w).Encode(ret)
if err != nil {
diff --git a/src/orchestrator/api/controllerhandler_test.go b/src/orchestrator/api/controllerhandler_test.go
index 1844fb32..a2f93ea7 100644
--- a/src/orchestrator/api/controllerhandler_test.go
+++ b/src/orchestrator/api/controllerhandler_test.go
@@ -40,7 +40,7 @@ type mockControllerManager struct {
Err error
}
-func (m *mockControllerManager) CreateController(inp moduleLib.Controller) (moduleLib.Controller, error) {
+func (m *mockControllerManager) CreateController(inp moduleLib.Controller, mayExist bool) (moduleLib.Controller, error) {
if m.Err != nil {
return moduleLib.Controller{}, m.Err
}
@@ -56,6 +56,14 @@ func (m *mockControllerManager) GetController(name string) (moduleLib.Controller
return m.Items[0], nil
}
+func (m *mockControllerManager) GetControllers() ([]moduleLib.Controller, error) {
+ if m.Err != nil {
+ return []moduleLib.Controller{}, m.Err
+ }
+
+ return m.Items, nil
+}
+
func (m *mockControllerManager) DeleteController(name string) error {
return m.Err
}
@@ -77,22 +85,33 @@ func TestControllerCreateHandler(t *testing.T) {
label: "Create Controller",
expectedCode: http.StatusCreated,
reader: bytes.NewBuffer([]byte(`{
- "name":"testController",
+ "metadata": {
+ "name":"testController"
+ },
+ "spec": {
"ip-address":"10.188.234.1",
- "port":8080
+ "port":8080 }
}`)),
expected: moduleLib.Controller{
- Name: "testController",
- Host: "10.188.234.1",
- Port: 8080,
+ Metadata: moduleLib.Metadata{
+ Name: "testController",
+ },
+ Spec: moduleLib.ControllerSpec{
+ Host: "10.188.234.1",
+ Port: 8080,
+ },
},
controllerClient: &mockControllerManager{
//Items that will be returned by the mocked Client
Items: []moduleLib.Controller{
{
- Name: "testController",
- Host: "10.188.234.1",
- Port: 8080,
+ Metadata: moduleLib.Metadata{
+ Name: "testController",
+ },
+ Spec: moduleLib.ControllerSpec{
+ Host: "10.188.234.1",
+ Port: 8080,
+ },
},
},
},
@@ -110,7 +129,7 @@ func TestControllerCreateHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("POST", "/v2/controllers", testCase.reader)
- resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
@@ -144,17 +163,25 @@ func TestControllerGetHandler(t *testing.T) {
label: "Get Controller",
expectedCode: http.StatusOK,
expected: moduleLib.Controller{
- Name: "testController",
- Host: "10.188.234.1",
- Port: 8080,
+ Metadata: moduleLib.Metadata{
+ Name: "testController",
+ },
+ Spec: moduleLib.ControllerSpec{
+ Host: "10.188.234.1",
+ Port: 8080,
+ },
},
name: "testController",
controllerClient: &mockControllerManager{
Items: []moduleLib.Controller{
{
- Name: "testController",
- Host: "10.188.234.1",
- Port: 8080,
+ Metadata: moduleLib.Metadata{
+ Name: "testController",
+ },
+ Spec: moduleLib.ControllerSpec{
+ Host: "10.188.234.1",
+ Port: 8080,
+ },
},
},
},
@@ -173,7 +200,7 @@ func TestControllerGetHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("GET", "/v2/controllers/"+testCase.name, nil)
- resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
@@ -222,7 +249,7 @@ func TestControllerDeleteHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("DELETE", "/v2/controllers/"+testCase.name, nil)
- resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(nil, nil, nil, testCase.controllerClient, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
diff --git a/src/orchestrator/api/instantiation_handler.go b/src/orchestrator/api/instantiation_handler.go
new file mode 100644
index 00000000..c95785f2
--- /dev/null
+++ b/src/orchestrator/api/instantiation_handler.go
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2020 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 api
+
+import (
+ "github.com/gorilla/mux"
+ moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
+ "net/http"
+)
+
+/* Used to store backend implementation objects
+Also simplifies mocking for unit testing purposes
+*/
+type instantiationHandler struct {
+ client moduleLib.InstantiationManager
+}
+
+func (h instantiationHandler) instantiateHandler(w http.ResponseWriter, r *http.Request) {
+
+ vars := mux.Vars(r)
+ p := vars["project-name"]
+ ca := vars["composite-app-name"]
+ v := vars["composite-app-version"]
+ di := vars["deployment-intent-group-name"]
+
+ iErr := h.client.Instantiate(p, ca, v, di)
+ if iErr != nil {
+ http.Error(w, iErr.Error(), http.StatusInternalServerError)
+ return
+ }
+ w.WriteHeader(http.StatusAccepted)
+
+}
diff --git a/src/orchestrator/api/projecthandler_test.go b/src/orchestrator/api/projecthandler_test.go
index af40f961..0212e57a 100644
--- a/src/orchestrator/api/projecthandler_test.go
+++ b/src/orchestrator/api/projecthandler_test.go
@@ -95,7 +95,7 @@ func TestProjectCreateHandler(t *testing.T) {
projectClient: &mockProjectManager{
//Items that will be returned by the mocked Client
Items: []moduleLib.Project{
- moduleLib.Project{
+ {
MetaData: moduleLib.ProjectMetaData{
Name: "testProject",
Description: "Test Project used for unit testing",
@@ -119,7 +119,7 @@ func TestProjectCreateHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("POST", "/v2/projects", testCase.reader)
- resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
@@ -163,7 +163,7 @@ func TestProjectGetHandler(t *testing.T) {
name: "testProject",
projectClient: &mockProjectManager{
Items: []moduleLib.Project{
- moduleLib.Project{
+ {
MetaData: moduleLib.ProjectMetaData{
Name: "testProject",
Description: "Test Project used for unit testing",
@@ -188,7 +188,7 @@ func TestProjectGetHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("GET", "/v2/projects/"+testCase.name, nil)
- resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
@@ -237,7 +237,7 @@ func TestProjectDeleteHandler(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.label, func(t *testing.T) {
request := httptest.NewRequest("DELETE", "/v2/projects/"+testCase.name, nil)
- resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil))
+ resp := executeRequest(request, NewRouter(testCase.projectClient, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil))
//Check returned code
if resp.StatusCode != testCase.expectedCode {
diff --git a/src/orchestrator/cmd/main.go b/src/orchestrator/cmd/main.go
index f95c057e..001903a7 100644
--- a/src/orchestrator/cmd/main.go
+++ b/src/orchestrator/cmd/main.go
@@ -47,7 +47,7 @@ func main() {
log.Fatalln("Exiting...")
}
- httpRouter := api.NewRouter(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ httpRouter := api.NewRouter(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
loggedRouter := handlers.LoggingHandler(os.Stdout, httpRouter)
log.Println("Starting Kubernetes Multicloud API")
diff --git a/src/orchestrator/go.mod b/src/orchestrator/go.mod
index 547fa8ed..39d28d5c 100644
--- a/src/orchestrator/go.mod
+++ b/src/orchestrator/go.mod
@@ -2,13 +2,11 @@ module github.com/onap/multicloud-k8s/src/orchestrator
require (
github.com/coreos/etcd v3.3.12+incompatible
- github.com/docker/engine v0.0.0-20190620014054-c513a4c6c298
github.com/ghodss/yaml v1.0.0
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/snappy v0.0.1 // indirect
github.com/gorilla/handlers v1.3.0
github.com/gorilla/mux v1.6.2
- github.com/hashicorp/consul v1.4.0
github.com/json-iterator/go v1.1.8 // indirect
github.com/onap/multicloud-k8s/src/k8splugin v0.0.0-20191115005109-f168ebb73d8d // indirect
github.com/pkg/errors v0.8.1
@@ -17,9 +15,7 @@ require (
go.mongodb.org/mongo-driver v1.0.0
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
- k8s.io/api v0.0.0-20190831074750-7364b6bdad65
k8s.io/apimachinery v0.0.0-20190831074630-461753078381
- k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
k8s.io/helm v2.14.3+incompatible
k8s.io/klog v1.0.0 // indirect
)
diff --git a/src/orchestrator/go.sum b/src/orchestrator/go.sum
index aeab3b50..8205385d 100644
--- a/src/orchestrator/go.sum
+++ b/src/orchestrator/go.sum
@@ -1,80 +1,119 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
+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/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08=
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
+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/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
+github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+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/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg=
+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/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag=
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=
github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.12+incompatible h1:pAWNwdf7QiT1zfaWyqCtNZQWCLByQyA3JrSQyuYAqnQ=
github.com/coreos/etcd v3.3.12+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
+github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f h1:JOrtw2xFKzlg+cbHpyrpLDmnN1HqhBfnX7WDiW7eG2c=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
+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 v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
+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.20190912223608-ad718029b705 h1:up4REDeXtcm77SlkowEGUuakgjpdNR2N9TkGTZSL4rM=
github.com/docker/docker v0.7.3-0.20190912223608-ad718029b705/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/engine v0.0.0-20190620014054-c513a4c6c298/go.mod h1:3CPr2caMgTHxxIAZgEMd3uLYPDlRvPqCpyeRf6ncPcY=
+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/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1 h1:yY9rWGoXv1U5pl4gxqlULARMQD7x0QG85lqEXTWysik=
github.com/elazarl/goproxy v0.0.0-20190911111923-ecfe977594f1/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
+github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
+github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/evanphx/json-patch v4.5.0+incompatible h1:ouOWdg56aJriqS0huScTkVXPC5IcNrDCXZ6OoTAWu7M=
github.com/evanphx/json-patch v4.5.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/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
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-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg=
+github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
+github.com/go-openapi/jsonreference v0.19.2 h1:o20suLFB4Ri0tuzpWtyHlh7E7HnkqTNLq6aR6WVNS1w=
github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc=
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
+github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc=
github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo=
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY=
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
+github.com/go-sql-driver/mysql v1.4.0 h1:7LxgVwFb2hIQtMm87NdgAVfXjnt4OePseqT1tKx+opk=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
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/gobuffalo/envy v1.7.0 h1:GlXgaiBkmrYMHco6t4j7SacKO4XUjvh5pwXh0f4uxXU=
github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI=
github.com/gobuffalo/logger v1.0.0/go.mod h1:2zbswyIUa45I+c+FLXuWl9zSWEiVuthsk8ze5s8JvPs=
+github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4=
github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q=
+github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg=
github.com/gobuffalo/packr v1.30.1/go.mod h1:ljMyFO2EcrnzsHsN99cvbq055Y9OhRrIaviy289eRuk=
github.com/gobuffalo/packr/v2 v2.5.1/go.mod h1:8f9c96ITobJlPzI44jj+4tHnEKNt0xXWSVlXRN9X1Iw=
+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.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
+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/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@@ -85,26 +124,36 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+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-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
+github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY=
+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=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v1.3.0 h1:tsg9qP3mjt1h4Roxp+M1paRjrVBfPSOpBuVclh6YluI=
github.com/gorilla/handlers v1.3.0/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
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/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
+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-middleware v1.1.0 h1:THDBEeQ9xZ8JEaCLyLQqXMMdRqNr0QAUJTIkQAUtFjg=
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE=
+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/grpc-ecosystem/grpc-gateway v1.11.1 h1:/dBYI+n4xIL+Y9SKXQrjlKTmJJDwCSlNLRwZ5nBhIek=
github.com/grpc-ecosystem/grpc-gateway v1.11.1/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/hashicorp/consul v1.4.0 h1:PQTW4xCuAExEiSbhrsFsikzbW5gVBoi74BjUvYFyKHw=
github.com/hashicorp/consul v1.4.0/go.mod h1:mFrjN1mfidgJfYP1xrJCF+AfRhr6Eaqhb2+sfyn/OOI=
@@ -120,17 +169,25 @@ github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90 h1:VBj0QYQ0
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90/go.mod h1:o4zcYY1e0GEZI6eSEr+43QDYmuGglw1qSO6qdHUHCgg=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
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/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/memberlist v0.1.5/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
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/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
+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/jmoiron/sqlx v1.2.0 h1:41Ip0zITnmWNR/vHV+S4m+VoUivnWY5E4OJfLZjCJMA=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
+github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
+github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@@ -142,23 +199,32 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
+github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0=
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
+github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
+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/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
+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=
@@ -177,41 +243,57 @@ github.com/onap/multicloud-k8s/src/k8splugin v0.0.0-20191115005109-f168ebb73d8d
github.com/onap/multicloud-k8s/src/k8splugin v0.0.0-20191115005109-f168ebb73d8d/go.mod h1:EnQd/vQGZR1/55IihaHxiux4ZUig/zfXZux7bfmU0S8=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
+github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
+github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
+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/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
+github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+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.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
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/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
+github.com/rubenv/sql-migrate v0.0.0-20190902133344-8926f37f0bc1 h1:G7j/gxkXAL80NMLOWi6EEctDET1Iuxl3sBMJXDnu2z0=
github.com/rubenv/sql-migrate v0.0.0-20190902133344-8926f37f0bc1/go.mod h1:WS0rl9eEliYI8DPnr3TOwz4439pay+qNgzJoVya/DmY=
+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/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
+github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
+github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
+github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
+github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -223,29 +305,41 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+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/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
+github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
+github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
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=
+github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
+github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1 h1:j2hhcujLRHAg872RWAV5yaUrEjHEObwDv3aImCaNLek=
github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSfTONNIgpN5RA8prR7fF8nkF6cTWTcNerRO8=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
+go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/etcd v3.3.12+incompatible h1:V6PRYRGpU4k5EajJaaj/GL3hqIdzyPnBU8aPUp+35yw=
go.etcd.io/etcd v3.3.12+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.mongodb.org/mongo-driver v1.0.0 h1:KxPRDyfB2xXnDE2My8acoOWBQkfv3tz0SaWTRZjJR0c=
go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
+go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
+go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
+go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@@ -274,6 +368,7 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -300,6 +395,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -313,6 +409,7 @@ golang.org/x/tools v0.0.0-20190624180213-70d37148ca0c/go.mod h1:/rFqwRUd4F7ZHNgw
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
+google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -322,43 +419,59 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98
google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
+gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
+gopkg.in/gorp.v1 v1.7.2 h1:j3DWlAyGVv8whO7AcIWznQ2Yj7yJkn34B8s63GViAAw=
gopkg.in/gorp.v1 v1.7.2/go.mod h1:Wo3h+DBQZIxATwftsglhdD/62zRFPhGhTiu5jUJmCaw=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
+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/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b h1:aBGgKJUM9Hk/3AE8WaZIApnTxG35kbuQba2w+SXqezo=
k8s.io/api v0.0.0-20190409021203-6e4e0e4f393b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
+k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8 h1:q1Qvjzs/iEdXF6A1a8H3AKVFDzJNcJn3nXMs6R6qFtA=
k8s.io/apiextensions-apiserver v0.0.0-20190409022649-727a075fdec8/go.mod h1:IxkesAMoaCRoLrPJdZNZUQp9NfZnzqaVzLhb2VEQzXE=
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d h1:Jmdtdt1ZnoGfWWIIik61Z7nKYgO3J+swQJtPYsP9wHA=
k8s.io/apimachinery v0.0.0-20190404173353-6a84e37a896d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
+k8s.io/apiserver v0.0.0-20190409021813-1ec86e4da56c h1:k7ALUVzrOEgz4hOF+pr4pePn7TqZ9lB/8Z8ndMSsWSU=
k8s.io/apiserver v0.0.0-20190409021813-1ec86e4da56c/go.mod h1:6bqaTSOSJavUIXUtfaR9Os9JtTCm8ZqH2SUl2S60C4w=
+k8s.io/cli-runtime v0.0.0-20190409023024-d644b00f3b79 h1:bZyxc0wzVA5KgUfAXZA6z872zDWmyslwfvrr175VF68=
k8s.io/cli-runtime v0.0.0-20190409023024-d644b00f3b79/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM=
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible h1:U5Bt+dab9K8qaUmXINrkXO135kA11/i5Kg1RUydgaMQ=
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
+k8s.io/cloud-provider v0.0.0-20190409023720-1bc0c81fa51d h1:ad7UpNUGRx6FbYoK4+xIYyeS2CUShjNKY45YN1ipjLI=
k8s.io/cloud-provider v0.0.0-20190409023720-1bc0c81fa51d/go.mod h1:LlIffnLBu+GG7d4ppPzC8UnA1Ex8S+ntmSRVsnr7Xy4=
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
+k8s.io/helm v2.14.3+incompatible h1:uzotTcZXa/b2SWVoUzM1xiCXVjI38TuxMujS/1s+3Gw=
k8s.io/helm v2.14.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
+k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
+k8s.io/kubernetes v1.14.1 h1:I9F52h5sqVxBmoSsBlNQ0YygNcukDilkpGxUbJRoBoY=
k8s.io/kubernetes v1.14.1/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
+k8s.io/utils v0.0.0-20190907131718-3d4f5b7dea0b h1:eMM0sTvh3KBVGwJfuNcU86P38TJhlVMAICbFPDG3t0M=
k8s.io/utils v0.0.0-20190907131718-3d4f5b7dea0b/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
+sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
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/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/Chart.yaml
new file mode 100644
index 00000000..91a641bd
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/Chart.yaml
new file mode 100644
index 00000000..be3edcef
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subcharta/values.yaml
new file mode 100644
index 00000000..f0381ae6
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/Chart.yaml
new file mode 100644
index 00000000..c3c6bbaf
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/charts/subchartb/values.yaml
new file mode 100644
index 00000000..774fdd75
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt b/src/orchestrator/mock_files/mock_charts/testchart1/templates/NOTES.txt
new file mode 100644
index 00000000..4bdf443f
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/templates/service.yaml
new file mode 100644
index 00000000..e06d19b9
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart1/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart1/values.yaml
new file mode 100644
index 00000000..72d3fa5c
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml
new file mode 100644
index 00000000..f2818e52
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/Chart.yaml
@@ -0,0 +1,4 @@
+apiVersion: v1
+description: A Helm chart for Kubernetes
+name: testchart2
+version: 0.1.0
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/Chart.yaml
new file mode 100644
index 00000000..be3edcef
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subcharta/values.yaml
new file mode 100644
index 00000000..f0381ae6
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/Chart.yaml
new file mode 100644
index 00000000..c3c6bbaf
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/templates/service.yaml
new file mode 100644
index 00000000..fdf75aa9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/charts/subchartb/values.yaml
new file mode 100644
index 00000000..774fdd75
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/delete.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml
new file mode 100644
index 00000000..70efc671
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/delete.yaml
@@ -0,0 +1,22 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: testchart2
+ labels:
+ chart: "testchart2-0.1.0"
+ namespace: "testnamespace"
+ release-name: "testreleasename"
+ release-is-upgrade: "false"
+ release-is-install: "true"
+ kube-version/major: "1"
+ kube-version/minor: "14"
+ kube-version/gitversion: "v1.14.0"
+spec:
+ type: ClusterIP
+ ports:
+ - port: 80
+ targetPort: 80
+ protocol: TCP
+ name: nginx
+ selector:
+ app: testchart2 \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt b/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt
new file mode 100644
index 00000000..4bdf443f
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/templates/NOTES.txt
@@ -0,0 +1 @@
+Sample notes for {{ .Chart.Name }} \ No newline at end of file
diff --git a/src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/templates/service.yaml
new file mode 100644
index 00000000..e06d19b9
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_charts/testchart2/values.yaml b/src/orchestrator/mock_files/mock_charts/testchart2/values.yaml
new file mode 100644
index 00000000..72d3fa5c
--- /dev/null
+++ b/src/orchestrator/mock_files/mock_charts/testchart2/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/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-dest-manifest.yaml
new file mode 100644
index 00000000..8c61a4e4
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-manifest.yaml
new file mode 100644
index 00000000..a123111a
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/faulty-src-manifest.yaml
new file mode 100644
index 00000000..eff534bb
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/manifest.yaml
new file mode 100644
index 00000000..e4beada0
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/override_values.yaml
new file mode 100644
index 00000000..0186c662
--- /dev/null
+++ b/src/orchestrator/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/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml b/src/orchestrator/mock_files/mock_profiles/profile1/subdir/p1.yaml
new file mode 100644
index 00000000..2dad677a
--- /dev/null
+++ b/src/orchestrator/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/src/orchestrator/pkg/appcontext/appcontext.go b/src/orchestrator/pkg/appcontext/appcontext.go
index bad5fa47..d92b1d11 100644
--- a/src/orchestrator/pkg/appcontext/appcontext.go
+++ b/src/orchestrator/pkg/appcontext/appcontext.go
@@ -18,6 +18,8 @@ package appcontext
import (
"fmt"
+ "strings"
+
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/rtcontext"
pkgerrors "github.com/pkg/errors"
)
@@ -160,6 +162,36 @@ func (ac *AppContext) GetClusterHandle(appname string, clustername string) (inte
return nil, pkgerrors.Errorf("No handle was found for the given cluster")
}
+//Returns a list of all clusters for a given app
+func (ac *AppContext) GetClusterNames(appname string) ([]string, error) {
+ if appname == "" {
+ return nil, pkgerrors.Errorf("Not a valid run time context app name")
+ }
+
+ rh, err := ac.rtc.RtcGet()
+ if err != nil {
+ return nil, err
+ }
+
+ prefix := fmt.Sprintf("%v", rh) + "app/" + appname + "/cluster/"
+ hs, err := ac.rtc.RtcGetHandles(prefix)
+ if err != nil {
+ return nil, pkgerrors.Errorf("Error getting handles for %v", prefix)
+ }
+ var cs []string
+ for _, h := range hs {
+ hstr := fmt.Sprintf("%v", h)
+ ks := strings.Split(hstr, prefix)
+ for _, k := range ks {
+ ck := strings.Split(k, "/")
+ if len(ck) == 2 && ck[1] == "" {
+ cs = append(cs, ck[0])
+ }
+ }
+ }
+ return cs, nil
+}
+
//Add resource under app and cluster
func (ac *AppContext) AddResource(handle interface{}, resname string, value interface{}) (interface{}, error) {
h, err := ac.rtc.RtcAddResource(handle, resname, value)
@@ -266,7 +298,7 @@ func (ac *AppContext) GetResourceInstruction(appname string, clustername string,
if err != nil {
return nil, err
}
- s := fmt.Sprintf("%v", rh) + "app/" + appname + "/cluster/" + clustername + "/resource/instruction/" + insttype
+ s := fmt.Sprintf("%v", rh) + "app/" + appname + "/cluster/" + clustername + "/resource/instruction/" + insttype + "/"
var v string
err = ac.rtc.RtcGetValue(s, &v)
if err != nil {
diff --git a/src/orchestrator/pkg/appcontext/appcontext_test.go b/src/orchestrator/pkg/appcontext/appcontext_test.go
index 3fde3a9e..e539ed7a 100644
--- a/src/orchestrator/pkg/appcontext/appcontext_test.go
+++ b/src/orchestrator/pkg/appcontext/appcontext_test.go
@@ -82,7 +82,7 @@ func (c *MockRunTimeContext) RtcDeletePair(handle interface{}) error {
}
func (c *MockRunTimeContext) RtcDeletePrefix(handle interface{}) error {
- for k, _ := range c.Items {
+ for k := range c.Items {
delete(c.Items, k)
}
return c.Err
@@ -91,7 +91,7 @@ func (c *MockRunTimeContext) RtcDeletePrefix(handle interface{}) error {
func (c *MockRunTimeContext) RtcGetHandles(handle interface{}) ([]interface{}, error) {
var keys []interface{}
- for k, _ := range c.Items {
+ for k := range c.Items {
keys = append(keys, string(k))
}
return keys, c.Err
@@ -226,7 +226,7 @@ func TestAddApp(t *testing.T) {
key: "/context/9345674458787728/",
},
{
- label: "Delete returns error case",
+ label: "Error case for adding app",
mockRtcontext: &MockRunTimeContext{Err: pkgerrors.Errorf("Error adding app to run time context:")},
key: "/context/9345674458787728/",
expectedError: "Error adding app to run time context:",
diff --git a/src/orchestrator/pkg/gpic/gpic.go b/src/orchestrator/pkg/gpic/gpic.go
new file mode 100644
index 00000000..f02e5352
--- /dev/null
+++ b/src/orchestrator/pkg/gpic/gpic.go
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2020 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 gpic
+
+/*
+ gpic stands for GenericPlacementIntent Controller.
+ This file pertains to the implementation and handling of generic placement intents
+*/
+
+import (
+ "log"
+ ncmmodule "github.com/onap/multicloud-k8s/src/ncm/pkg/module"
+ pkgerrors "github.com/pkg/errors"
+)
+
+// Clusters has 1 field - a list of ClusterNames
+type Clusters struct {
+ ClustersWithName []ClusterWithName
+}
+
+// ClusterWithName has two fields - ProviderName and ClusterName
+type ClusterWithName struct {
+ ProviderName string
+ ClusterName string
+}
+
+// ClusterWithLabel has two fields - ProviderName and ClusterLabel
+type ClusterWithLabel struct {
+ ProviderName string
+ ClusterLabel string
+}
+
+// IntentStruc consists of AllOfArray and AnyOfArray
+type IntentStruc struct {
+ AllOfArray []AllOf `json:"allOf,omitempty"`
+ AnyOfArray []AnyOf `json:"anyOf,omitempty"`
+}
+
+// AllOf consists if ProviderName, ClusterName, ClusterLabelName and AnyOfArray. Any of them can be empty
+type AllOf struct {
+ ProviderName string `json:"provider-name,omitempty"`
+ ClusterName string `json:"cluster-name,omitempty"`
+ ClusterLabelName string `json:"cluster-label-name,omitempty"`
+ AnyOfArray []AnyOf `json:"anyOf,omitempty"`
+}
+
+// AnyOf consists of Array of ProviderName & ClusterLabelNames
+type AnyOf struct {
+ ProviderName string `json:"provider-name,omitempty"`
+ ClusterName string `json:"cluster-name,omitempty"`
+ ClusterLabelName string `json:"cluster-label-name,omitempty"`
+}
+
+// intentResolverHelper helps to populate the cluster lists
+func intentResolverHelper(pn, cn, cln string, clustersWithName []ClusterWithName) ([]ClusterWithName, error) {
+ if cln == "" && cn != "" {
+ eachClusterWithName := ClusterWithName{pn, cn}
+ clustersWithName = append(clustersWithName, eachClusterWithName)
+ log.Printf("Added Cluster: %s ", cn)
+ }
+ if cn == "" && cln != "" {
+ //Finding cluster names for the clusterlabel
+ clusterNamesList, err := ncmmodule.NewClusterClient().GetClustersWithLabel(pn, cln)
+ if err != nil {
+ return []ClusterWithName{}, pkgerrors.Wrap(err, "Error getting clusterLabels")
+ }
+ // Populate the clustersWithName array with the clusternames found above
+ for _, eachClusterName := range clusterNamesList {
+ eachClusterWithPN := ClusterWithName{pn, eachClusterName}
+ clustersWithName = append(clustersWithName, eachClusterWithPN)
+ log.Printf("Added Cluster: %s ", cln)
+ }
+ }
+ return clustersWithName, nil
+}
+
+// IntentResolver shall help to resolve the given intent into 2 lists of clusters where the app need to be deployed.
+func IntentResolver(intent IntentStruc) (Clusters, error) {
+ var clustersWithName []ClusterWithName
+ var err error
+
+ for _, eachAllOf := range intent.AllOfArray {
+ clustersWithName, err = intentResolverHelper(eachAllOf.ProviderName, eachAllOf.ClusterName, eachAllOf.ClusterLabelName, clustersWithName)
+ if err!=nil {
+ return Clusters{}, pkgerrors.Wrap(err, "intentResolverHelper error")
+ }
+ if len(eachAllOf.AnyOfArray) > 0 {
+ for _, eachAnyOf := range eachAllOf.AnyOfArray {
+ clustersWithName, err = intentResolverHelper(eachAnyOf.ProviderName, eachAnyOf.ClusterName, eachAnyOf.ClusterLabelName, clustersWithName)
+ if err!=nil {
+ return Clusters{}, pkgerrors.Wrap(err, "intentResolverHelper error")
+ }
+ }
+ }
+ }
+ if len(intent.AnyOfArray) > 0 {
+ for _, eachAnyOf := range intent.AnyOfArray {
+ clustersWithName, err = intentResolverHelper(eachAnyOf.ProviderName, eachAnyOf.ClusterName, eachAnyOf.ClusterLabelName, clustersWithName)
+ if err!=nil {
+ return Clusters{}, pkgerrors.Wrap(err, "intentResolverHelper error")
+ }
+ }
+ }
+ clusters := Clusters{clustersWithName}
+ return clusters, nil
+}
diff --git a/src/orchestrator/pkg/infra/contextdb/mock.go b/src/orchestrator/pkg/infra/contextdb/mock.go
index fc0f8ff7..9aaed750 100644
--- a/src/orchestrator/pkg/infra/contextdb/mock.go
+++ b/src/orchestrator/pkg/infra/contextdb/mock.go
@@ -47,7 +47,7 @@ func (c *MockEtcd) Delete(key string) error {
func (c *MockEtcd) GetAllKeys(path string) ([]string, error) {
var keys []string
- for k, _ := range c.Items {
+ for k := range c.Items {
keys = append(keys, string(k))
}
return keys, nil
diff --git a/src/orchestrator/pkg/infra/db/mongo.go b/src/orchestrator/pkg/infra/db/mongo.go
index a344aa1c..a3fdc570 100644
--- a/src/orchestrator/pkg/infra/db/mongo.go
+++ b/src/orchestrator/pkg/infra/db/mongo.go
@@ -49,7 +49,7 @@ type MongoCollection interface {
opts ...*options.FindOptions) (*mongo.Cursor, error)
UpdateOne(ctx context.Context, filter interface{}, update interface{},
opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
- CountDocuments(ctx context.Context, filter interface{},
+ CountDocuments(ctx context.Context, filter interface{},
opts ...*options.CountOptions) (int64, error)
}
@@ -539,9 +539,6 @@ func (m *MongoStore) Find(coll string, key Key, tag string) ([][]byte, error) {
}
result = append(result, data)
}
- if len(result) == 0 {
- return result, pkgerrors.Errorf("Did not find any objects with tag: %s", tag)
- }
return result, nil
}
@@ -588,3 +585,30 @@ func (m *MongoStore) Remove(coll string, key Key) error {
return nil
}
+// RemoveTag is used to remove an element from a document
+func (m *MongoStore) RemoveTag(coll string, key Key, tag string) error {
+ c := getCollection(coll, m)
+ ctx := context.Background()
+
+ filter, err := m.findFilter(key)
+ if err != nil {
+ return err
+ }
+
+ _, err = decodeBytes(
+ c.FindOneAndUpdate(
+ ctx,
+ filter,
+ bson.D{
+ {"$unset", bson.D{
+ {tag, ""},
+ }},
+ },
+ options.FindOneAndUpdate().SetUpsert(true).SetReturnDocument(options.After)))
+
+ if err != nil {
+ return pkgerrors.Errorf("Error removing tag: %s", err.Error())
+ }
+
+ return nil
+}
diff --git a/src/orchestrator/pkg/infra/db/store.go b/src/orchestrator/pkg/infra/db/store.go
index e87722cd..a332fcda 100644
--- a/src/orchestrator/pkg/infra/db/store.go
+++ b/src/orchestrator/pkg/infra/db/store.go
@@ -59,11 +59,14 @@ type Store interface {
// Find the document(s) with key and get the tag values from the document(s)
Find(coll string, key Key, tag string) ([][]byte, error)
- // Removes the document(s) matching the key if no child reference in collection
+ // Removes the document(s) matching the key if no child reference in collection
Remove(coll string, key Key) error
// Remove all the document(s) matching the key
RemoveAll(coll string, key Key) error
+
+ // Remove the specifiec tag from the document matching the key
+ RemoveTag(coll string, key Key, tag string) error
}
// CreateDBClient creates the DB client
diff --git a/src/orchestrator/pkg/infra/validation/validation.go b/src/orchestrator/pkg/infra/validation/validation.go
index d744dc3d..c43d29ec 100644
--- a/src/orchestrator/pkg/infra/validation/validation.go
+++ b/src/orchestrator/pkg/infra/validation/validation.go
@@ -19,9 +19,11 @@ package validation
import (
"archive/tar"
"compress/gzip"
+ "fmt"
"io"
"net"
"regexp"
+ "strconv"
"strings"
pkgerrors "github.com/pkg/errors"
@@ -70,21 +72,37 @@ func IsTarGz(r io.Reader) error {
}
func IsIpv4Cidr(cidr string) error {
- _, _, err := net.ParseCIDR(cidr)
- if err != nil {
- return pkgerrors.Wrapf(err, "could not parse subnet %v", cidr)
+ ip, _, err := net.ParseCIDR(cidr)
+ if err != nil || ip.To4() == nil {
+ return pkgerrors.Wrapf(err, "could not parse ipv4 cidr %v", cidr)
}
return nil
}
-func IsIpv4(ip string) error {
+func IsIp(ip string) error {
addr := net.ParseIP(ip)
if addr == nil {
+ return pkgerrors.Errorf("invalid ip address %v", ip)
+ }
+ return nil
+}
+
+func IsIpv4(ip string) error {
+ addr := net.ParseIP(ip)
+ if addr == nil || addr.To4() == nil {
return pkgerrors.Errorf("invalid ipv4 address %v", ip)
}
return nil
}
+func IsMac(mac string) error {
+ _, err := net.ParseMAC(mac)
+ if err != nil {
+ return pkgerrors.Errorf("invalid MAC address %v", mac)
+ }
+ return nil
+}
+
// default name check - matches valid label value with addtion that length > 0
func IsValidName(name string) []string {
var errs []string
@@ -262,3 +280,44 @@ func IsValidNumber(value, min, max int) []string {
}
return errs
}
+
+func IsValidNumberStr(value string, min, max int) []string {
+ var errs []string
+
+ if min > max {
+ errs = append(errs, "invalid constraints")
+ return errs
+ }
+
+ n, err := strconv.Atoi(value)
+ if err != nil {
+ errs = append(errs, err.Error())
+ return errs
+ }
+ if n < min {
+ errs = append(errs, "value less than minimum")
+ }
+ if n > max {
+ errs = append(errs, "value greater than maximum")
+ }
+ return errs
+}
+
+/*
+IsValidParameterPresent method takes in a vars map and a array of string parameters
+that you expect to be present in the GET request.
+Returns Nil if all the parameters are present or else shall return error message.
+*/
+func IsValidParameterPresent(vars map[string]string, sp []string) error {
+
+ for i := range sp {
+ v := vars[sp[i]]
+ if v == "" {
+ errMessage := fmt.Sprintf("Missing %v in GET request", sp[i])
+ return fmt.Errorf(errMessage)
+ }
+
+ }
+ return nil
+
+}
diff --git a/src/orchestrator/pkg/infra/validation/validation_test.go b/src/orchestrator/pkg/infra/validation/validation_test.go
index 5109b6c7..6a7f504b 100644
--- a/src/orchestrator/pkg/infra/validation/validation_test.go
+++ b/src/orchestrator/pkg/infra/validation/validation_test.go
@@ -185,6 +185,43 @@ func TestIsIpv4(t *testing.T) {
})
}
+func TestIsMac(t *testing.T) {
+ t.Run("Valid MAC", func(t *testing.T) {
+ validmacs := []string{
+ "11:22:33:44:55:66",
+ "ab-cd-ef-12-34-56",
+ "AB-CD-EF-12-34-56",
+ }
+ for _, mac := range validmacs {
+ err := IsMac(mac)
+ if err != nil {
+ t.Errorf("Valid MAC string failed to pass: %v", mac)
+ }
+ }
+ })
+
+ t.Run("Invalid MAC", func(t *testing.T) {
+ invalidmacs := []string{
+ "",
+ "1.2.3.4.5",
+ "1.2.3.45/32",
+ "ab:cd:ef:gh:12:34",
+ "11:22-33-44:55:66",
+ "11,22,33,44,55,66",
+ "11|22|33|44|55|66",
+ "11:22:33:44:55:66:77",
+ "11-22-33-44-55",
+ "11-22-33-44-55-66-77",
+ }
+ for _, mac := range invalidmacs {
+ err := IsMac(mac)
+ if err == nil {
+ t.Errorf("Invalid MAC passed: %v", mac)
+ }
+ }
+ })
+}
+
func TestIsValidString(t *testing.T) {
t.Run("Valid Strings", func(t *testing.T) {
validStrings := []struct {
diff --git a/src/orchestrator/pkg/module/add_intents.go b/src/orchestrator/pkg/module/add_intents.go
index 20fba189..89bf255f 100644
--- a/src/orchestrator/pkg/module/add_intents.go
+++ b/src/orchestrator/pkg/module/add_intents.go
@@ -16,6 +16,11 @@
package module
+/*
+This files deals with the backend implementation of adding
+genericPlacementIntents to deployementIntentGroup
+*/
+
import (
"encoding/json"
"reflect"
@@ -41,12 +46,7 @@ type IntentMetaData struct {
// IntentSpecData has Intent
type IntentSpecData struct {
- Intent IntentObj `json:"intent"`
-}
-
-// IntentObj has name of the generic placement intent
-type IntentObj struct {
- Generic string `json:"generic"`
+ Intent map[string]string `json:"intent"`
}
// ListOfIntents is a list of intents
@@ -58,6 +58,8 @@ type ListOfIntents struct {
type IntentManager interface {
AddIntent(a Intent, p string, ca string, v string, di string) (Intent, error)
GetIntent(i string, p string, ca string, v string, di string) (Intent, error)
+ GetAllIntents(p, ca, v, di string) (ListOfIntents, error)
+ GetIntentByName(i, p, ca, v, di string) (IntentSpecData, error)
DeleteIntent(i string, p string, ca string, v string, di string) error
}
@@ -95,13 +97,16 @@ func NewIntentClient() *IntentClient {
}
}
-// AddIntent adds a given intent to the deployment-intent-group and stores in the db. Other input parameters for it - projectName, compositeAppName, version, DeploymentIntentgroupName
+/*
+AddIntent adds a given intent to the deployment-intent-group and stores in the db.
+Other input parameters for it - projectName, compositeAppName, version, DeploymentIntentgroupName
+*/
func (c *IntentClient) AddIntent(a Intent, p string, ca string, v string, di string) (Intent, error) {
//Check for the AddIntent already exists here.
res, err := c.GetIntent(a.MetaData.Name, p, ca, v, di)
if !reflect.DeepEqual(res, Intent{}) {
- return Intent{}, pkgerrors.New("AppIntent already exists")
+ return Intent{}, pkgerrors.New("Intent already exists")
}
//Check if project exists
@@ -137,7 +142,10 @@ func (c *IntentClient) AddIntent(a Intent, p string, ca string, v string, di str
return a, nil
}
-// GetIntent returns an Intent
+/*
+GetIntent takes in an IntentName, ProjectName, CompositeAppName, Version and DeploymentIntentGroup.
+It returns the Intent.
+*/
func (c *IntentClient) GetIntent(i string, p string, ca string, v string, di string) (Intent, error) {
k := IntentKey{
@@ -150,7 +158,7 @@ func (c *IntentClient) GetIntent(i string, p string, ca string, v string, di str
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
if err != nil {
- return Intent{}, pkgerrors.Wrap(err, "Get AppIntent error")
+ return Intent{}, pkgerrors.Wrap(err, "Get Intent error")
}
if result != nil {
@@ -162,7 +170,66 @@ func (c *IntentClient) GetIntent(i string, p string, ca string, v string, di str
return a, nil
}
- return Intent{}, pkgerrors.New("Error getting AppIntent")
+ return Intent{}, pkgerrors.New("Error getting Intent")
+}
+
+/*
+GetIntentByName takes in IntentName, projectName, CompositeAppName, CompositeAppVersion
+and deploymentIntentGroupName returns the list of intents under the IntentName.
+*/
+func (c IntentClient) GetIntentByName(i string, p string, ca string, v string, di string) (IntentSpecData, error) {
+ k := IntentKey{
+ Name: i,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ DeploymentIntentGroup: di,
+ }
+ result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
+ if err != nil {
+ return IntentSpecData{}, pkgerrors.Wrap(err, "Get AppIntent error")
+ }
+ var a Intent
+ err = db.DBconn.Unmarshal(result[0], &a)
+ if err != nil {
+ return IntentSpecData{}, pkgerrors.Wrap(err, "Unmarshalling Intent")
+ }
+ return a.Spec, nil
+}
+
+/*
+GetAllIntents takes in projectName, CompositeAppName, CompositeAppVersion,
+DeploymentIntentName . It returns ListOfIntents.
+*/
+func (c IntentClient) GetAllIntents(p string, ca string, v string, di string) (ListOfIntents, error) {
+ k := IntentKey{
+ Name: "",
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ DeploymentIntentGroup: di,
+ }
+
+ result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
+ if err != nil {
+ return ListOfIntents{}, pkgerrors.Wrap(err, "Get AppIntent error")
+ }
+ var a Intent
+ var listOfMapOfIntents []map[string]string
+
+ if len(result) != 0 {
+ for i := range result {
+ a = Intent{}
+ err = db.DBconn.Unmarshal(result[i], &a)
+ if err != nil {
+ return ListOfIntents{}, pkgerrors.Wrap(err, "Unmarshalling Intent")
+ }
+ //mapOfIntents := ListOfIntents{a.Spec.Intent.ListOfIntents}
+ listOfMapOfIntents = append(listOfMapOfIntents, a.Spec.Intent)
+ }
+ return ListOfIntents{listOfMapOfIntents}, nil
+ }
+ return ListOfIntents{}, err
}
// DeleteIntent deletes a given intent tied to project, composite app and deployment intent group
@@ -180,5 +247,4 @@ func (c IntentClient) DeleteIntent(i string, p string, ca string, v string, di s
return pkgerrors.Wrap(err, "Delete Project entry;")
}
return nil
-
}
diff --git a/src/orchestrator/pkg/module/app_intent.go b/src/orchestrator/pkg/module/app_intent.go
index a3f4b832..9da252e5 100644
--- a/src/orchestrator/pkg/module/app_intent.go
+++ b/src/orchestrator/pkg/module/app_intent.go
@@ -16,12 +16,17 @@
package module
+/*
+This file deals with the backend implementation of
+Adding/Querying AppIntents for each application in the composite-app
+*/
+
import (
"encoding/json"
"reflect"
+ gpic "github.com/onap/multicloud-k8s/src/orchestrator/pkg/gpic"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
-
pkgerrors "github.com/pkg/errors"
)
@@ -39,29 +44,10 @@ type MetaData struct {
UserData2 string `json:"userData2"`
}
-// AllOf consists of AnyOfArray and ClusterNames array
-type AllOf struct {
- ClusterName string `json:"cluster-name,omitempty"`
- ClusterLabelName string `json:"cluster-label-name,omitempty"`
- AnyOfArray []AnyOf `json:"anyOf,omitempty"`
-}
-
-// AnyOf consists of Array of ClusterLabelNames
-type AnyOf struct {
- ClusterName string `json:"cluster-name,omitempty"`
- ClusterLabelName string `json:"cluster-label-name,omitempty"`
-}
-
-// IntentStruc consists of AllOfArray and AnyOfArray
-type IntentStruc struct {
- AllOfArray []AllOf `json:"allOf,omitempty"`
- AnyOfArray []AnyOf `json:"anyOf,omitempty"`
-}
-
// SpecData consists of appName and intent
type SpecData struct {
- AppName string `json:"app-name"`
- Intent IntentStruc `json:"intent"`
+ AppName string `json:"app-name"`
+ Intent gpic.IntentStruc `json:"intent"`
}
// AppIntentManager is an interface which exposes the
@@ -69,9 +55,16 @@ type SpecData struct {
type AppIntentManager interface {
CreateAppIntent(a AppIntent, p string, ca string, v string, i string) (AppIntent, error)
GetAppIntent(ai string, p string, ca string, v string, i string) (AppIntent, error)
+ GetAllIntentsByApp(aN, p, ca, v, i string) (SpecData, error)
+ GetAllAppIntents(p, ca, v, i string) (ApplicationsAndClusterInfo, error)
DeleteAppIntent(ai string, p string, ca string, v string, i string) error
}
+//AppIntentQueryKey required for query
+type AppIntentQueryKey struct {
+ AppName string `json:"app-name"`
+}
+
// AppIntentKey is used as primary key
type AppIntentKey struct {
Name string `json:"appintent"`
@@ -81,6 +74,28 @@ type AppIntentKey struct {
Intent string `json:"genericplacement"`
}
+// AppIntentFindByAppKey required for query
+type AppIntentFindByAppKey struct {
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+ Intent string `json:"genericplacement"`
+ AppName string `json:"app-name"`
+}
+
+// ApplicationsAndClusterInfo type represents the list of
+type ApplicationsAndClusterInfo struct {
+ ArrayOfAppClusterInfo []AppClusterInfo `json:"applications"`
+}
+
+// AppClusterInfo is a type linking the app and the clusters
+// on which they need to be installed.
+type AppClusterInfo struct {
+ Name string `json:"name"`
+ AllOfArray []gpic.AllOf `json:"allOf,omitempty"`
+ AnyOfArray []gpic.AnyOf `json:"anyOf,omitempty"`
+}
+
// We will use json marshalling to convert to string to
// preserve the underlying structure.
func (ak AppIntentKey) String() string {
@@ -105,7 +120,8 @@ func NewAppIntentClient() *AppIntentClient {
}
}
-// CreateAppIntent creates an entry for AppIntent in the db. Other input parameters for it - projectName, compositeAppName, version, intentName.
+// CreateAppIntent creates an entry for AppIntent in the db.
+// Other input parameters for it - projectName, compositeAppName, version, intentName.
func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v string, i string) (AppIntent, error) {
//Check for the AppIntent already exists here.
@@ -140,7 +156,11 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
Intent: i,
}
- err = db.DBconn.Insert(c.storeName, akey, nil, c.tagMetaData, a)
+ qkey := AppIntentQueryKey{
+ AppName: a.Spec.AppName,
+ }
+
+ err = db.DBconn.Insert(c.storeName, akey, qkey, c.tagMetaData, a)
if err != nil {
return AppIntent{}, pkgerrors.Wrap(err, "Create DB entry error")
}
@@ -176,6 +196,71 @@ func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string,
return AppIntent{}, pkgerrors.New("Error getting AppIntent")
}
+/*
+GetAllIntentsByApp takes in parameters AppName, CompositeAppName, CompositeNameVersion
+and GenericPlacementIntentName. Returns SpecData which contains
+all the intents for the app.
+*/
+func (c *AppIntentClient) GetAllIntentsByApp(aN, p, ca, v, i string) (SpecData, error) {
+ k := AppIntentFindByAppKey{
+ Project: p,
+ CompositeApp: ca,
+ CompositeAppVersion: v,
+ Intent: i,
+ AppName: aN,
+ }
+ result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
+ if err != nil {
+ return SpecData{}, pkgerrors.Wrap(err, "Get AppIntent error")
+ }
+ var a AppIntent
+ err = db.DBconn.Unmarshal(result[0], &a)
+ if err != nil {
+ return SpecData{}, pkgerrors.Wrap(err, "Unmarshalling AppIntent")
+ }
+ return a.Spec, nil
+
+}
+
+/*
+GetAllAppIntents takes in paramaters ProjectName, CompositeAppName, CompositeNameVersion
+and GenericPlacementIntentName. Returns the ApplicationsAndClusterInfo Object - an array of AppClusterInfo
+*/
+func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i string) (ApplicationsAndClusterInfo, error) {
+ k := AppIntentKey{
+ Name: "",
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
+ }
+ result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
+ if err != nil {
+ return ApplicationsAndClusterInfo{}, pkgerrors.Wrap(err, "Get AppClusterInfo error")
+ }
+
+ var a AppIntent
+ var appClusterInfoArray []AppClusterInfo
+
+ if len(result) != 0 {
+ for i := range result {
+ a = AppIntent{}
+ err = db.DBconn.Unmarshal(result[i], &a)
+ if err != nil {
+ return ApplicationsAndClusterInfo{}, pkgerrors.Wrap(err, "Unmarshalling AppIntent")
+ }
+ appName := a.Spec.AppName
+ allOfArray := a.Spec.Intent.AllOfArray
+ anyOfArray := a.Spec.Intent.AnyOfArray
+ appClusterInfo := AppClusterInfo{appName, allOfArray,
+ anyOfArray}
+ appClusterInfoArray = append(appClusterInfoArray, appClusterInfo)
+ }
+ }
+ applicationsAndClusterInfo := ApplicationsAndClusterInfo{appClusterInfoArray}
+ return applicationsAndClusterInfo, err
+}
+
// DeleteAppIntent delete an AppIntent
func (c *AppIntentClient) DeleteAppIntent(ai string, p string, ca string, v string, i string) error {
k := AppIntentKey{
diff --git a/src/orchestrator/pkg/module/app_intent_test.go b/src/orchestrator/pkg/module/app_intent_test.go
index 6cbdf15f..089f09ff 100644
--- a/src/orchestrator/pkg/module/app_intent_test.go
+++ b/src/orchestrator/pkg/module/app_intent_test.go
@@ -21,6 +21,7 @@ import (
"strings"
"testing"
+ gpic "github.com/onap/multicloud-k8s/src/orchestrator/pkg/gpic"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
)
@@ -47,27 +48,31 @@ func TestCreateAppIntent(t *testing.T) {
},
Spec: SpecData{
AppName: "SampleApp",
- Intent: IntentStruc{
- AllOfArray: []AllOf{
+ Intent: gpic.IntentStruc{
+ AllOfArray: []gpic.AllOf{
{
- ClusterName: "edge1",
+ ProviderName: "aws",
+ ClusterName: "edge1",
//ClusterLabelName: "edge1",
},
{
- ClusterName: "edge2",
+ ProviderName: "aws",
+ ClusterName: "edge2",
//ClusterLabelName: "edge2",
},
{
- AnyOfArray: []AnyOf{
- {ClusterLabelName: "east-us1"},
- {ClusterLabelName: "east-us2"},
+ AnyOfArray: []gpic.AnyOf{
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us1"},
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us2"},
//{ClusterName: "east-us1"},
//{ClusterName: "east-us2"},
},
},
},
- AnyOfArray: []AnyOf{},
+ AnyOfArray: []gpic.AnyOf{},
},
},
},
@@ -85,26 +90,30 @@ func TestCreateAppIntent(t *testing.T) {
},
Spec: SpecData{
AppName: "SampleApp",
- Intent: IntentStruc{
- AllOfArray: []AllOf{
+ Intent: gpic.IntentStruc{
+ AllOfArray: []gpic.AllOf{
{
- ClusterName: "edge1",
+ ProviderName: "aws",
+ ClusterName: "edge1",
//ClusterLabelName: "edge1",
},
{
- ClusterName: "edge2",
+ ProviderName: "aws",
+ ClusterName: "edge2",
//ClusterLabelName: "edge2",
},
{
- AnyOfArray: []AnyOf{
- {ClusterLabelName: "east-us1"},
- {ClusterLabelName: "east-us2"},
+ AnyOfArray: []gpic.AnyOf{
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us1"},
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us2"},
//{ClusterName: "east-us1"},
//{ClusterName: "east-us2"},
},
},
},
- AnyOfArray: []AnyOf{},
+ AnyOfArray: []gpic.AnyOf{},
},
},
},
@@ -194,18 +203,22 @@ func TestGetAppIntent(t *testing.T) {
},
Spec: SpecData{
AppName: "SampleApp",
- Intent: IntentStruc{
- AllOfArray: []AllOf{
+ Intent: gpic.IntentStruc{
+ AllOfArray: []gpic.AllOf{
{
- ClusterName: "edge1",
+ ProviderName: "aws",
+ ClusterName: "edge1",
},
{
- ClusterName: "edge2",
+ ProviderName: "aws",
+ ClusterName: "edge2",
},
{
- AnyOfArray: []AnyOf{
- {ClusterLabelName: "east-us1"},
- {ClusterLabelName: "east-us2"},
+ AnyOfArray: []gpic.AnyOf{
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us1"},
+ {ProviderName: "aws",
+ ClusterLabelName: "east-us2"},
},
},
},
@@ -230,13 +243,19 @@ func TestGetAppIntent(t *testing.T) {
"\"spec\":{\"app-name\": \"SampleApp\"," +
"\"intent\": {" +
"\"allOf\":[" +
- "{\"cluster-name\":\"edge1\"}," +
- "{\"cluster-name\":\"edge2\"}," +
+ "{" +
+ "\"provider-name\":\"aws\"," +
+ "\"cluster-name\":\"edge1\"}," +
+ "{" +
+ "\"provider-name\":\"aws\"," +
+ "\"cluster-name\":\"edge2\"}," +
"{" +
"\"anyOf\":[" +
"{" +
+ "\"provider-name\":\"aws\"," +
"\"cluster-label-name\":\"east-us1\"}," +
"{" +
+ "\"provider-name\":\"aws\"," +
"\"cluster-label-name\":\"east-us2\"}" +
"]}]" +
"}}}"),
diff --git a/src/orchestrator/pkg/module/app_profile.go b/src/orchestrator/pkg/module/app_profile.go
index 77835fb4..6600ed24 100644
--- a/src/orchestrator/pkg/module/app_profile.go
+++ b/src/orchestrator/pkg/module/app_profile.go
@@ -122,7 +122,7 @@ func (c *AppProfileClient) CreateAppProfile(project, compositeApp, compositeAppV
//Check if composite profile exists (success assumes existance of all higher level 'parent' objects)
_, err = NewCompositeProfileClient().GetCompositeProfile(compositeProfile, project, compositeApp, compositeAppVersion)
if err != nil {
- return AppProfile{}, pkgerrors.New("Unable to find the project")
+ return AppProfile{}, pkgerrors.New("Unable to find the compositeProfile")
}
// TODO: (after app api is ready) check that the app Spec.AppName exists as part of the composite app
diff --git a/src/orchestrator/pkg/module/composite_profile.go b/src/orchestrator/pkg/module/composite_profile.go
index dca2116a..25a9721c 100644
--- a/src/orchestrator/pkg/module/composite_profile.go
+++ b/src/orchestrator/pkg/module/composite_profile.go
@@ -121,7 +121,7 @@ func (c *CompositeProfileClient) CreateCompositeProfile(cpf CompositeProfile, p
return cpf, nil
}
-// GetCompositeProfile shall take arguments - name of the composite profile, name of //// the project, name of the composite app and version of the composite app. It shall return the CompositeProfile if its present.
+// GetCompositeProfile shall take arguments - name of the composite profile, name of the project, name of the composite app and version of the composite app. It shall return the CompositeProfile if its present.
func (c *CompositeProfileClient) GetCompositeProfile(cpf string, p string, ca string, v string) (CompositeProfile, error) {
key := CompositeProfileKey{
Name: cpf,
@@ -147,7 +147,7 @@ func (c *CompositeProfileClient) GetCompositeProfile(cpf string, p string, ca st
return CompositeProfile{}, pkgerrors.New("Error getting CompositeProfile")
}
-// GetCompositeProfile shall take arguments - name of the composite profile, name of //// the project, name of the composite app and version of the composite app. It shall return the CompositeProfile if its present.
+// GetCompositeProfiles shall take arguments - name of the project, name of the composite profile and version of the composite app. It shall return an array of CompositeProfile.
func (c *CompositeProfileClient) GetCompositeProfiles(p string, ca string, v string) ([]CompositeProfile, error) {
key := CompositeProfileKey{
Name: "",
@@ -175,7 +175,7 @@ func (c *CompositeProfileClient) GetCompositeProfiles(p string, ca string, v str
return resp, nil
}
-// DeleteCompositeProfile the intent from the database
+// DeleteCompositeProfile deletes the compsiteApp profile from the database
func (c *CompositeProfileClient) DeleteCompositeProfile(cpf string, p string, ca string, v string) error {
key := CompositeProfileKey{
Name: cpf,
diff --git a/src/orchestrator/pkg/module/controller.go b/src/orchestrator/pkg/module/controller.go
index 35d6f892..976b8988 100644
--- a/src/orchestrator/pkg/module/controller.go
+++ b/src/orchestrator/pkg/module/controller.go
@@ -27,13 +27,24 @@ import (
// Controller contains the parameters needed for Controllers
// It implements the interface for managing the Controllers
type Controller struct {
- Name string `json:"name"`
-
- Host string `json:"host"`
+ Metadata Metadata `json:"metadata"`
+ Spec ControllerSpec `json:"spec"`
+}
- Port int64 `json:"port"`
+type ControllerSpec struct {
+ Host string `json:"host"`
+ Port int `json:"port"`
+ Type string `json:"type"`
+ Priority int `json:"priority"`
}
+const MinControllerPriority = 1
+const MaxControllerPriority = 1000000
+const CONTROLLER_TYPE_ACTION string = "action"
+const CONTROLLER_TYPE_PLACEMENT string = "placement"
+
+var CONTROLLER_TYPES = [...]string{CONTROLLER_TYPE_ACTION, CONTROLLER_TYPE_PLACEMENT}
+
// ControllerKey is the key structure that is used in the database
type ControllerKey struct {
ControllerName string `json:"controller-name"`
@@ -52,8 +63,9 @@ func (mk ControllerKey) String() string {
// ControllerManager is an interface exposes the Controller functionality
type ControllerManager interface {
- CreateController(ms Controller) (Controller, error)
+ CreateController(ms Controller, mayExist bool) (Controller, error)
GetController(name string) (Controller, error)
+ GetControllers() ([]Controller, error)
DeleteController(name string) error
}
@@ -74,20 +86,20 @@ func NewControllerClient() *ControllerClient {
}
// CreateController a new collection based on the Controller
-func (mc *ControllerClient) CreateController(m Controller) (Controller, error) {
+func (mc *ControllerClient) CreateController(m Controller, mayExist bool) (Controller, error) {
//Construct the composite key to select the entry
key := ControllerKey{
- ControllerName: m.Name,
+ ControllerName: m.Metadata.Name,
}
//Check if this Controller already exists
- _, err := mc.GetController(m.Name)
- if err == nil {
+ _, err := mc.GetController(m.Metadata.Name)
+ if err == nil && !mayExist {
return Controller{}, pkgerrors.New("Controller already exists")
}
- err = db.DBconn.Create(mc.collectionName, key, mc.tagMeta, m)
+ err = db.DBconn.Insert(mc.collectionName, key, nil, mc.tagMeta, m)
if err != nil {
return Controller{}, pkgerrors.Wrap(err, "Creating DB Entry")
}
@@ -102,15 +114,14 @@ func (mc *ControllerClient) GetController(name string) (Controller, error) {
key := ControllerKey{
ControllerName: name,
}
- value, err := db.DBconn.Read(mc.collectionName, key, mc.tagMeta)
+ value, err := db.DBconn.Find(mc.collectionName, key, mc.tagMeta)
if err != nil {
return Controller{}, pkgerrors.Wrap(err, "Get Controller")
}
- //value is a byte array
if value != nil {
microserv := Controller{}
- err = db.DBconn.Unmarshal(value, &microserv)
+ err = db.DBconn.Unmarshal(value[0], &microserv)
if err != nil {
return Controller{}, pkgerrors.Wrap(err, "Unmarshaling Value")
}
@@ -120,6 +131,42 @@ func (mc *ControllerClient) GetController(name string) (Controller, error) {
return Controller{}, pkgerrors.New("Error getting Controller")
}
+// GetControllers returns all the Controllers that are registered
+func (mc *ControllerClient) GetControllers() ([]Controller, error) {
+
+ //Construct the composite key to select the entry
+ key := ControllerKey{
+ ControllerName: "",
+ }
+
+ var resp []Controller
+ values, err := db.DBconn.Find(mc.collectionName, key, mc.tagMeta)
+ if err != nil {
+ return []Controller{}, pkgerrors.Wrap(err, "Get Controller")
+ }
+
+ for _, value := range values {
+ microserv := Controller{}
+ err = db.DBconn.Unmarshal(value, &microserv)
+ if err != nil {
+ return []Controller{}, pkgerrors.Wrap(err, "Unmarshaling Value")
+ }
+
+ // run healthcheck
+ /*
+ err = mc.HealthCheck(microserv.Name)
+ if err != nil {
+ log.Warn("HealthCheck Failed", log.Fields{
+ "Controller": microserv.Name,
+ })
+ }
+ */
+ resp = append(resp, microserv)
+ }
+
+ return resp, nil
+}
+
// DeleteController the Controller from database
func (mc *ControllerClient) DeleteController(name string) error {
@@ -127,7 +174,7 @@ func (mc *ControllerClient) DeleteController(name string) error {
key := ControllerKey{
ControllerName: name,
}
- err := db.DBconn.Delete(name, key, mc.tagMeta)
+ err := db.DBconn.Remove(mc.collectionName, key)
if err != nil {
return pkgerrors.Wrap(err, "Delete Controller Entry;")
}
diff --git a/src/orchestrator/pkg/module/controller_test.go b/src/orchestrator/pkg/module/controller_test.go
index 2e783c13..a13f43a5 100644
--- a/src/orchestrator/pkg/module/controller_test.go
+++ b/src/orchestrator/pkg/module/controller_test.go
@@ -37,14 +37,22 @@ func TestCreateController(t *testing.T) {
{
label: "Create Controller",
inp: Controller{
- Name: "testController",
- Host: "132.156.0.10",
- Port: 8080,
+ Metadata: Metadata{
+ Name: "testController",
+ },
+ Spec: ControllerSpec{
+ Host: "132.156.0.10",
+ Port: 8080,
+ },
},
expected: Controller{
- Name: "testController",
- Host: "132.156.0.10",
- Port: 8080,
+ Metadata: Metadata{
+ Name: "testController",
+ },
+ Spec: ControllerSpec{
+ Host: "132.156.0.10",
+ Port: 8080,
+ },
},
expectedError: "",
mockdb: &db.MockDB{},
@@ -62,7 +70,7 @@ func TestCreateController(t *testing.T) {
t.Run(testCase.label, func(t *testing.T) {
db.DBconn = testCase.mockdb
impl := NewControllerClient()
- got, err := impl.CreateController(testCase.inp)
+ got, err := impl.CreateController(testCase.inp, false)
if err != nil {
if testCase.expectedError == "" {
t.Fatalf("Create returned an unexpected error %s", err)
@@ -94,18 +102,25 @@ func TestGetController(t *testing.T) {
label: "Get Controller",
name: "testController",
expected: Controller{
- Name: "testController",
- Host: "132.156.0.10",
- Port: 8080,
+ Metadata: Metadata{
+ Name: "testController",
+ },
+ Spec: ControllerSpec{
+ Host: "132.156.0.10",
+ Port: 8080,
+ },
},
expectedError: "",
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
ControllerKey{ControllerName: "testController"}.String(): {
"controllermetadata": []byte(
- "{\"name\":\"testController\"," +
+ "{\"metadata\":{" +
+ "\"name\":\"testController\"" +
+ "}," +
+ "\"spec\":{" +
"\"host\":\"132.156.0.10\"," +
- "\"port\":8080}"),
+ "\"port\": 8080 }}"),
},
},
},
diff --git a/src/orchestrator/pkg/module/instantiation.go b/src/orchestrator/pkg/module/instantiation.go
new file mode 100644
index 00000000..56021547
--- /dev/null
+++ b/src/orchestrator/pkg/module/instantiation.go
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2020 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 module
+
+import (
+ "fmt"
+
+ gpic "github.com/onap/multicloud-k8s/src/orchestrator/pkg/gpic"
+
+ "encoding/base64"
+
+ "github.com/onap/multicloud-k8s/src/orchestrator/utils/helm"
+ pkgerrors "github.com/pkg/errors"
+ "log"
+)
+
+// ManifestFileName is the name given to the manifest file in the profile package
+const ManifestFileName = "manifest.yaml"
+
+// GenericPlacementIntentName denotes the generic placement intent name
+const GenericPlacementIntentName = "generic-placement-intent"
+
+// InstantiationClient implements the InstantiationManager
+type InstantiationClient struct {
+ storeName string
+ tagMetaData string
+}
+
+// InstantiationManager is an interface which exposes the
+// InstantiationManager functionalities
+type InstantiationManager interface {
+ //ApproveInstantiation(p string, ca string, v string, di string) (error)
+ Instantiate(p string, ca string, v string, di string) error
+}
+
+// NewInstantiationClient returns an instance of InstantiationClient
+func NewInstantiationClient() *InstantiationClient {
+ return &InstantiationClient{
+ storeName: "orchestrator",
+ tagMetaData: "instantiation",
+ }
+}
+
+// TODO
+//ApproveInstantiation approves an instantiation
+// func (c InstantiationClient) ApproveInstantiation(p string, ca string, v string, di string) (error){
+// }
+
+func getOverrideValuesByAppName(ov []OverrideValues, a string) map[string]string {
+ for _, eachOverrideVal := range ov {
+ if eachOverrideVal.AppName == a {
+ return eachOverrideVal.ValuesObj
+ }
+ }
+ return map[string]string{}
+}
+
+/*
+FindGenericPlacementIntent takes in projectName, CompositeAppName, CompositeAppVersion, DeploymentIntentName
+and returns the name of the genericPlacementIntentName. Returns empty value if string not found.
+*/
+func FindGenericPlacementIntent(p, ca, v, di string) (string, error) {
+ var gi string
+ var found bool
+ iList, err := NewIntentClient().GetAllIntents(p, ca, v, di)
+ if err != nil {
+ return gi, err
+ }
+ for _, eachMap := range iList.ListOfIntents {
+ if gi, found := eachMap[GenericPlacementIntentName]; found {
+ log.Printf("::Name of the generic-placement-intent:: %s", gi)
+ return gi, err
+ }
+ }
+ if found == false {
+ fmt.Println("generic-placement-intent not found !")
+ }
+ return gi, pkgerrors.New("Generic-placement-intent not found")
+
+}
+
+// GetSortedTemplateForApp returns the sorted templates.
+//It takes in arguments - appName, project, compositeAppName, releaseName, compositeProfileName, array of override values
+func GetSortedTemplateForApp(appName, p, ca, v, rName, cp string, overrideValues []OverrideValues) ([]helm.KubernetesResourceTemplate, error) {
+
+ log.Println("Processing App.. ", appName)
+
+ var sortedTemplates []helm.KubernetesResourceTemplate
+
+ aC, err := NewAppClient().GetAppContent(appName, p, ca, v)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, fmt.Sprint("Not finding the content of app:: ", appName))
+ }
+ appContent, err := base64.StdEncoding.DecodeString(aC.FileContent)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Fail to convert to byte array")
+ }
+ log.Println("Got the app content..")
+
+ appPC, err := NewAppProfileClient().GetAppProfileContentByApp(p, ca, v, cp, appName)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, fmt.Sprintf("Not finding the appProfileContent for:: %s", appName))
+ }
+ appProfileContent, err := base64.StdEncoding.DecodeString(appPC.Profile)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Fail to convert to byte array")
+ }
+
+ log.Println("Got the app Profile content ...")
+
+ overrideValuesOfApp := getOverrideValuesByAppName(overrideValues, appName)
+ //Convert override values from map to array of strings of the following format
+ //foo=bar
+ overrideValuesOfAppStr := []string{}
+ if overrideValuesOfApp != nil {
+ for k, v := range overrideValuesOfApp {
+ overrideValuesOfAppStr = append(overrideValuesOfAppStr, k+"="+v)
+ }
+ }
+
+ sortedTemplates, err = helm.NewTemplateClient("", "default", rName,
+ ManifestFileName).Resolve(appContent,
+ appProfileContent, overrideValuesOfAppStr,
+ appName)
+
+ log.Printf("The len of the sortedTemplates :: %d", len(sortedTemplates))
+
+ return sortedTemplates, err
+}
+
+// Instantiate methods takes in project
+func (c InstantiationClient) Instantiate(p string, ca string, v string, di string) error {
+
+ dIGrp, err := NewDeploymentIntentGroupClient().GetDeploymentIntentGroup(di, p, ca, v)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Not finding the deploymentIntentGroup")
+ }
+ rName := dIGrp.Spec.Version //rName is releaseName
+ overrideValues := dIGrp.Spec.OverrideValuesObj
+ cp := dIGrp.Spec.Profile
+
+ gIntent, err := FindGenericPlacementIntent(p, ca, v, di)
+ if err != nil {
+ return err
+ }
+ log.Printf("The name of the GenPlacIntent:: %s", gIntent)
+
+ log.Printf("dIGrp :: %s, releaseName :: %s and cp :: %s \n", dIGrp.MetaData.Name, rName, cp)
+ allApps, err := NewAppClient().GetApps(p, ca, v)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Not finding the apps")
+ }
+ for _, eachApp := range allApps {
+ sortedTemplates, err := GetSortedTemplateForApp(eachApp.Metadata.Name, p, ca, v, rName, cp, overrideValues)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Unable to get the sorted templates for app")
+ }
+ log.Printf("Resolved all the templates for app :: %s under the compositeApp...", eachApp.Metadata.Name)
+ log.Printf("sortedTemplates :: %v ", sortedTemplates)
+
+ specData, err := NewAppIntentClient().GetAllIntentsByApp(eachApp.Metadata.Name, p, ca, v, gIntent)
+ if err != nil {
+ return pkgerrors.Wrap(err, "Unable to get the intents for app")
+ }
+ listOfClusters,err := gpic.IntentResolver(specData.Intent)
+ if err!=nil {
+ return pkgerrors.Wrap(err, "Unable to get the intents resolved for app")
+ }
+ log.Printf("::listOfClusters:: %v", listOfClusters)
+
+ }
+ log.Printf("Done with instantiation...")
+ return err
+}
diff --git a/src/orchestrator/pkg/module/module.go b/src/orchestrator/pkg/module/module.go
index c697bbff..463a55b3 100644
--- a/src/orchestrator/pkg/module/module.go
+++ b/src/orchestrator/pkg/module/module.go
@@ -1,5 +1,5 @@
/*
- * Copyright 2018 Intel Corporation, Inc
+ * Copyright 2020 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.
@@ -16,6 +16,11 @@
package module
+import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ pkgerrors "github.com/pkg/errors"
+)
+
// Client for using the services in the orchestrator
type Client struct {
Project *ProjectClient
@@ -29,6 +34,7 @@ type Client struct {
CompositeProfile *CompositeProfileClient
AppProfile *AppProfileClient
// Add Clients for API's here
+ Instantiation *InstantiationClient
}
// NewClient creates a new client for using the services
@@ -45,5 +51,42 @@ func NewClient() *Client {
c.CompositeProfile = NewCompositeProfileClient()
c.AppProfile = NewAppProfileClient()
// Add Client API handlers here
+ c.Instantiation = NewInstantiationClient()
return c
}
+
+// It implements the interface for managing the ClusterProviders
+const MAX_DESCRIPTION_LEN int = 1024
+const MAX_USERDATA_LEN int = 4096
+
+type Metadata struct {
+ Name string `json:"name" yaml:"name"`
+ Description string `json:"description" yaml:"-"`
+ UserData1 string `json:"userData1" yaml:"-"`
+ UserData2 string `json:"userData2" yaml:"-"`
+}
+
+// Check for valid format Metadata
+func IsValidMetadata(metadata Metadata) error {
+ errs := validation.IsValidName(metadata.Name)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata name=[%v], errors: %v", metadata.Name, errs)
+ }
+
+ errs = validation.IsValidString(metadata.Description, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.Description, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData1, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData1, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData2, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData2, errs)
+ }
+
+ return nil
+}
diff --git a/src/orchestrator/pkg/rtcontext/rtcontext_test.go b/src/orchestrator/pkg/rtcontext/rtcontext_test.go
index e9610ef0..eedbeb82 100644
--- a/src/orchestrator/pkg/rtcontext/rtcontext_test.go
+++ b/src/orchestrator/pkg/rtcontext/rtcontext_test.go
@@ -59,7 +59,7 @@ func (c *MockContextDb) Delete(key string) error {
// Delete all function
func (c *MockContextDb) DeleteAll(key string) error {
- for kvKey, _ := range c.Items {
+ for kvKey := range c.Items {
delete(c.Items, kvKey)
}
return c.Err
@@ -69,7 +69,7 @@ func (c *MockContextDb) DeleteAll(key string) error {
func (c *MockContextDb) GetAllKeys(path string) ([]string, error) {
var keys []string
- for k, _ := range c.Items {
+ for k := range c.Items {
keys = append(keys, string(k))
}
return keys, c.Err
diff --git a/src/orchestrator/utils/helm/helm.go b/src/orchestrator/utils/helm/helm.go
new file mode 100644
index 00000000..80cdfe5a
--- /dev/null
+++ b/src/orchestrator/utils/helm/helm.go
@@ -0,0 +1,331 @@
+/*
+ * Copyright 2020 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 (
+ "bytes"
+ utils "github.com/onap/multicloud-k8s/src/orchestrator/utils"
+
+ pkgerrors "github.com/pkg/errors"
+ "log"
+
+ "fmt"
+ "io/ioutil"
+ "k8s.io/helm/pkg/strvals"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+
+ "github.com/ghodss/yaml"
+ "k8s.io/apimachinery/pkg/runtime/schema"
+ "k8s.io/apimachinery/pkg/runtime/serializer/json"
+ "k8s.io/apimachinery/pkg/util/validation"
+ k8syaml "k8s.io/apimachinery/pkg/util/yaml"
+ "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"
+)
+
+//KubernetesResourceTemplate - Represents the template that is used to create a particular
+//resource in Kubernetes
+type KubernetesResourceTemplate struct {
+ // Tracks the apiVersion and Kind of the resource
+ GVK schema.GroupVersionKind
+ // Path to the file that contains the resource info
+ FilePath string
+}
+
+// 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
+ manifestName string
+}
+
+// NewTemplateClient returns a new instance of TemplateClient
+func NewTemplateClient(k8sversion, namespace, releasename, manifestFileName string) *TemplateClient {
+ return &TemplateClient{
+ whitespaceRegex: regexp.MustCompile(`^\s*$`),
+ // defaultKubeVersion is the default value of --kube-version flag
+ kubeVersion: k8sversion,
+ kubeNameSpace: namespace,
+ releaseName: releasename,
+ manifestName: manifestFileName,
+ }
+}
+
+// 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
+}
+
+// GenerateKubernetesArtifacts a mapping of type to fully evaluated helm template
+func (h *TemplateClient) GenerateKubernetesArtifacts(inputPath string, valueFiles []string,
+ values []string) ([]KubernetesResourceTemplate, error) {
+
+ var outputDir, chartPath, namespace, releaseName string
+ var retData []KubernetesResourceTemplate
+
+ 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")
+ }
+ log.Printf("The o/p dir:: %s ", outputDir)
+
+ 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
+ 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)
+ utils.EnsureDirectory(mfilePath)
+ err = ioutil.WriteFile(mfilePath, []byte(data), 0666)
+ if err != nil {
+ return retData, err
+ }
+
+ gvk, err := getGroupVersionKind(data)
+ if err != nil {
+ return retData, err
+ }
+
+ kres := KubernetesResourceTemplate{
+ GVK: gvk,
+ FilePath: mfilePath,
+ }
+ retData = append(retData, kres)
+ }
+ return retData, nil
+}
+
+func getGroupVersionKind(data string) (schema.GroupVersionKind, error) {
+ out, err := k8syaml.ToJSON([]byte(data))
+ if err != nil {
+ return schema.GroupVersionKind{}, pkgerrors.Wrap(err, "Converting yaml to json")
+ }
+
+ simpleMeta := json.SimpleMetaFactory{}
+ gvk, err := simpleMeta.Interpret(out)
+ if err != nil {
+ return schema.GroupVersionKind{}, pkgerrors.Wrap(err, "Parsing apiversion and kind")
+ }
+
+ return *gvk, nil
+}
+
+// Resolver is an interface exposes the helm related functionalities
+type Resolver interface {
+ Resolve(appContent, appProfileContent []byte, overrideValuesOfAppStr []string, appName string) ([]KubernetesResourceTemplate, error)
+}
+
+// Resolve function
+func (h *TemplateClient) Resolve(appContent []byte, appProfileContent []byte, overrideValuesOfAppStr []string, appName string) ([]KubernetesResourceTemplate, error) {
+
+ var sortedTemplates []KubernetesResourceTemplate
+
+ //chartBasePath is the tmp path where the appContent(rawHelmCharts) is extracted.
+ chartBasePath, err := utils.ExtractTarBall(bytes.NewBuffer(appContent))
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Extracting appContent")
+ }
+ log.Printf("The chartBasePath :: %s", chartBasePath)
+
+ //prPath is the tmp path where the appProfileContent is extracted.
+ prPath, err := utils.ExtractTarBall(bytes.NewBuffer(appProfileContent))
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Extracting Profile Content")
+ }
+ log.Printf("The profile path:: %s", prPath)
+
+ prYamlClient, err := ProcessProfileYaml(prPath, h.manifestName)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Processing Profile Manifest")
+ }
+ log.Println("Got the profileYamlClient..")
+
+ err = prYamlClient.CopyConfigurationOverrides(chartBasePath)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Copying configresources to chart")
+ }
+
+ chartPath := filepath.Join(chartBasePath, appName)
+ sortedTemplates, err = h.GenerateKubernetesArtifacts(chartPath, []string{prYamlClient.GetValues()}, overrideValuesOfAppStr)
+ if err != nil {
+ return sortedTemplates, pkgerrors.Wrap(err, "Generate final k8s yaml")
+ }
+ return sortedTemplates, nil
+}
diff --git a/src/orchestrator/utils/helm/helm_test.go b/src/orchestrator/utils/helm/helm_test.go
new file mode 100644
index 00000000..e9442e8a
--- /dev/null
+++ b/src/orchestrator/utils/helm/helm_test.go
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2020 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/testchart2"
+ 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: "",
+ },
+ {
+ label: "Process complex Pair Override",
+ values: []string{
+ "name={a,b,c}",
+ "servers[0].port=80",
+ },
+ expectedError: "",
+ expectedHash: "50d9401b003f65c1ccfd1c5155106fff88c8201ab8b7d66bd6ffa4fe2883bead",
+ },
+ }
+
+ h := sha256.New()
+
+ for _, testCase := range testCases {
+ t.Run(testCase.label, func(t *testing.T) {
+ tc := NewTemplateClient("1.12.3", "testnamespace", "testreleasename", "manifest.yaml")
+ 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 hash '%s' of values.yaml:\n%s", gotHash, out)
+ }
+ }
+ })
+ }
+}
+
+func TestGenerateKubernetesArtifacts(t *testing.T) {
+
+ chartDir := "../../mock_files/mock_charts/testchart2"
+ 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{
+ "testchart2/templates/service.yaml": "fdd6a2b6795486f0dd1d8c44379afb5ffe4072c09f9cf6594738e8ded4dd872d",
+ "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{
+ "testchart2/templates/service.yaml": "2bb96e791ecb6a3404bc5de3f6c4182aed881630269e2aa6766df38b0f852724",
+ "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", "manifest.yaml")
+ 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 {
+ f := v.FilePath
+ 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/orchestrator/utils/helm/profile_yaml.go b/src/orchestrator/utils/helm/profile_yaml.go
new file mode 100644
index 00000000..e72fdbdc
--- /dev/null
+++ b/src/orchestrator/utils/helm/profile_yaml.go
@@ -0,0 +1,109 @@
+/*
+ * Copyright 2020 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 (
+ "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/orchestrator/utils/utils.go b/src/orchestrator/utils/utils.go
new file mode 100644
index 00000000..13c78ba4
--- /dev/null
+++ b/src/orchestrator/utils/utils.go
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2020 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 utils
+
+import (
+ "archive/tar"
+ "compress/gzip"
+ "io"
+ "io/ioutil"
+ "os"
+ "path"
+ "path/filepath"
+
+ pkgerrors "github.com/pkg/errors"
+)
+
+//ExtractTarBall provides functionality to extract a tar.gz file
+//into a temporary location for later use.
+//It returns the path to the new location
+func ExtractTarBall(r io.Reader) (string, error) {
+ //Check if it is a valid gz
+ gzf, err := gzip.NewReader(r)
+ if err != nil {
+ return "", pkgerrors.Wrap(err, "Invalid gzip format")
+ }
+
+ //Check if it is a valid tar file
+ //Unfortunately this can only be done by inspecting all the tar contents
+ tarR := tar.NewReader(gzf)
+ first := true
+
+ outDir, _ := ioutil.TempDir("", "k8s-ext-")
+
+ for true {
+ header, err := tarR.Next()
+
+ if err == io.EOF {
+ //Check if we have just a gzip file without a tar archive inside
+ if first {
+ return "", pkgerrors.New("Empty or non-existant Tar file found")
+ }
+ //End of archive
+ break
+ }
+
+ if err != nil {
+ return "", pkgerrors.Wrap(err, "Error reading tar file")
+ }
+
+ target := filepath.Join(outDir, header.Name)
+
+ switch header.Typeflag {
+ case tar.TypeDir:
+ if _, err := os.Stat(target); err != nil {
+ // Using 755 read, write, execute for owner
+ // groups and others get read and execute permissions
+ // on the folder.
+ if err := os.MkdirAll(target, 0755); err != nil {
+ return "", pkgerrors.Wrap(err, "Creating directory")
+ }
+ }
+ case tar.TypeReg:
+ if target == outDir { // Handle '.' substituted to '' entry
+ continue
+ }
+
+ err = EnsureDirectory(target)
+ if err != nil {
+ return "", pkgerrors.Wrap(err, "Creating Directory")
+ }
+
+ f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
+ if err != nil {
+ return "", pkgerrors.Wrap(err, "Creating file")
+ }
+
+ // copy over contents
+ if _, err := io.Copy(f, tarR); err != nil {
+ return "", pkgerrors.Wrap(err, "Copying file content")
+ }
+
+ // close for each file instead of a defer for all
+ // at the end of the function
+ f.Close()
+ }
+
+ first = false
+ }
+
+ return outDir, nil
+}
+
+//EnsureDirectory makes sure that the directories specified in the path exist
+//If not, it will create them, if possible.
+func EnsureDirectory(f string) error {
+ base := path.Dir(f)
+ _, err := os.Stat(base)
+ if err != nil && !os.IsNotExist(err) {
+ return err
+ }
+ return os.MkdirAll(base, 0755)
+}