Feature 10904: Make all deployment methods optional for K8s cluster
Change-Id: Ifd7f83f35cef767479508e1ae364a076661813f0
Signed-off-by: bacigalupo <tbacigalupo@whitestack.com>
diff --git a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
index 84f2150..f06d098 100644
--- a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
+++ b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
@@ -50,6 +50,18 @@
</div>
</div>
<div class="form-group row">
+ <label class="col-sm-4 col-form-label" for="deployment_methods">{{'PAGE.K8S.DEPLOYMENTMETHODS' | translate}}*</label>
+ <div class="col-sm-8">
+ <ng-select placeholder="{{'SELECT' | translate}} {{'PAGE.K8S.DEPLOYMENTMETHODS' | translate}}"
+ multiple="true"
+ [items]="deploymentMethodsSelect" bindLabel="title" bindValue="value" formControlName="deployment_methods" id="deploymentMethodsId"
+ [ngClass]="{ 'is-invalid': submitted && f.deployment_methods.errors }"
+ [(ngModel)]="selectedDeploymentMethods"
+ required>
+ </ng-select>
+ </div>
+ </div>
+ <div class="form-group row">
<label class="col-sm-4 col-form-label" for="description">{{'PAGE.K8S.DESCRIPTION' | translate}}*</label>
<div class="col-sm-8">
<textarea class="form-control" placeholder="{{'PAGE.K8S.DESCRIPTION' | translate}}" type="text"
diff --git a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
index 0295b35..aa33193 100644
--- a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
+++ b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
@@ -24,7 +24,7 @@
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { TranslateService } from '@ngx-translate/core';
import { NotifierService } from 'angular-notifier';
-import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA } from 'CommonModel';
+import { APIURLHEADER, ERRORDATA, MODALCLOSERESPONSEDATA, TYPESECTION } from 'CommonModel';
import { environment } from 'environment';
import * as jsyaml from 'js-yaml';
import { RestService } from 'RestService';
@@ -51,6 +51,15 @@
/** Contains all vim account collections */
public vimAccountSelect: VimAccountDetails;
+ /** Contains all deployment methods */
+ public deploymentMethodsSelect: TYPESECTION[] = [];
+
+ /** Submited deployments methods format */
+ public deploymentMethodsSubmit: Map<string, boolean>;
+
+ /** Contains all deployment methods selected */
+ public selectedDeploymentMethods: string[] = ['helm-chart-v2', 'helm-chart-v3', 'juju-bundle'];
+
/** Instance for active modal service @public */
public activeModal: NgbActiveModal;
@@ -104,6 +113,20 @@
this.notifierService = this.injector.get(NotifierService);
this.translateService = this.injector.get(TranslateService);
this.sharedService = this.injector.get(SharedService);
+ this.deploymentMethodsSelect = [
+ {
+ title: 'Helm v2',
+ value: 'helm-chart-v2'
+ },
+ {
+ title: 'Helm v3',
+ value: 'helm-chart-v3'
+ },
+ {
+ title: 'Juju bundle',
+ value: 'juju-bundle'
+ }
+ ];
}
public ngOnInit(): void {
@@ -125,6 +148,7 @@
vim_account: [null, [Validators.required]],
description: ['', [Validators.required]],
nets: ['', [Validators.required]],
+ deployment_methods: ['', [Validators.required]],
credentials: ['', [Validators.required]]
});
}
@@ -172,6 +196,25 @@
this.notifierService.notify('error', this.translateService.instant('INVALIDCONFIG'));
return;
}
+
+ this.deploymentMethodsSubmit = new Map<string, boolean>();
+ /// Set deployment method Map
+ for (const methods of this.deploymentMethodsSelect) {
+ this.deploymentMethodsSubmit.set(methods.value, false);
+ }
+
+ this.k8sclusterForm.value.deployment_methods.forEach((dm: string): void => {
+ this.deploymentMethodsSubmit.set(dm, true);
+ });
+ // Transform Map to json object
+ const jsonDMObject: {} = {};
+ this.deploymentMethodsSubmit.forEach((value: boolean, key: string): void => {
+ jsonDMObject[key] = value;
+ });
+
+ // Transform values to json
+ this.k8sclusterForm.value.deployment_methods = jsonDMObject;
+
this.isLoadingResults = true;
this.restService.postResource(apiURLHeader, this.k8sclusterForm.value).subscribe((result: {}) => {
this.activeModal.close(modalData);
diff --git a/src/assets/i18n/de.json b/src/assets/i18n/de.json
index 75c1683..9fa8bd4 100644
--- a/src/assets/i18n/de.json
+++ b/src/assets/i18n/de.json
@@ -453,6 +453,7 @@
"K8SVERSION": "K8s-versie",
"VIMACCOUNT": "Vim-account",
"DESCRIPTION": "Beschrijving",
+ "DEPLOYMENTMETHODS": "Bereitstellungsmethoden",
"NETS": "Nets",
"NETSPLACEHOLDER": "example: {'net1': 'osm-ext'}",
"CREDENTIALS": "Inloggegevens",
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json
index 882029d..6f00d56 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/en.json
@@ -453,6 +453,7 @@
"K8SVERSION": "K8s Version",
"VIMACCOUNT": "Vim Account",
"DESCRIPTION": "Description",
+ "DEPLOYMENTMETHODS": "Deployment methods",
"NETS": "Nets",
"NETSPLACEHOLDER": "example: {'net1': 'osm-ext'}",
"CREDENTIALS": "Credentials",
diff --git a/src/assets/i18n/es.json b/src/assets/i18n/es.json
index 65e4167..6c49608 100644
--- a/src/assets/i18n/es.json
+++ b/src/assets/i18n/es.json
@@ -453,6 +453,7 @@
"K8SVERSION": "Versión K8s",
"VIMACCOUNT": "Cuenta Vim",
"DESCRIPTION": "Descripción",
+ "DEPLOYMENTMETHODS": "Métodos de despliegue",
"NETS": "Redes",
"NETSPLACEHOLDER": "example: {'net1': 'osm-ext'}",
"CREDENTIALS": "Credenciales",
diff --git a/src/assets/i18n/pt.json b/src/assets/i18n/pt.json
index c4c4e4f..03b698f 100644
--- a/src/assets/i18n/pt.json
+++ b/src/assets/i18n/pt.json
@@ -453,6 +453,7 @@
"K8SVERSION": "Versão do K8s",
"VIMACCOUNT": "Conta Vim",
"DESCRIPTION": "Descrição",
+ "DEPLOYMENTMETHODS": "Métodos de implantação",
"NETS": "Nets",
"NETSPLACEHOLDER": "example: {'net1': 'osm-ext'}",
"CREDENTIALS": "Credenciais",