@Endpoint('PUT')
@UpdatePermission
# pylint: disable=unused-variable
- def edit_cluster(self, url, cluster_alias, username, verify=False, ssl_certificate=None):
+ def edit_cluster(self, name, url, cluster_alias, username, verify=False, ssl_certificate=None):
multicluster_config = self.load_multi_cluster_config()
if "config" in multicluster_config:
for key, cluster_details in multicluster_config["config"].items():
for cluster in cluster_details:
- if cluster["url"] == url and cluster["user"] == username:
+ if cluster["name"] == name and cluster["user"] == username:
+ cluster['url'] = url
cluster['cluster_alias'] = cluster_alias
cluster['ssl_verify'] = verify
cluster['ssl_certificate'] = ssl_certificate if verify else ''
ngOnInit(): void {
if (this.action === 'edit') {
this.remoteClusterForm.get('remoteClusterUrl').setValue(this.cluster.url);
- this.remoteClusterForm.get('remoteClusterUrl').disable();
this.remoteClusterForm.get('clusterAlias').setValue(this.cluster.cluster_alias);
this.remoteClusterForm.get('ssl').setValue(this.cluster.ssl_verify);
this.remoteClusterForm.get('ssl_cert').setValue(this.cluster.ssl_certificate);
createForm() {
this.remoteClusterForm = new CdFormGroup({
- // showToken: new FormControl(false),
username: new FormControl('', [
CdValidators.custom('uniqueUrlandUser', (username: string) => {
let remoteClusterUrl = '';
);
})
]),
- password: new FormControl('', []),
+ password: new FormControl(
+ null,
+ CdValidators.custom('requiredNotEdit', (value: string) => {
+ return this.action !== 'edit' && !value;
+ })
+ ),
remoteClusterUrl: new FormControl(null, {
validators: [
CdValidators.custom('endpoint', (value: string) => {
Validators.required
]
}),
- // apiToken: new FormControl('', [
- // CdValidators.requiredIf({
- // showToken: true
- // })
- // ]),
clusterAlias: new FormControl(null, {
validators: [
Validators.required,
return (
(this.action === 'connect' || this.action === 'edit') &&
this.clusterAliasNames &&
- this.clusterAliasNames.indexOf(clusterAlias) !== -1
+ this.clusterAliasNames.indexOf(clusterAlias) !== -1 &&
+ this.cluster?.cluster_alias &&
+ this.cluster.cluster_alias !== clusterAlias
);
})
]
case 'edit':
this.subs.add(
this.multiClusterService
- .editCluster(this.cluster.url, clusterAlias, this.cluster.user, ssl, ssl_certificate)
+ .editCluster(
+ this.cluster.name,
+ url,
+ clusterAlias,
+ this.cluster.user,
+ ssl,
+ ssl_certificate
+ )
.subscribe({
...commonSubscribtion,
complete: () => this.handleSuccess($localize`Cluster updated successfully`)