mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-06-16 04:10:44 +00:00
fix workspace type
This commit is contained in:
parent
0230ea3bdd
commit
09d9853911
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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...))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue