diff --git a/pipeline/backend/docker/convert.go b/pipeline/backend/docker/convert.go index 6484df419..93504d4f2 100644 --- a/pipeline/backend/docker/convert.go +++ b/pipeline/backend/docker/convert.go @@ -108,10 +108,10 @@ func toHostConfig(step *types.Step) *container.HostConfig { config.Devices = toDev(step.Devices) } - if step.Workspace.Tmpfs.Size != 0 { - config.Binds = step.Volumes + if len(step.Workspace) != 0 { + config.Tmpfs = map[string]string{step.Workspace[0].Tmpfs[0].Path: "size=" + strconv.Itoa(step.Workspace[0].Tmpfs[0].Size)} } else { - config.Tmpfs = map[string]string{step.Workspace.Tmpfs.Path: "size=" + strconv.Itoa(step.Workspace.Tmpfs.Size)} + config.Binds = step.Volumes } return config diff --git a/pipeline/backend/docker/convert_test.go b/pipeline/backend/docker/convert_test.go index c6bfde741..74757acfe 100644 --- a/pipeline/backend/docker/convert_test.go +++ b/pipeline/backend/docker/convert_test.go @@ -154,7 +154,9 @@ func TestToConfigFull(t *testing.T) { AuthConfig: backend.Auth{Username: "user", Password: "123456"}, NetworkMode: "bridge", Ports: []backend.Port{{Number: 21}, {Number: 22}}, - UseTmpfs: true, + Workspace: []backend.Workspace{{ + Tmpfs: []backend.Tmpfs{{Path: "/tmp", Size: 1024}}, + }}, }) assert.NotNil(t, conf) diff --git a/pipeline/backend/docker/docker.go b/pipeline/backend/docker/docker.go index a9c264987..8c94b678d 100644 --- a/pipeline/backend/docker/docker.go +++ b/pipeline/backend/docker/docker.go @@ -213,7 +213,7 @@ func (e *docker) StartStep(ctx context.Context, step *backend.Step, taskUUID str } // add default volumes to the host configuration - if step.UseTmpfs { + if step.Workspace.Tmpfs.Size != 0 { hostConfig.Binds = e.volumes } else { hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...)) diff --git a/pipeline/backend/types/step.go b/pipeline/backend/types/step.go index 10b687f34..0d80ebafe 100644 --- a/pipeline/backend/types/step.go +++ b/pipeline/backend/types/step.go @@ -47,12 +47,7 @@ type Step struct { NetworkMode string `json:"network_mode,omitempty"` Ports []Port `json:"ports,omitempty"` BackendOptions map[string]any `json:"backend_options,omitempty"` - Workspace struct { - Tmpfs struct { - Size int - Path string - } - } + Workspace []Workspace `json:"workspace,omitempty"` } // StepType identifies the type of step diff --git a/pipeline/backend/types/workspace.go b/pipeline/backend/types/workspace.go index 4ddcce643..99bfdc785 100644 --- a/pipeline/backend/types/workspace.go +++ b/pipeline/backend/types/workspace.go @@ -2,10 +2,10 @@ package types // BackendOptions defines all the advanced options for the kubernetes backend type Workspace struct { - Tmpfs []Tmpfs `json:"Tmpfs"` + Tmpfs []Tmpfs `json:"Tmpfs"` } type Tmpfs struct { Path string `json:"path,omitempty"` - Size int `json:"size,omitempty"` + Size int `json:"size,omitempty"` }