Skip to content

Commit

Permalink
Copy documentation to api/tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
endocrimes committed Aug 12, 2019
1 parent e57cf06 commit c486143
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
7 changes: 5 additions & 2 deletions api/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions jobspec/parse_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{})
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion jobspec/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestParse(t *testing.T) {
},
},

Volumes: map[string]*api.Volume{
Volumes: map[string]*api.VolumeRequest{
"foo": {
Name: "foo",
Type: "host",
Expand Down

0 comments on commit c486143

Please sign in to comment.