Skip to content

Commit 4aa12ed

Browse files
committed
Add CODE_SNIPPET_URL to config
Signed-off-by: ddl-rliu <richard.liu@dominodatalab.com>
1 parent 7636e32 commit 4aa12ed

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

packages/common/src/environment/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ export interface Env extends NodeJS.ProcessEnv {
3333
* @example MAINTENANCE_MODE="We are currently down for maintenance.\n\nPlease try again later."
3434
*/
3535
MAINTENANCE_MODE?: string;
36+
37+
/**
38+
* Controls the endpoint used in Python code snippet, leave unset to use the default window.location.host
39+
*/
40+
CODE_SNIPPET_URL?: string;
3641
}
3742

3843
/** Represents a plain object where string keys map to values of the same type */

packages/oss-console/src/components/Executions/ExecutionDetails/ExecutionNodeURL.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Grid from '@mui/material/Grid';
1111
import Link from '@mui/material/Link';
1212
import { RowExpander } from '../Tables/RowExpander';
1313
import { ScrollableMonospaceText } from '../../common/ScrollableMonospaceText';
14+
import { env } from '@clients/common/environment';
1415

1516
const StyledScrollableMonospaceText = styled(ScrollableMonospaceText)(({ theme }) => ({
1617
'&>div': {
@@ -28,22 +29,23 @@ export const ExecutionNodeURL: React.FC<{
2829
copyUrlText: string;
2930
}> = ({ dataSourceURI, copyUrlText }) => {
3031
const [expanded, setExpanded] = React.useState<boolean>(false);
31-
const isHttps = /^https:/.test(window.location.href);
32+
const codeSnippetUrl = new URL(env.CODE_SNIPPET_URL || window.location.href);
33+
const isHttps = /^https:/.test(codeSnippetUrl.protocol);
3234
const ref = React.useRef<HTMLDivElement>(null);
3335

3436
const code = isHttps
3537
? // https snippet
3638
`from flytekit.remote.remote import FlyteRemote
3739
from flytekit.configuration import Config
3840
remote = FlyteRemote(
39-
Config.for_endpoint("${window.location.host}"),
41+
Config.for_endpoint("${codeSnippetUrl.host}"),
4042
)
4143
remote.get("${dataSourceURI}")`
4244
: // http snippet
4345
`from flytekit.remote.remote import FlyteRemote
4446
from flytekit.configuration import Config
4547
remote = FlyteRemote(
46-
Config.for_endpoint("${window.location.host}", True),
48+
Config.for_endpoint("${codeSnippetUrl.host}", True),
4749
)
4850
remote.get("${dataSourceURI}")`;
4951

website/console/env/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ const ASSETS_PATH = `${BASE_URL}/assets/`;
7777
*/
7878
const MAINTENANCE_MODE = process.env.MAINTENANCE_MODE || '';
7979

80+
/**
81+
* Controls the endpoint used in Python code snippet
82+
*/
83+
const CODE_SNIPPET_URL = process.env.CODE_SNIPPET_URL || '';
84+
8085
const processEnv = {
8186
NODE_ENV,
8287
PORT,
@@ -86,6 +91,7 @@ const processEnv = {
8691
BASE_HREF,
8792
DISABLE_CONSOLE_ROUTE_PREFIX,
8893
MAINTENANCE_MODE,
94+
CODE_SNIPPET_URL,
8995
};
9096

9197
export {
@@ -101,5 +107,6 @@ export {
101107
ADMIN_API,
102108
LOCAL_DEV_HOST,
103109
MAINTENANCE_MODE,
110+
CODE_SNIPPET_URL,
104111
processEnv,
105112
};

0 commit comments

Comments
 (0)