diff --git a/pipeline/backend/docker/convert.go b/pipeline/backend/docker/convert.go index 8459041eb..6484df419 100644 --- a/pipeline/backend/docker/convert.go +++ b/pipeline/backend/docker/convert.go @@ -19,6 +19,7 @@ import ( "encoding/json" "maps" "regexp" + "strconv" "strings" "github.com/docker/docker/api/types/container" @@ -107,10 +108,10 @@ func toHostConfig(step *types.Step) *container.HostConfig { config.Devices = toDev(step.Devices) } - if !step.UseTmpfs { + if step.Workspace.Tmpfs.Size != 0 { config.Binds = step.Volumes } else { - config.Tmpfs = map[string]string{"/woodpecker": ""} + config.Tmpfs = map[string]string{step.Workspace.Tmpfs.Path: "size=" + strconv.Itoa(step.Workspace.Tmpfs.Size)} } return config diff --git a/pipeline/backend/docker/convert_test.go b/pipeline/backend/docker/convert_test.go index 9aabed901..c6bfde741 100644 --- a/pipeline/backend/docker/convert_test.go +++ b/pipeline/backend/docker/convert_test.go @@ -154,7 +154,7 @@ func TestToConfigFull(t *testing.T) { AuthConfig: backend.Auth{Username: "user", Password: "123456"}, NetworkMode: "bridge", Ports: []backend.Port{{Number: 21}, {Number: 22}}, - UseTmpfs: true, + UseTmpfs: true, }) assert.NotNil(t, conf) diff --git a/pipeline/backend/types/step.go b/pipeline/backend/types/step.go index 62ebdacd1..10b687f34 100644 --- a/pipeline/backend/types/step.go +++ b/pipeline/backend/types/step.go @@ -47,7 +47,12 @@ type Step struct { NetworkMode string `json:"network_mode,omitempty"` Ports []Port `json:"ports,omitempty"` BackendOptions map[string]any `json:"backend_options,omitempty"` - UseTmpfs bool `json:"use_tmpfs,omitempty"` + Workspace struct { + Tmpfs struct { + Size int + Path string + } + } } // StepType identifies the type of step diff --git a/pipeline/backend/types/workspace.go b/pipeline/backend/types/workspace.go new file mode 100644 index 000000000..4ddcce643 --- /dev/null +++ b/pipeline/backend/types/workspace.go @@ -0,0 +1,11 @@ +package types + +// BackendOptions defines all the advanced options for the kubernetes backend +type Workspace struct { + Tmpfs []Tmpfs `json:"Tmpfs"` +} + +type Tmpfs struct { + Path string `json:"path,omitempty"` + Size int `json:"size,omitempty"` +} diff --git a/pipeline/frontend/yaml/compiler/convert.go b/pipeline/frontend/yaml/compiler/convert.go index c4686d4aa..dad824ff3 100644 --- a/pipeline/frontend/yaml/compiler/convert.go +++ b/pipeline/frontend/yaml/compiler/convert.go @@ -215,7 +215,7 @@ func (c *Compiler) createProcess(container *yaml_types.Container, stepType backe NetworkMode: networkMode, Ports: ports, BackendOptions: container.BackendOptions, - UseTmpfs: container.UseTmpfs, + Workspace: container.Workspace, }, nil } diff --git a/pipeline/frontend/yaml/types/container.go b/pipeline/frontend/yaml/types/container.go index fa649dccd..04b445624 100644 --- a/pipeline/frontend/yaml/types/container.go +++ b/pipeline/frontend/yaml/types/container.go @@ -71,7 +71,7 @@ type ( Networks Networks `yaml:"networks,omitempty"` ShmSize base.MemStringOrInt `yaml:"shm_size,omitempty"` Tmpfs []string `yaml:"tmpfs,omitempty"` - UseTmpfs bool `yaml:"use_tmpfs,omitempty"` + Workspace []Workspace `yaml:"workspace"` } )