diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-03-19 12:08:11 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-03-19 15:35:35 +0000 |
| commit | 3b7445cf7f3c99cd574fc04ecdda1a67097cf55f (patch) | |
| tree | 4d6a1d09ab00a0db7fbcb5713d7060d9a3bb2cc8 /pkg/gcs | |
| parent | e20d7b1367f179faeed38718178841377f3accbf (diff) | |
syz-ci/manager.go: make CoverProgramsPath target public
PublishGCS param now controls the CoverProgramsPath targets too.
Previously it controlled only CoverUploadPath and CorpusUploadPath.
Diffstat (limited to 'pkg/gcs')
| -rw-r--r-- | pkg/gcs/gcs.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/gcs/gcs.go b/pkg/gcs/gcs.go index c9e62c86e..186b9a8eb 100644 --- a/pkg/gcs/gcs.go +++ b/pkg/gcs/gcs.go @@ -22,6 +22,30 @@ import ( "google.golang.org/api/iterator" ) +func UploadFile(ctx context.Context, srcFile io.Reader, destURL string, publish bool) error { + destURL = strings.TrimPrefix(destURL, "gs://") + client, err := NewClient(ctx) + if err != nil { + return fmt.Errorf("func NewClient: %w", err) + } + defer client.Close() + gcsWriter, err := client.FileWriter(destURL) + if err != nil { + return fmt.Errorf("client.FileWriter: %w", err) + } + if _, err := io.Copy(gcsWriter, srcFile); err != nil { + gcsWriter.Close() + return fmt.Errorf("io.Copy: %w", err) + } + if err := gcsWriter.Close(); err != nil { + return fmt.Errorf("gcsWriter.Close: %w", err) + } + if publish { + return client.Publish(destURL) + } + return nil +} + type Client struct { client *storage.Client ctx context.Context |
