Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Fix #285: Allow setting of task name in manifest with override from commandline flag #1123

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/snapctl/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ func createTaskUsingTaskManifest(ctx *cli.Context) error {
return fmt.Errorf("Unsupported file type %s\n", ext)
}

t.Name = ctx.String("name")
// Set t.Name to value of --name flag if set on command line
if ctx.IsSet("name") {
t.Name = ctx.String("name")
}

if t.Version != 1 {
return fmt.Errorf("Invalid version provided")
}
Expand Down
2 changes: 1 addition & 1 deletion core/task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestMarshalTask(t *testing.T) {
task, err := marshalTask(file)
So(err, ShouldBeNil)
So(task, ShouldNotBeNil)
So(task.Name, ShouldEqual, "")
So(task.Name, ShouldEqual, "mock-file")
So(task.Deadline, ShouldEqual, "")
So(task.Schedule.Type, ShouldEqual, "simple")
So(task.Schedule.Interval, ShouldEqual, "1s")
Expand Down
1 change: 1 addition & 0 deletions examples/tasks/mock-file.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"version": 1,
"name": "mock-file",
"schedule": {
"type": "simple",
"interval": "1s"
Expand Down
1 change: 1 addition & 0 deletions examples/tasks/mock-file.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
version: 1
name: mock-file
schedule:
type: "simple"
interval: "1s"
Expand Down