Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFR] Fixed patching of tackle CR #680

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading