Skip to content

Commit

Permalink
fix: add skip_workspace boolean parameter to stage.*.container.skip_w…
Browse files Browse the repository at this point in the history
…orkspace

allows you to skip mounting the workspace directory on every container using a bind
which is the default operation
  • Loading branch information
srevinsaju committed Feb 28, 2024
1 parent c044992 commit 72bb147
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v2.0.0-alpha.16]
- Add `stage.*.container.skip_workspace` boolean parameter to skip mounting the current working directory when using the docker plugin

## [v2.0.0-alpha.14]
- Fixes `depends_on` not being respected on modules.

Expand Down
15 changes: 8 additions & 7 deletions internal/ci/stage_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,9 @@ func (s *Stage) executeDocker(conductor *Conductor, evalCtx *hcl.EvalContext, cm
}

logger.Trace("parsing container arguments")
binds := []string{
fmt.Sprintf("%s:/workspace", cmd.Dir),
var binds []string
if !s.Container.SkipWorkspace {
binds = append(binds, fmt.Sprintf("%s:/workspace", cmd.Dir))
}

logger.Trace("parsing container volumes")
Expand All @@ -614,11 +615,11 @@ func (s *Stage) executeDocker(conductor *Conductor, evalCtx *hcl.EvalContext, cm

logger.Trace("dry run check")
if cfg.Behavior.DryRun {
fmt.Println(ui.Blue("docker:run.image"), ui.Green(image))
fmt.Println(ui.Blue("docker:run.workdir"), ui.Green("/workspace"))
fmt.Println(ui.Blue("docker:run.volume"), ui.Green(cmd.Dir+":/workspace"))
fmt.Println(ui.Blue("docker:run.stdin"), ui.Green(s.Container.Stdin))
fmt.Println(ui.Blue("docker:run.args"), ui.Green(cmd.String()))
fmt.Println(ui.Blue("# docker:run.image"), ui.Green(image))
fmt.Println(ui.Blue("# docker:run.workdir"), ui.Green("/workspace"))
fmt.Println(ui.Blue("# docker:run.volume"), ui.Green(cmd.Dir+":/workspace"))
fmt.Println(ui.Blue("# docker:run.stdin"), ui.Green(s.Container.Stdin))
fmt.Println(ui.Blue("# docker:run.args"), ui.Green(cmd.String()))
return diags
}

Expand Down
3 changes: 3 additions & 0 deletions internal/ci/stage_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ type StageContainer struct {
// Volumes have a list of host path volume mapping which is bound on docker run
Volumes StageContainerVolumes `hcl:"volume,block" json:"volumes"`

// SkipWorkspace allows you to skip mounting the workspace directory
SkipWorkspace bool `hcl:"skip_workspace,optional" json:"skip_workspace"`

// Ports have a list of ports that needs to be exposed from the container
Ports StageContainerPorts `hcl:"port,block" json:"ports"`

Expand Down

0 comments on commit 72bb147

Please sign in to comment.