From c486143ced1c8a5df87cba0c70558a0555cc464f Mon Sep 17 00:00:00 2001 From: Danielle Lancashire Date: Mon, 12 Aug 2019 16:22:27 +0200 Subject: [PATCH] Copy documentation to api/tasks --- api/tasks.go | 7 +++++-- client/config/config.go | 2 +- jobspec/parse_group.go | 8 ++++---- jobspec/parse_test.go | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/tasks.go b/api/tasks.go index e044f9a9f..b30227662 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -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 diff --git a/client/config/config.go b/client/config/config.go index cb7e25726..d6e09fde9 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -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 } diff --git a/jobspec/parse_group.go b/jobspec/parse_group.go index d79677809..a835732de 100644 --- a/jobspec/parse_group.go +++ b/jobspec/parse_group.go @@ -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, diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index a1107e030..f9f009c07 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -112,7 +112,7 @@ func TestParse(t *testing.T) { }, }, - Volumes: map[string]*api.Volume{ + Volumes: map[string]*api.VolumeRequest{ "foo": { Name: "foo", Type: "host",