diff --git a/api/pkg/artifact/artifact.go b/api/pkg/artifact/artifact.go index 5b5df578..af7857bc 100644 --- a/api/pkg/artifact/artifact.go +++ b/api/pkg/artifact/artifact.go @@ -27,7 +27,7 @@ type Service interface { ParseURL(gsURL string) (*URL, error) ReadArtifact(ctx context.Context, url string) ([]byte, error) - WriteArtifact(ctx context.Context, url, content string) error + WriteArtifact(ctx context.Context, url string, content []byte) error DeleteArtifact(ctx context.Context, url string) error } @@ -88,14 +88,14 @@ func (gac *GcsArtifactClient) ReadArtifact(ctx context.Context, url string) ([]b return bytes, nil } -func (gac *GcsArtifactClient) WriteArtifact(ctx context.Context, url, content string) error { +func (gac *GcsArtifactClient) WriteArtifact(ctx context.Context, url string, content []byte) error { u, err := gac.ParseURL(url) if err != nil { return err } w := gac.API.Bucket(u.Bucket).Object(u.Object).NewWriter(ctx) - if _, err := fmt.Fprint(w, content); err != nil { + if _, err := fmt.Fprintf(w, "%s", content); err != nil { return err } @@ -147,7 +147,7 @@ func (nac *NopArtifactClient) ReadArtifact(ctx context.Context, url string) ([]b return nil, nil } -func (nac *NopArtifactClient) WriteArtifact(ctx context.Context, url, content string) error { +func (nac *NopArtifactClient) WriteArtifact(ctx context.Context, url string, content []byte) error { return nil } diff --git a/api/pkg/artifact/mocks/artifact.go b/api/pkg/artifact/mocks/artifact.go index 426e9bea..36e785c7 100644 --- a/api/pkg/artifact/mocks/artifact.go +++ b/api/pkg/artifact/mocks/artifact.go @@ -82,11 +82,11 @@ func (_m *Service) ReadArtifact(ctx context.Context, url string) ([]byte, error) } // WriteArtifact provides a mock function with given fields: ctx, url, content -func (_m *Service) WriteArtifact(ctx context.Context, url string, content string) error { +func (_m *Service) WriteArtifact(ctx context.Context, url string, content []byte) error { ret := _m.Called(ctx, url, content) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, []byte) error); ok { r0 = rf(ctx, url, content) } else { r0 = ret.Error(0)