Skip to content

Commit

Permalink
[RFR] Fixed patching of tackle CR (#680)
Browse files Browse the repository at this point in the history
* Fixed patching of tackle CR

Signed-off-by: Igor Braginsky <[email protected]>

* Align changes with mta_6.2.0

Signed-off-by: Igor Braginsky <[email protected]>

---------

Signed-off-by: Igor Braginsky <[email protected]>
  • Loading branch information
ibragins authored Aug 21, 2023
1 parent d8c4904 commit c843807
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions cypress/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1680,24 +1680,38 @@ export function isRwxEnabled(): boolean {
return Cypress.env("rwx_enabled");
}

export function getUrl(): string {
return window.location.href;
}

export function getNamespace(): string {
// This is regexp pattern to search between first `-` and first `.`
const namespacePattern = /-(.*?)\./;
// First match, means `-`
const match = getUrl().match(namespacePattern);
if (match && match[1]) {
return match[1].toString();
} else {
return "konveyor-tackle";
}
}

// This method is patching
export function configureRWX(isEnabled = true): void {
// Patching CR to set value
let value: string;
let value = "";
if (isEnabled) {
value = "true";
} else {
value = "false";
}
let command = "";
let tackleCr = "tackle=$(oc get tackle --all-namespaces|grep -iv name|awk '{print $2}'); ";
let namespace =
'namespace=$(oc get tackle --all-namespaces|egrep "tackle|mta"|cut -d " " -f 1); ';
let namespace = getNamespace();
let tackleCr = `tackle=$(oc get tackle -n${namespace}|grep -iv name|awk '{print $1}'); `;
command += tackleCr;
command += namespace;
command += "oc patch tackle ";
command += "$tackle ";
command += "-n$namespace ";
command += `-n${namespace} `;
command += "--type merge ";
command += `--patch '{"spec":{"rwx_supported": ${value}}}'`;
cy.log(command);
Expand Down

0 comments on commit c843807

Please sign in to comment.