mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-09-28 14:31:59 +00:00
use workspace struct
This commit is contained in:
parent
b9fc030ca5
commit
0230ea3bdd
6 changed files with 23 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
11
pipeline/backend/types/workspace.go
Normal file
11
pipeline/backend/types/workspace.go
Normal file
|
@ -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"`
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue