the setManual return value is true when a snapshot is manually created, such as when overriding the source info or snapshotting from stdin.
(ctx context.Context, dir string, rep repo.RepositoryWriter)
| 458 | // the setManual return value is true when a snapshot is manually created, such |
| 459 | // as when overriding the source info or snapshotting from stdin. |
| 460 | func (c *commandSnapshotCreate) getContentToSnapshot(ctx context.Context, dir string, rep repo.RepositoryWriter) (fsEntry fs.Entry, info snapshot.SourceInfo, setManual bool, err error) { |
| 461 | var absDir string |
| 462 | |
| 463 | absDir, err = filepath.Abs(dir) |
| 464 | if err != nil { |
| 465 | return nil, info, false, errors.Wrapf(err, "invalid source %v", dir) |
| 466 | } |
| 467 | |
| 468 | if c.sourceOverride != "" { |
| 469 | info, err = parseFullSource(c.sourceOverride, rep.ClientOptions().Hostname, rep.ClientOptions().Username) |
| 470 | if err != nil { |
| 471 | return nil, info, false, errors.Wrapf(err, "invalid source override %v", c.sourceOverride) |
| 472 | } |
| 473 | |
| 474 | setManual = true |
| 475 | } else { |
| 476 | info = snapshot.SourceInfo{ |
| 477 | Path: filepath.Clean(absDir), |
| 478 | Host: rep.ClientOptions().Hostname, |
| 479 | UserName: rep.ClientOptions().Username, |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if c.snapshotCreateStdinFileName != "" { |
| 484 | // stdin source will be snapshotted using a virtual static root directory with a single streaming file entry |
| 485 | // Create a new static directory with the given name and add a streaming file entry with os.Stdin reader |
| 486 | fsEntry = virtualfs.NewStaticDirectory(absDir, []fs.Entry{ |
| 487 | virtualfs.StreamingFileFromReader(c.snapshotCreateStdinFileName, io.NopCloser(c.svc.stdin())), |
| 488 | }) |
| 489 | setManual = true |
| 490 | } else { |
| 491 | fsEntry, err = getLocalFSEntry(ctx, absDir) |
| 492 | if err != nil { |
| 493 | return nil, info, false, errors.Wrap(err, "unable to get local filesystem entry") |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | return fsEntry, info, setManual, nil |
| 498 | } |
| 499 | |
| 500 | func parseFullSource(str, hostname, username string) (snapshot.SourceInfo, error) { |
| 501 | sourceInfo, err := snapshot.ParseSourceInfo(str, hostname, username) |
no test coverage detected