Skip to content

Commit

Permalink
Remove task merge behavior from store.
Browse files Browse the repository at this point in the history
  • Loading branch information
hashi-derek authored and noejbrown committed Jul 8, 2022
1 parent 42e8af3 commit 86e55d5
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions state/in_memory_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ func (s *InMemoryStore) GetTask(taskName string) (config.TaskConfig, bool) {
return config.TaskConfig{}, false
}

// SetTask adds a new task configuration or does a patch update to an
// existing task configuration with the same name. The returned error
// will always be nil.
// SetTask adds a new task configuration or overwrites an existing task
// configuration with the same name. The returned error will always be nil.
func (s *InMemoryStore) SetTask(newTaskConf config.TaskConfig) error {
s.conf.mu.Lock()
defer s.conf.mu.Unlock()
Expand All @@ -95,15 +94,15 @@ func (s *InMemoryStore) SetTask(newTaskConf config.TaskConfig) error {

for ix, taskConf := range *taskConfs {
if config.StringVal(taskConf.Name) == newTaskName {
// patch update the existing task
updatedTaskConf := taskConf.Merge(&newTaskConf)
// overwrite the existing task
updatedTaskConf := newTaskConf.Copy()
(*taskConfs)[ix] = updatedTaskConf
return nil
}
}

// add as a new task
*taskConfs = append(*taskConfs, &newTaskConf)
*taskConfs = append(*taskConfs, newTaskConf.Copy())
return nil
}

Expand Down

0 comments on commit 86e55d5

Please sign in to comment.