1+ import * as fs from 'fs' ;
12import { exec } from "../../../util/shell" ;
23import { Werft } from "../../../util/werft" ;
34import { getNodePoolIndex } from "../deploy-to-preview-environment" ;
5+ import { renderPayment } from "../payment/render" ;
46
57const BLOCK_NEW_USER_CONFIG_PATH = './blockNewUsers' ;
68const WORKSPACE_SIZE_CONFIG_PATH = './workspaceSizing' ;
@@ -34,6 +36,7 @@ export type InstallerOptions = {
3436 workspaceFeatureFlags : string [ ]
3537 gitpodDaemonsetPorts : GitpodDaemonsetPorts
3638 smithToken : string
39+ withPayment : boolean
3740}
3841
3942export class Installer {
@@ -69,6 +72,12 @@ export class Installer {
6972 } else {
7073 this . dontIncludeAnalytics ( slice )
7174 }
75+
76+ if ( this . options . withPayment ) {
77+ // let installer know that there is a chargbee config
78+ exec ( `yq w -i ${ this . options . installerConfigPath } experimental.webapp.server.chargebeeSecret chargebee-config` , { slice : slice } ) ;
79+ }
80+
7281 } catch ( err ) {
7382 throw new Error ( err )
7483 }
@@ -176,6 +185,7 @@ export class Installer {
176185
177186 this . configureLicense ( slice )
178187 this . configureWorkspaceFeatureFlags ( slice )
188+ this . configurePayment ( slice )
179189 this . process ( slice )
180190
181191 this . options . werft . done ( slice )
@@ -200,7 +210,26 @@ export class Installer {
200210 } )
201211 // post-process.sh looks for /tmp/defaultFeatureFlags
202212 // each "flag" string gets added to the configmap
213+ // also watches aout for /tmp/payment
214+ }
215+ }
216+
217+ private configurePayment ( slice : string ) : void {
218+ // 1. Read versions from docker image
219+ this . options . werft . log ( slice , "configuring withPayment..." ) ;
220+ try {
221+ exec ( `docker run --rm eu.gcr.io/gitpod-core-dev/build/versions:${ this . options . version } cat /versions.yaml > versions.yaml` ) ;
222+ } catch ( err ) {
223+ this . options . werft . fail ( slice , err ) ;
203224 }
225+ const serviceWaiterVersion = exec ( "yq r ./versions.yaml 'components.serviceWaiter.version'" ) . stdout . toString ( ) . trim ( ) ;
226+ const paymentEndpointVersion = exec ( "yq r ./versions.yaml 'components.paymentEndpoint.version'" ) . stdout . toString ( ) . trim ( ) ;
227+
228+ // 2. render chargebee-config and payment-endpoint
229+ const paymentYamls = renderPayment ( this . options . deploymentNamespace , paymentEndpointVersion , serviceWaiterVersion ) ;
230+ fs . writeFileSync ( "/tmp/payment" , paymentYamls ) ;
231+
232+ this . options . werft . log ( slice , "done configuring withPayment." ) ;
204233 }
205234
206235 private process ( slice : string ) : void {
0 commit comments