diff --git a/bin/periphery/src/api/build/mod.rs b/bin/periphery/src/api/build/mod.rs index 021491b11..ff6ceaa47 100644 --- a/bin/periphery/src/api/build/mod.rs +++ b/bin/periphery/src/api/build/mod.rs @@ -271,7 +271,7 @@ impl Resolve for build::Build { "Pre Build", pre_build_path.as_path(), &pre_build.command, - KomodoCommandMode::Multiline, + if pre_build.shell_mode { KomodoCommandMode::Shell } else { KomodoCommandMode::Multiline }, &replacers, ) .instrument(span) diff --git a/bin/periphery/src/api/compose.rs b/bin/periphery/src/api/compose.rs index 794067b25..22a218a3b 100644 --- a/bin/periphery/src/api/compose.rs +++ b/bin/periphery/src/api/compose.rs @@ -490,7 +490,7 @@ impl Resolve for ComposeUp { "Pre Deploy", pre_deploy_path.as_path(), &stack.config.pre_deploy.command, - KomodoCommandMode::Multiline, + if stack.config.pre_deploy.shell_mode { KomodoCommandMode::Shell } else { KomodoCommandMode::Multiline }, &replacers, ) .instrument(span) @@ -760,7 +760,7 @@ impl Resolve for ComposeUp { "Post Deploy", post_deploy_path.as_path(), &stack.config.post_deploy.command, - KomodoCommandMode::Multiline, + if stack.config.post_deploy.shell_mode { KomodoCommandMode::Shell } else { KomodoCommandMode::Multiline }, &replacers, ) .instrument(span) diff --git a/bin/periphery/src/helpers.rs b/bin/periphery/src/helpers.rs index 623a4331c..4701134d1 100644 --- a/bin/periphery/src/helpers.rs +++ b/bin/periphery/src/helpers.rs @@ -189,7 +189,7 @@ pub async fn handle_post_repo_execution( "On Clone", path.as_path(), on_clone.command, - KomodoCommandMode::Multiline, + if on_clone.shell_mode { KomodoCommandMode::Shell } else { KomodoCommandMode::Multiline }, &replacers, ) .await @@ -214,7 +214,7 @@ pub async fn handle_post_repo_execution( "On Pull", path.as_path(), on_pull.command, - KomodoCommandMode::Multiline, + if on_pull.shell_mode { KomodoCommandMode::Shell } else { KomodoCommandMode::Multiline }, &replacers, ) .await diff --git a/client/core/rs/src/entities/mod.rs b/client/core/rs/src/entities/mod.rs index cf5f817e0..9a9facf7a 100644 --- a/client/core/rs/src/entities/mod.rs +++ b/client/core/rs/src/entities/mod.rs @@ -215,6 +215,8 @@ pub struct SystemCommand { pub path: String, #[serde(default, deserialize_with = "file_contents_deserializer")] pub command: String, + #[serde(default)] + pub shell_mode: bool, } impl SystemCommand { diff --git a/client/core/ts/src/types.ts b/client/core/ts/src/types.ts index 4d4e0d186..7a78b3ed1 100644 --- a/client/core/ts/src/types.ts +++ b/client/core/ts/src/types.ts @@ -611,6 +611,7 @@ export interface ImageRegistryConfig { export interface SystemCommand { path?: string; command?: string; + shell_mode?: boolean; } /** The build configuration. */ diff --git a/ui/public/client/types.d.ts b/ui/public/client/types.d.ts index 4374fb160..fbe2fa368 100644 --- a/ui/public/client/types.d.ts +++ b/ui/public/client/types.d.ts @@ -606,6 +606,7 @@ export interface ImageRegistryConfig { export interface SystemCommand { path?: string; command?: string; + shell_mode?: boolean; } /** The build configuration. */ export interface BuildConfig { diff --git a/ui/src/components/config/system-command.tsx b/ui/src/components/config/system-command.tsx index b6ddfe2ee..bef3bfd4b 100644 --- a/ui/src/components/config/system-command.tsx +++ b/ui/src/components/config/system-command.tsx @@ -1,4 +1,4 @@ -import { Stack, TextInput } from "@mantine/core"; +import { Checkbox, Code, Stack, TextInput } from "@mantine/core"; import { Types } from "komodo_client"; import { MonacoEditor } from "@/components/monaco"; @@ -13,6 +13,9 @@ export default function SystemCommand({ disabled, set, }: SystemCommandProps) { + const placeholder = value?.shell_mode + ? " # Add a command to run.\n " + : " # Add multiple commands on new lines. Supports comments and escaped newlines.\n "; return ( set({ ...(value || {}), path: e.target.value })} disabled={disabled} /> - + Run in shell mode ( + + sh -c + + ){" "} + + } + checked={value?.shell_mode ?? false} + onChange={(e) => + set({ + ...(value || {}), + shell_mode: e.currentTarget.checked, + }) } + disabled={disabled} + /> + set({ ...(value || {}), command })} readOnly={disabled}