nolint:gocyclo,funlen
( ctx context.Context, fsEntry fs.Entry, setManual bool, rep repo.RepositoryWriter, u *upload.Uploader, sourceInfo snapshot.SourceInfo, tags map[string]string, st *notifydata.MultiSnapshotStatus, )
| 282 | |
| 283 | //nolint:gocyclo,funlen |
| 284 | func (c *commandSnapshotCreate) snapshotSingleSource( |
| 285 | ctx context.Context, |
| 286 | fsEntry fs.Entry, |
| 287 | setManual bool, |
| 288 | rep repo.RepositoryWriter, |
| 289 | u *upload.Uploader, |
| 290 | sourceInfo snapshot.SourceInfo, |
| 291 | tags map[string]string, |
| 292 | st *notifydata.MultiSnapshotStatus, |
| 293 | ) (finalErr error) { |
| 294 | log(ctx).Infof("Snapshotting %v ...", sourceInfo) |
| 295 | |
| 296 | var mwe notifydata.ManifestWithError |
| 297 | |
| 298 | mwe.Manifest.Source = sourceInfo |
| 299 | |
| 300 | st.Snapshots = append(st.Snapshots, &mwe) |
| 301 | |
| 302 | defer func() { |
| 303 | if finalErr != nil { |
| 304 | mwe.Error = finalErr.Error() |
| 305 | } |
| 306 | }() |
| 307 | |
| 308 | var previous []*snapshot.Manifest |
| 309 | |
| 310 | previous, finalErr = snapshot.FindPreviousManifests(ctx, rep, sourceInfo, nil) |
| 311 | if finalErr != nil { |
| 312 | return errors.Wrap(finalErr, "unable to find previous manifests") |
| 313 | } |
| 314 | |
| 315 | if len(previous) > 0 { |
| 316 | mwe.Previous = previous[0] |
| 317 | } |
| 318 | |
| 319 | policyTree, finalErr := policy.TreeForSource(ctx, rep, sourceInfo) |
| 320 | if finalErr != nil { |
| 321 | return errors.Wrap(finalErr, "unable to get policy tree") |
| 322 | } |
| 323 | |
| 324 | manifest, finalErr := u.Upload(ctx, fsEntry, policyTree, sourceInfo, previous...) |
| 325 | if finalErr != nil { |
| 326 | // fail-fast uploads will fail here without recording a manifest, other uploads will |
| 327 | // possibly fail later. |
| 328 | return errors.Wrap(finalErr, "upload error") |
| 329 | } |
| 330 | |
| 331 | manifest.Description = c.snapshotCreateDescription |
| 332 | manifest.Tags = tags |
| 333 | manifest.UpdatePins(c.pins, nil) |
| 334 | |
| 335 | startTimeOverride, _ := parseTimestamp(c.snapshotCreateStartTime) |
| 336 | endTimeOverride, _ := parseTimestamp(c.snapshotCreateEndTime) |
| 337 | |
| 338 | if !startTimeOverride.IsZero() { |
| 339 | if endTimeOverride.IsZero() { |
| 340 | // Calculate the correct end time based on current duration if they're not specified |
| 341 | duration := manifest.EndTime.Sub(manifest.StartTime) |
no test coverage detected