Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple tasks of same type only handled once per snowblock configuration file #76

Closed
arcticicestudio opened this issue Jul 15, 2019 · 1 comment

Comments

@arcticicestudio
Copy link
Owner

arcticicestudio commented Jul 15, 2019

Epic: #33

When a task is defined multiple times within the same snowblock configuration file, only the last object is processed while any object before are ignored.
The root cause is the pkg/snowblock.TaskRunnerMapping custom type that only accepts one pkg/api.TaskConfiguration object.
Therefore any parsed task object of the same type is overriden by tasks that are parsed after that task resulting in missing tasks.

Running this example configuration will not process the first clean task but only the second one:

[
  {
    "clean": ["~/desktop/failure"]
  },
  {
    "link": {
      "~/desktop/success/config.json": {
        "create": true,
        "path": "config.json"
      }
    }
  },
  {
    "clean": ["~/desktop/success"]
  },
]

To fix this problem the pkg/snowblock.TaskRunnerMapping type should accept multiple pkg/api.TaskConfiguration objects (TaskRunnerMapping map[api.TaskRunner][]api.TaskConfiguration) instead of only one so the previous object won't be overridden.

@arcticicestudio arcticicestudio self-assigned this Jul 15, 2019
@arcticicestudio arcticicestudio added this to the 0.4.0 milestone Jul 15, 2019
arcticicestudio added a commit that referenced this issue Jul 15, 2019
When a task is defined multiple times within the same snowblock
configuration file, only the last object was processed while any object
before has been ignored.
The root cause was the `pkg/snowblock.TaskRunnerMapping` (1) custom type
that only accepted one `pkg/api.TaskConfiguration` (2) object.
Therefore any parsed task object of the same type was overriden (2) by
tasks that are parsed after that task resulted in missing tasks.

Before this commit, running this example configuration has not processed
the first `clean` task but only the second one:

```json
[
  {
    "clean": ["~/desktop/failure"]
  },
  {
    "link": {
      "~/desktop/success/config.json": {
        "create": true,
        "path": "config.json"
      }
    }
  },
  {
    "clean": ["~/desktop/success"]
  },
]
```

To fix the problem the `pkg/snowblock.TaskRunnerMapping` type now
accepts multiple `pkg/api.TaskConfiguration` (2) objects
(`TaskRunnerMapping map[api.TaskRunner][]api.TaskConfiguration`) instead
of only one so the previous object won't be overridden.

References:
  (1) https://github.com/arcticicestudio/snowsaw/blob/efdff96ec01f26bbf0a0d75bb9aab4cb86f023e8/pkg/snowblock/snowblock.go#L46
  (2) https://github.com/arcticicestudio/snowsaw/blob/988073b1bde8d7db4b40f259e99d218c959bba8f/pkg/api/snowblock/task.go#L18
  (3) https://github.com/arcticicestudio/snowsaw/blob/efdff96ec01f26bbf0a0d75bb9aab4cb86f023e8/pkg/snowblock/snowblock.go#L112

Epic: GH-33
Fixes GH-76
@arcticicestudio
Copy link
Owner Author

Fixed in 006ae99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant