@@ -101,33 +101,36 @@ async function createVM(werft: Werft, config: JobConfig) {
101
101
const cpu = config . withLargeVM ? 12 : 6 ;
102
102
const memory = config . withLargeVM ? 24 : 12 ;
103
103
104
- // set some common vars for TF
105
- // We pass the GCP credentials explicitly, otherwise for some reason TF doesn't pick them up
106
- const commonVars = `GOOGLE_BACKEND_CREDENTIALS=${ GCLOUD_SERVICE_ACCOUNT_PATH } \
107
- GOOGLE_APPLICATION_CREDENTIALS=${ GCLOUD_SERVICE_ACCOUNT_PATH } \
108
- TF_VAR_kubeconfig_path=${ GLOBAL_KUBECONFIG_PATH } \
109
- TF_VAR_preview_name=${ config . previewEnvironment . destname } \
110
- TF_VAR_vm_cpu=${ cpu } \
111
- TF_VAR_vm_memory=${ memory } Gi \
112
- TF_VAR_vm_storage_class="longhorn-gitpod-k3s-202209251218-onereplica"`
104
+ // -replace=... forces recreation of the resource
105
+ const planArgs = config . cleanSlateDeployment ? "-replace=harvester_virtualmachine.harvester" : ""
106
+
107
+ const environment = {
108
+ // We pass the GCP credentials explicitly, otherwise for some reason TF doesn't pick them up
109
+ "GOOGLE_BACKEND_CREDENTIALS" : GCLOUD_SERVICE_ACCOUNT_PATH ,
110
+ "GOOGLE_APPLICATION_CREDENTIALS" : GCLOUD_SERVICE_ACCOUNT_PATH ,
111
+ "TF_VAR_kubeconfig_path" : GLOBAL_KUBECONFIG_PATH ,
112
+ "TF_VAR_preview_name" : config . previewEnvironment . destname ,
113
+ "TF_VAR_vm_cpu" : `${ cpu } ` ,
114
+ "TF_VAR_vm_memory" : `${ memory } Gi` ,
115
+ "TF_VAR_vm_storage_class" : "longhorn-gitpod-k3s-202209251218-onereplica" ,
116
+ "TF_CLI_ARGS_plan" : planArgs
117
+ }
118
+
119
+ const variables = Object
120
+ . entries ( environment )
121
+ . filter ( ( [ _ , value ] ) => value . length > 0 )
122
+ . map ( ( [ key , value ] ) => `${ key } ="${ value } "` )
123
+ . join ( " " )
113
124
114
125
if ( config . cleanSlateDeployment ) {
115
126
werft . log ( prepareSlices . BOOT_VM , "Cleaning previously created VM" ) ;
116
- // -replace=... forces recreation of the resource
117
- await execStream ( `${ commonVars } \
118
- TF_CLI_ARGS_plan="-replace=harvester_virtualmachine.harvester" \
119
- ./dev/preview/workflow/preview/deploy-harvester.sh` ,
120
- { slice : prepareSlices . BOOT_VM }
121
- ) ;
127
+ await execStream ( `${ variables } leeway run dev/preview:create-preview` , { slice : prepareSlices . BOOT_VM } ) ;
122
128
}
123
129
124
130
werft . log ( prepareSlices . BOOT_VM , "Creating VM" ) ;
125
131
126
132
try {
127
- await execStream ( `${ commonVars } \
128
- ./dev/preview/workflow/preview/deploy-harvester.sh` ,
129
- { slice : prepareSlices . BOOT_VM }
130
- ) ;
133
+ await execStream ( `${ variables } leeway run dev/preview:create-preview` , { slice : prepareSlices . BOOT_VM } ) ;
131
134
} catch ( err ) {
132
135
werft . currentPhaseSpan . setAttribute ( "preview.created_vm" , false ) ;
133
136
werft . fail ( prepareSlices . BOOT_VM , new Error ( `Failed creating VM: ${ err } ` ) )
0 commit comments