Skip to content

Commit 68b8cd1

Browse files
feat: extract image name to derived emulator config (#488)
Signed-off-by: David Dal Busco <[email protected]>
1 parent 0c290ba commit 68b8cd1

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/configs/emulator.config.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as z from 'zod';
44
import {DEPLOY_LOCAL_REPLICA_PATH} from '../constants/dev.constants';
55
import {EMULATOR_SKYLAB} from '../constants/emulator.constants';
66
import {ENV} from '../env';
7-
import type {CliEmulatorConfig} from '../types/emulator';
7+
import {type CliEmulatorConfig} from '../types/emulator';
88
import {readPackageJson} from '../utils/pkg.utils';
99
import {junoConfigExist, readJunoConfig} from './juno.config';
1010

@@ -45,6 +45,8 @@ export const readEmulatorConfig = async (): Promise<
4545
`${hostname}:${destination}`
4646
);
4747

48+
const image = config.runner?.image ?? `junobuild/${emulatorType}:latest`;
49+
4850
return {
4951
success: true,
5052
config: {
@@ -54,7 +56,8 @@ export const readEmulatorConfig = async (): Promise<
5456
emulatorType,
5557
runner,
5658
targetDeploy,
57-
extraHosts
59+
extraHosts,
60+
image
5861
}
5962
}
6063
};

src/services/emulator/_runner.services.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const initConfigFile = async () => {
151151
const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfig}) => {
152152
const {
153153
config,
154-
derivedConfig: {emulatorType, containerName, runner, targetDeploy, extraHosts}
154+
derivedConfig: {emulatorType, containerName, runner, targetDeploy, extraHosts, image}
155155
} = extendedConfig;
156156

157157
const {running} = await assertContainerRunning({containerName, runner});
@@ -217,8 +217,6 @@ const startEmulator = async ({config: extendedConfig}: {config: CliEmulatorConfi
217217
// Podman does not auto create the path folders.
218218
await createDeployTargetDir({targetDeploy});
219219

220-
const image = config.runner?.image ?? `junobuild/${emulatorType}:latest`;
221-
222220
const platform = config.runner?.platform;
223221

224222
await execute({

src/types/emulator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ export type EmulatorRunnerType = EmulatorRunner['type'];
66

77
export type EmulatorConfigWithoutConsole = Exclude<EmulatorConfig, {console: EmulatorConsole}>;
88

9+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
10+
export type EmulatorImage = `junobuild/${EmulatorType}:latest` | string;
11+
912
export interface CliEmulatorDerivedConfig {
1013
containerName: string;
1114
runner: EmulatorRunnerType;
1215
emulatorType: EmulatorType;
1316
targetDeploy: string;
1417
extraHosts: string[];
18+
image: EmulatorImage;
1519
}
1620

1721
export interface CliEmulatorConfig {

0 commit comments

Comments
 (0)