mirror of https://github.com/rancher/dashboard.git
Switch alertmanagerconfig to use dispatch with { root:true }
The utility was broken in prod due to the function names changing. Instead of trying to differentiate the dispatch method being used we just set the { root:true } config so we can always use the 'cluster/action'.
https://github.com/rancher/dashboard/issues/1238#issuecomment-719730626
This commit is contained in:
parent
c2a4ca65e9
commit
cf83a76900
|
|
@ -11,9 +11,7 @@ const ALERTMANAGER_ID = 'cattle-monitoring-system/rancher-monitoring-alertmanage
|
||||||
export const FILENAME = 'alertmanager.yaml';
|
export const FILENAME = 'alertmanager.yaml';
|
||||||
|
|
||||||
export async function getSecretId(dispatch) {
|
export async function getSecretId(dispatch) {
|
||||||
const isLocal = dispatch.name === 'boundDispatch';
|
const alertManager = await dispatch('cluster/find', { type: MONITORING.ALERTMANAGER, id: ALERTMANAGER_ID }, { root: true });
|
||||||
const action = isLocal ? 'cluster/find' : 'find';
|
|
||||||
const alertManager = await dispatch(action, { type: MONITORING.ALERTMANAGER, id: ALERTMANAGER_ID });
|
|
||||||
|
|
||||||
return alertManager?.spec?.configSecret || DEFAULT_SECRET_ID;
|
return alertManager?.spec?.configSecret || DEFAULT_SECRET_ID;
|
||||||
}
|
}
|
||||||
|
|
@ -22,13 +20,10 @@ export async function getSecret(dispatch) {
|
||||||
const secretId = await getSecretId(dispatch, false);
|
const secretId = await getSecretId(dispatch, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const isLocal = dispatch.name === 'boundDispatch';
|
return await dispatch('cluster/find', { type: SECRET, id: secretId }, { root: true });
|
||||||
const action = isLocal ? 'cluster/find' : 'find';
|
|
||||||
|
|
||||||
return await dispatch(action, { type: SECRET, id: secretId });
|
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
const [namespace, name] = secretId.split('/');
|
const [namespace, name] = secretId.split('/');
|
||||||
const secret = await dispatch('create', { type: SECRET });
|
const secret = await dispatch('cluster/create', { type: SECRET }, { root: true });
|
||||||
|
|
||||||
secret.metadata = {
|
secret.metadata = {
|
||||||
namespace,
|
namespace,
|
||||||
|
|
@ -86,7 +81,7 @@ export async function updateConfig(dispatch, path, type, updateFn) {
|
||||||
secret.data[FILENAME] = encodedFile;
|
secret.data[FILENAME] = encodedFile;
|
||||||
await secret.save();
|
await secret.save();
|
||||||
// Force a store update
|
// Force a store update
|
||||||
await dispatch('findAll', { type, opt: { force: true } });
|
await dispatch('cluster/findAll', { type, opt: { force: true } }, { root: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAllReceivers(dispatch) {
|
export async function getAllReceivers(dispatch) {
|
||||||
|
|
@ -99,7 +94,7 @@ export async function getAllReceivers(dispatch) {
|
||||||
spec: receiver,
|
spec: receiver,
|
||||||
type: MONITORING.SPOOFED.RECEIVER,
|
type: MONITORING.SPOOFED.RECEIVER,
|
||||||
secret
|
secret
|
||||||
}));
|
}, { root: true }));
|
||||||
|
|
||||||
return Promise.all(mapped);
|
return Promise.all(mapped);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
@ -123,7 +118,7 @@ export async function getAllRoutes(dispatch) {
|
||||||
spec: route,
|
spec: route,
|
||||||
type: MONITORING.SPOOFED.ROUTE,
|
type: MONITORING.SPOOFED.ROUTE,
|
||||||
secret
|
secret
|
||||||
}));
|
}, { root: true }));
|
||||||
|
|
||||||
return Promise.all(mapped);
|
return Promise.all(mapped);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue