MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / getCurrentStack

Function getCurrentStack

console/src/config/currentStack.ts:41–85  ·  view source on GitHub ↗
({
  hostname,
  isBrowser,
  defaultStack = buildConstants.defaultStack,
}: {
  hostname: string;
  isBrowser: boolean;
  defaultStack?: string;
})

Source from the content-addressed store, hash-verified

39 * kind - Local cloud stack running in kind
40 */
41export const getCurrentStack = ({
42 hostname,
43 isBrowser,
44 defaultStack = buildConstants.defaultStack,
45}: {
46 hostname: string;
47 isBrowser: boolean;
48 defaultStack?: string;
49}) => {
50 if (!isBrowser) return getE2eTestStack(hostname);
51
52 if (buildConstants.forceOverrideStack) {
53 return buildConstants.forceOverrideStack;
54 }
55 if (storageAvailable("localStorage")) {
56 const stack = window.localStorage.getItem(CURRENT_STACK_KEY);
57 if (stack) {
58 return stack;
59 }
60 }
61 if (
62 hostname.startsWith("staging.") ||
63 hostname.startsWith("oidc-test.") ||
64 hostname.startsWith("local.console") ||
65 hostname.match(/^.*\.preview/)
66 ) {
67 // matches staging.console.materialize.com
68 // or oid-test.console.materialize.com
69 // or local.console.materialize.com
70 // or *.preview.console.materialize.com
71 return "staging";
72 }
73 if (hostname.startsWith("loadtest.")) {
74 return "loadtest";
75 }
76 if (hostname.startsWith("local.dev.")) {
77 return defaultStack;
78 }
79 const personalStackMatch = hostname.match(/^\w*\.(staging|dev)/);
80 if (personalStackMatch) {
81 // personal stack, return $USER.$ENV
82 return personalStackMatch[0];
83 }
84 return defaultStack;
85};
86
87export const setCurrentStack = (stackName: string) => {
88 if (storageAvailable("localStorage")) {

Callers 3

SwitchStackModalContentFunction · 0.90
CloudAppConfigClass · 0.90

Calls 2

getE2eTestStackFunction · 0.85
storageAvailableFunction · 0.85

Tested by

no test coverage detected