Copy documentation to api/tasks

This commit is contained in:
Danielle Lancashire
2019-08-12 16:22:27 +02:00
parent e57cf06b0d
commit c486143ced
4 changed files with 11 additions and 8 deletions

View File

@@ -362,7 +362,8 @@ func (m *MigrateStrategy) Copy() *MigrateStrategy {
return nm
}
type Volume struct {
// VolumeRequest is a representation of a storage volume that a TaskGroup wishes to use.
type VolumeRequest struct {
Name string
Type string
ReadOnly bool `mapstructure:"read_only"`
@@ -371,6 +372,8 @@ type Volume struct {
Config map[string]interface{}
}
// VolumeMount represents the relationship between a destination path in a task
// and the task group volume that should be mounted there.
type VolumeMount struct {
Volume string
Destination string
@@ -385,7 +388,7 @@ type TaskGroup struct {
Affinities []*Affinity
Tasks []*Task
Spreads []*Spread
Volumes map[string]*Volume
Volumes map[string]*VolumeRequest
RestartPolicy *RestartPolicy
ReschedulePolicy *ReschedulePolicy
EphemeralDisk *EphemeralDisk

View File

@@ -235,7 +235,7 @@ type Config struct {
// notation
BridgeNetworkAllocSubnet string
// HostVolumes is the set of configured host volumes
// HostVolumes is a map of the configured host volumes by name.
HostVolumes map[string]*structs.ClientHostVolumeConfig
}

View File

@@ -284,8 +284,8 @@ func parseRestartPolicy(final **api.RestartPolicy, list *ast.ObjectList) error {
return nil
}
func parseVolumes(out *map[string]*api.Volume, list *ast.ObjectList) error {
volumes := make(map[string]*api.Volume, len(list.Items))
func parseVolumes(out *map[string]*api.VolumeRequest, list *ast.ObjectList) error {
volumes := make(map[string]*api.VolumeRequest, len(list.Items))
for _, item := range list.Items {
n := item.Keys[0].Token.Value().(string)
@@ -304,7 +304,7 @@ func parseVolumes(out *map[string]*api.Volume, list *ast.ObjectList) error {
return err
}
// TODO(dani): FIXME: this is gross but we don't have ObjectList.Filter here
// TODO(dani): this is gross but we don't have ObjectList.Filter here
var cfg map[string]interface{}
if cfgI, ok := m["config"]; ok {
cfgL, ok := cfgI.([]map[string]interface{})
@@ -320,7 +320,7 @@ func parseVolumes(out *map[string]*api.Volume, list *ast.ObjectList) error {
}
delete(m, "config")
var result api.Volume
var result api.VolumeRequest
dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
WeaklyTypedInput: true,
Result: &result,

View File

@@ -112,7 +112,7 @@ func TestParse(t *testing.T) {
},
},
Volumes: map[string]*api.Volume{
Volumes: map[string]*api.VolumeRequest{
"foo": {
Name: "foo",
Type: "host",