(filePath string)
| 45 | } |
| 46 | |
| 47 | func (a *ArtifactUpload) Run(filePath string) (*CASArtifact, error) { |
| 48 | client := casclient.New(a.artifactsCASConn, casclient.WithLogger(a.Logger)) |
| 49 | |
| 50 | // open file and calculate size |
| 51 | f, err := os.Open(filePath) |
| 52 | if err != nil { |
| 53 | return nil, fmt.Errorf("can't open file to upload: %w", err) |
| 54 | } |
| 55 | defer f.Close() |
| 56 | |
| 57 | info, err := f.Stat() |
| 58 | if err != nil { |
| 59 | return nil, fmt.Errorf("retrieving file information: %w", err) |
| 60 | } |
| 61 | |
| 62 | // render progress bar |
| 63 | go renderOperationStatus(context.Background(), client.ProgressStatus, info.Size()) |
| 64 | defer close(client.ProgressStatus) |
| 65 | |
| 66 | res, err := client.UploadFile(context.Background(), filePath) |
| 67 | if err != nil { |
| 68 | return nil, err |
| 69 | } |
| 70 | |
| 71 | // Give some time for the progress renderer to finish |
| 72 | // TODO: Implement with proper subroutine messaging |
| 73 | time.Sleep(progress.DefaultUpdateFrequency) |
| 74 | |
| 75 | return &CASArtifact{Digest: res.Digest, fileName: res.Filename}, nil |
| 76 | } |
nothing calls this directly
no test coverage detected