Skip to content

Commit

Permalink
Fix the cluster conditional to choose the endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
asteriscos committed Dec 13, 2023
1 parent f871ede commit e9e500b
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ export const clusterStatusResponse = async (): Promise<boolean> => {
/**
* Get the remote configuration from api
*/
async function getRemoteConfiguration(nodeName: string): Promise<RemoteConfig> {
async function getRemoteConfiguration(
nodeName: string,
clusterStatus: boolean,
): Promise<RemoteConfig> {
let config: RemoteConfig = {
name: nodeName,
isUdp: false,
haveSecureConnection: false,
};

try {
const clusterStatus = await clusterStatusResponse();
let result;
if (clusterStatus) {
result = await WzRequest.apiReq(
Expand Down Expand Up @@ -97,8 +99,8 @@ async function getRemoteConfiguration(nodeName: string): Promise<RemoteConfig> {
* @param node
* @returns
*/
async function getAuthConfiguration(node?: string) {
const authConfigUrl = node
async function getAuthConfiguration(node: string, clusterStatus: boolean) {
const authConfigUrl = clusterStatus
? `/cluster/${node}/configuration/auth/auth`
: '/manager/configuration/auth/auth';
const result = await WzRequest.apiReq('GET', authConfigUrl, {});
Expand Down Expand Up @@ -131,7 +133,11 @@ async function getConnectionConfig(
const nodeIp = nodeSelected?.value;
if (!defaultServerAddress) {
if (nodeSelected.nodetype !== 'custom') {
const remoteConfig = await getRemoteConfiguration(nodeName);
const clusterStatus = await clusterStatusResponse();
const remoteConfig = await getRemoteConfiguration(
nodeName,
clusterStatus,
);
return {
serverAddress: nodeIp,
udpProtocol: remoteConfig.isUdp,
Expand Down Expand Up @@ -232,8 +238,12 @@ export const getMasterNode = (nodeIps: any[]): any[] => {
export const getMasterConfiguration = async () => {
const nodes = await fetchClusterNodesOptions();
const masterNode = getMasterNode(nodes);
const remote = await getRemoteConfiguration(masterNode[0].label);
const auth = await getAuthConfiguration(masterNode[0].label);
const clusterStatus = await clusterStatusResponse();
const remote = await getRemoteConfiguration(
masterNode[0].label,
clusterStatus,
);
const auth = await getAuthConfiguration(masterNode[0].label, clusterStatus);
return {
remote,
auth,
Expand Down

0 comments on commit e9e500b

Please sign in to comment.