PatchBlueprint FIXME ...
(id uint64, body map[string]interface{})
| 200 | |
| 201 | // PatchBlueprint FIXME ... |
| 202 | func PatchBlueprint(id uint64, body map[string]interface{}) (*models.Blueprint, errors.Error) { |
| 203 | // load record from db |
| 204 | blueprint, err := GetBlueprint(id, false) |
| 205 | if err != nil { |
| 206 | return nil, err |
| 207 | } |
| 208 | |
| 209 | originMode := blueprint.Mode |
| 210 | err = helper.DecodeMapStruct(body, blueprint, true) |
| 211 | if err != nil { |
| 212 | return nil, err |
| 213 | } |
| 214 | |
| 215 | // make sure mode is not being updated |
| 216 | if originMode != blueprint.Mode { |
| 217 | return nil, errors.Default.New("mode is not updatable") |
| 218 | } |
| 219 | // syncPolicy can be updated, so we need to decode it again |
| 220 | err = helper.DecodeMapStruct(body, &blueprint.SyncPolicy, true) |
| 221 | if err != nil { |
| 222 | return nil, err |
| 223 | } |
| 224 | if blueprint.SyncPolicy.TimeAfter != nil && blueprint.SyncPolicy.TimeAfter.IsZero() { |
| 225 | blueprint.SyncPolicy.TimeAfter = nil |
| 226 | } |
| 227 | |
| 228 | blueprint, err = saveBlueprint(blueprint) |
| 229 | if err != nil { |
| 230 | return nil, err |
| 231 | } |
| 232 | if err := SanitizeBlueprint(blueprint); err != nil { |
| 233 | return nil, errors.Convert(err) |
| 234 | } |
| 235 | return blueprint, nil |
| 236 | } |
| 237 | |
| 238 | // DeleteBlueprint FIXME ... |
| 239 | func DeleteBlueprint(id uint64) errors.Error { |
nothing calls this directly
no test coverage detected