From 3b7445cf7f3c99cd574fc04ecdda1a67097cf55f Mon Sep 17 00:00:00 2001 From: Taras Madan Date: Wed, 19 Mar 2025 12:08:11 +0100 Subject: syz-ci/manager.go: make CoverProgramsPath target public PublishGCS param now controls the CoverProgramsPath targets too. Previously it controlled only CoverUploadPath and CorpusUploadPath. --- pkg/gcs/gcs.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'pkg/gcs') 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 -- cgit mrf-deployment