UpdateJob updates job config
(namespace string, job models.JobConfig)
| 112 | |
| 113 | // UpdateJob updates job config |
| 114 | func (j *jobMutatorImpl) UpdateJob(namespace string, job models.JobConfig) (err error) { |
| 115 | jobListProto, jobListVersion, err := readEntityList(j.etcdStore, utils.JobListKey(namespace)) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | jobListProto, found := updateEntity(jobListProto, job.Name) |
| 121 | if !found { |
| 122 | j.logger.With( |
| 123 | "job", job, |
| 124 | ).Info("job not found for update, creating new job") |
| 125 | return j.AddJob(namespace, job) |
| 126 | } |
| 127 | |
| 128 | jobProto, jobVersion, err := j.readJob(namespace, job.Name) |
| 129 | if err != nil { |
| 130 | return err |
| 131 | } |
| 132 | if jobProto.Tomstoned { |
| 133 | return common.ErrJobConfigDoesNotExist |
| 134 | } |
| 135 | jobProto.Tomstoned = false |
| 136 | jobProto.Config, err = json.Marshal(job) |
| 137 | if err != nil { |
| 138 | return |
| 139 | } |
| 140 | |
| 141 | return kvstore.NewTransaction(). |
| 142 | AddKeyValue(utils.JobListKey(namespace), jobListVersion, &jobListProto). |
| 143 | AddKeyValue(utils.JobKey(namespace, job.Name), jobVersion, &jobProto). |
| 144 | WriteTo(j.etcdStore) |
| 145 | } |
| 146 | |
| 147 | // AddJob adds a new job |
| 148 | func (j *jobMutatorImpl) AddJob(namespace string, job models.JobConfig) error { |
nothing calls this directly
no test coverage detected