Use ArtifactDriver.Load() to get a stream, which we can use for all implementations of ArtifactDriver.OpenStream() that aren't yet implemented the "right way" and/or for those that don't have a natural way of streaming
(ctx context.Context, a *wfv1.Artifact, g ArtifactDriver)
| 28 | // Use ArtifactDriver.Load() to get a stream, which we can use for all implementations of ArtifactDriver.OpenStream() |
| 29 | // that aren't yet implemented the "right way" and/or for those that don't have a natural way of streaming |
| 30 | func LoadToStream(ctx context.Context, a *wfv1.Artifact, g ArtifactDriver) (io.ReadCloser, error) { |
| 31 | logger := logging.RequireLoggerFromContext(ctx) |
| 32 | logger.WithField("type", reflect.TypeOf(g)).Info(ctx, "Efficient artifact streaming is not supported") |
| 33 | filename := os.TempDir() + string(os.PathSeparator) + loadToStreamPrefix + rand.String(32) |
| 34 | if err := g.Load(ctx, a, filename); err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | f, err := os.Open(filename) |
| 38 | if err != nil { |
| 39 | _ = os.Remove(filename) |
| 40 | return nil, err |
| 41 | } |
| 42 | return &selfDestructingFile{*f}, nil |
| 43 | } |