mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-25 21:20:12 +00:00
fix workspace type
This commit is contained in:
parent
0230ea3bdd
commit
09d9853911
5 changed files with 10 additions and 13 deletions
|
@ -108,10 +108,10 @@ func toHostConfig(step *types.Step) *container.HostConfig {
|
||||||
config.Devices = toDev(step.Devices)
|
config.Devices = toDev(step.Devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
if step.Workspace.Tmpfs.Size != 0 {
|
if len(step.Workspace) != 0 {
|
||||||
config.Binds = step.Volumes
|
config.Tmpfs = map[string]string{step.Workspace[0].Tmpfs[0].Path: "size=" + strconv.Itoa(step.Workspace[0].Tmpfs[0].Size)}
|
||||||
} else {
|
} else {
|
||||||
config.Tmpfs = map[string]string{step.Workspace.Tmpfs.Path: "size=" + strconv.Itoa(step.Workspace.Tmpfs.Size)}
|
config.Binds = step.Volumes
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -154,7 +154,9 @@ func TestToConfigFull(t *testing.T) {
|
||||||
AuthConfig: backend.Auth{Username: "user", Password: "123456"},
|
AuthConfig: backend.Auth{Username: "user", Password: "123456"},
|
||||||
NetworkMode: "bridge",
|
NetworkMode: "bridge",
|
||||||
Ports: []backend.Port{{Number: 21}, {Number: 22}},
|
Ports: []backend.Port{{Number: 21}, {Number: 22}},
|
||||||
UseTmpfs: true,
|
Workspace: []backend.Workspace{{
|
||||||
|
Tmpfs: []backend.Tmpfs{{Path: "/tmp", Size: 1024}},
|
||||||
|
}},
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.NotNil(t, conf)
|
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
|
// add default volumes to the host configuration
|
||||||
if step.UseTmpfs {
|
if step.Workspace.Tmpfs.Size != 0 {
|
||||||
hostConfig.Binds = e.volumes
|
hostConfig.Binds = e.volumes
|
||||||
} else {
|
} else {
|
||||||
hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...))
|
hostConfig.Binds = utils.DeduplicateStrings(append(hostConfig.Binds, e.volumes...))
|
||||||
|
|
|
@ -47,12 +47,7 @@ type Step struct {
|
||||||
NetworkMode string `json:"network_mode,omitempty"`
|
NetworkMode string `json:"network_mode,omitempty"`
|
||||||
Ports []Port `json:"ports,omitempty"`
|
Ports []Port `json:"ports,omitempty"`
|
||||||
BackendOptions map[string]any `json:"backend_options,omitempty"`
|
BackendOptions map[string]any `json:"backend_options,omitempty"`
|
||||||
Workspace struct {
|
Workspace []Workspace `json:"workspace,omitempty"`
|
||||||
Tmpfs struct {
|
|
||||||
Size int
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StepType identifies the type of step
|
// StepType identifies the type of step
|
||||||
|
|
|
@ -2,10 +2,10 @@ package types
|
||||||
|
|
||||||
// BackendOptions defines all the advanced options for the kubernetes backend
|
// BackendOptions defines all the advanced options for the kubernetes backend
|
||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
Tmpfs []Tmpfs `json:"Tmpfs"`
|
Tmpfs []Tmpfs `json:"Tmpfs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tmpfs struct {
|
type Tmpfs struct {
|
||||||
Path string `json:"path,omitempty"`
|
Path string `json:"path,omitempty"`
|
||||||
Size int `json:"size,omitempty"`
|
Size int `json:"size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue