Skip to content

Commit 2a076c9

Browse files
authored
Adding support for content type to GCS output (#51)
* Adding support for content type to GCS output * update changelog * fixing typo
1 parent 7ae2356 commit 2a076c9

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1212

1313
### Removed
1414

15+
## [0.10.0]
16+
17+
### Added
18+
19+
- Added content type support to GCS output: [#51](https://github.com/elastic/stream/pull/51)
20+
1521
## [0.9.1]
1622

1723
### Changed

command/root.go

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func ExecuteContext(ctx context.Context) error {
9191
// GCS output flags.
9292
rootCmd.PersistentFlags().StringVar(&opts.GcsOptions.Bucket, "gcs-bucket", "testbucket", "GCS Bucket name")
9393
rootCmd.PersistentFlags().StringVar(&opts.GcsOptions.Object, "gcs-object", "testobject", "GCS Object name")
94+
rootCmd.PersistentFlags().StringVar(&opts.GcsOptions.ObjectContentType, "gcs-content-type", "application/json", "The Content type of the object to be uploaded to GCS.")
9495
rootCmd.PersistentFlags().StringVar(&opts.GcsOptions.ProjectID, "gcs-projectid", "testproject", "GCS Project name")
9596

9697
// Lumberjack output flags.

pkg/output/gcs/gcs.go

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ func New(opts *output.Options) (output.Output, error) {
3333
}
3434
obj := gcsClient.Bucket(opts.GcsOptions.Bucket).Object(opts.GcsOptions.Object)
3535
writer := obj.NewWriter(ctx)
36+
// System tests are failing because a default content type is not set automatically, so we set it here instead.
37+
writer.ObjectAttrs.ContentType = opts.GcsOptions.ObjectContentType
3638

3739
return &Output{opts: opts, client: gcsClient, cancelFunc: cancel, writer: writer}, nil
3840
}

pkg/output/options.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ type LumberjackOptions struct {
5353
}
5454

5555
type GcsOptions struct {
56-
ProjectID string // Project ID, needs to be unique with multiple buckets of the same name.
57-
Bucket string // Bucket name. Will create it if do not exist.
58-
Object string // Name of the object created inside the related Bucket.
56+
ProjectID string // Project ID, needs to be unique with multiple buckets of the same name.
57+
ObjectContentType string // The content-type set for the object that is created in the bucket, defaults to application/json
58+
Bucket string // Bucket name. Will create it if do not exist.
59+
Object string // Name of the object created inside the related Bucket.
5960
}

0 commit comments

Comments
 (0)