@@ -79,6 +79,10 @@ type BuildRequest struct {
7979 // State is a pointer to the [config.LibrarianState] struct, representing
8080 // the overall state of the generation and release pipeline.
8181 State * config.LibrarianState
82+
83+ // Image is the name of the docker image to use when running. If not
84+ // specified, uses the default image configured for the client.
85+ Image string
8286}
8387
8488// ConfigureRequest contains all the information required for a language
@@ -106,6 +110,10 @@ type ConfigureRequest struct {
106110 // State is a pointer to the [config.LibrarianState] struct, representing
107111 // the overall state of the generation and release pipeline.
108112 State * config.LibrarianState
113+
114+ // Image is the name of the docker image to use when running. If not
115+ // specified, uses the default image configured for the client.
116+ Image string
109117}
110118
111119// GenerateRequest contains all the information required for a language
@@ -127,6 +135,10 @@ type GenerateRequest struct {
127135 // State is a pointer to the [config.LibrarianState] struct, representing
128136 // the overall state of the generation and release pipeline.
129137 State * config.LibrarianState
138+
139+ // Image is the name of the docker image to use when running. If not
140+ // specified, uses the default image configured for the client.
141+ Image string
130142}
131143
132144// ReleaseStageRequest contains all the information required for a language
@@ -164,6 +176,10 @@ type ReleaseStageRequest struct {
164176 // State is a pointer to the [config.LibrarianState] struct, representing
165177 // the overall state of the generation and release pipeline.
166178 State * config.LibrarianState
179+
180+ // Image is the name of the docker image to use when running. If not
181+ // specified, uses the default image configured for the client.
182+ Image string
167183}
168184
169185// DockerOptions contains optional configuration parameters for invoking
@@ -232,7 +248,9 @@ func (c *Docker) Generate(ctx context.Context, request *GenerateRequest) error {
232248 fmt .Sprintf ("%s:/output" , request .Output ),
233249 fmt .Sprintf ("%s:/source:ro" , request .ApiRoot ), // readonly volume
234250 }
235- return c .runDocker (ctx , CommandGenerate , mounts , commandArgs )
251+
252+ image := c .resolveImage (request .Image )
253+ return c .runDocker (ctx , image , CommandGenerate , mounts , commandArgs )
236254}
237255
238256// Build builds the library with an ID of libraryID, as configured in
@@ -262,7 +280,8 @@ func (c *Docker) Build(ctx context.Context, request *BuildRequest) error {
262280 "--repo=/repo" ,
263281 }
264282
265- return c .runDocker (ctx , CommandBuild , mounts , commandArgs )
283+ image := c .resolveImage (request .Image )
284+ return c .runDocker (ctx , image , CommandBuild , mounts , commandArgs )
266285}
267286
268287// Configure configures an API within a repository, either adding it to an
@@ -307,7 +326,8 @@ func (c *Docker) Configure(ctx context.Context, request *ConfigureRequest) (stri
307326 mounts = append (mounts , fmt .Sprintf ("%s/%s:/repo/%s:ro" , request .RepoDir , globalFile , globalFile ))
308327 }
309328
310- if err := c .runDocker (ctx , CommandConfigure , mounts , commandArgs ); err != nil {
329+ image := c .resolveImage (request .Image )
330+ if err := c .runDocker (ctx , image , CommandConfigure , mounts , commandArgs ); err != nil {
311331 return "" , err
312332 }
313333
@@ -342,14 +362,15 @@ func (c *Docker) ReleaseStage(ctx context.Context, request *ReleaseStageRequest)
342362 fmt .Sprintf ("%s:/output" , request .Output ),
343363 }
344364
345- if err := c .runDocker (ctx , CommandReleaseStage , mounts , commandArgs ); err != nil {
365+ image := c .resolveImage (request .Image )
366+ if err := c .runDocker (ctx , image , CommandReleaseStage , mounts , commandArgs ); err != nil {
346367 return err
347368 }
348369
349370 return nil
350371}
351372
352- func (c * Docker ) runDocker (_ context.Context , command Command , mounts []string , commandArgs []string ) (err error ) {
373+ func (c * Docker ) runDocker (_ context.Context , image string , command Command , mounts []string , commandArgs []string ) (err error ) {
353374 mounts = maybeRelocateMounts (c .HostMount , mounts )
354375 args := []string {
355376 "run" ,
@@ -365,7 +386,7 @@ func (c *Docker) runDocker(_ context.Context, command Command, mounts []string,
365386 args = append (args , "--user" , fmt .Sprintf ("%s:%s" , c .uid , c .gid ))
366387 }
367388
368- args = append (args , c . Image )
389+ args = append (args , image )
369390 args = append (args , string (command ))
370391 args = append (args , commandArgs ... )
371392 return c .run (args ... )
@@ -389,6 +410,13 @@ func maybeRelocateMounts(hostMount string, mounts []string) []string {
389410 return relocatedMounts
390411}
391412
413+ func (c * Docker ) resolveImage (requestedImage string ) string {
414+ if requestedImage != "" {
415+ return requestedImage
416+ }
417+ return c .Image
418+ }
419+
392420func (c * Docker ) runCommand (cmdName string , args ... string ) error {
393421 cmd := exec .Command (cmdName , args ... )
394422 cmd .Stderr = os .Stderr
0 commit comments