@@ -8,7 +8,8 @@ import { inspect } from 'util'
88import { DeploymentMachine , ResourceType , StatefulSetMachine , k8sObjectToMachine } from './common.js'
99import { clientFromConfiguration , listMachines , machineConnection , flags as machineDriverFlags , parseRfc1123Flag } from './driver.js'
1010import { Client , CreationClient , kubeCreationClient , loadKubeConfig } from './client/index.js'
11- import { DEFAULT_TEMPLATE , packageJson } from '../static.js'
11+ import { DEFAULT_TEMPLATE , packageJsonPath } from '../static.js'
12+ import { Package } from './client/common.js'
1213
1314export const flags = {
1415 ...machineDriverFlags ,
@@ -103,6 +104,14 @@ const machineCreationDriver = (
103104
104105type FlagTypes = Omit < Interfaces . InferredFlags < typeof flags > , 'json' >
105106
107+ const tryReadPackage = async ( ) : Promise < Package | undefined > => {
108+ try {
109+ return JSON . parse ( await fs . promises . readFile ( packageJsonPath , 'utf-8' ) )
110+ } catch ( e ) {
111+ return undefined
112+ }
113+ }
114+
106115const creationClientFromConfiguration = ( { flags : f , profileId, log, kc } : {
107116 flags : FlagTypes
108117 profileId : string
@@ -113,7 +122,7 @@ const creationClientFromConfiguration = ({ flags: f, profileId, log, kc }: {
113122 namespace : f . namespace ,
114123 kc,
115124 profileId,
116- package : packageJson ,
125+ package : tryReadPackage ( ) ,
117126 template : fs . readFileSync ( f . template || DEFAULT_TEMPLATE , 'utf-8' ) ,
118127 storageClass : f [ 'storage-class' ] ,
119128 storageSize : f [ 'storage-size' ] ,
0 commit comments