MCPcopy
hub / github.com/apache/devlake / PatchBlueprint

Function PatchBlueprint

backend/server/services/blueprint.go:202–236  ·  view source on GitHub ↗

PatchBlueprint FIXME ...

(id uint64, body map[string]interface{})

Source from the content-addressed store, hash-verified

200
201// PatchBlueprint FIXME ...
202func 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 ...
239func DeleteBlueprint(id uint64) errors.Error {

Callers

nothing calls this directly

Calls 5

GetBlueprintFunction · 0.85
saveBlueprintFunction · 0.85
SanitizeBlueprintFunction · 0.85
NewMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected