Skip to content

Commit

Permalink
[Google Cloud Storage] Add support for alternative_host for system te…
Browse files Browse the repository at this point in the history
…sts (#34413)

* [Google Cloud Storage] Add support for alternative_host to override HTTP client for system tests

* update changelog
  • Loading branch information
P1llus authored Jan 30, 2023
1 parent 70f9ae3 commit d1ef41c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff]
- Add beta `take over` mode for `filestream` for simple migration from `log` inputs {pull}34292[34292]
- Add pagination support for Salesforce module. {issue}34057[34057] {pull}34065[34065]
- Allow users to redact sensitive data from CEL input debug logs. {pull}34302[34302]
- Added support for HTTP destination override to Google Cloud Storage input. {pull}34413[34413]

*Auditbeat*

Expand Down
10 changes: 10 additions & 0 deletions x-pack/filebeat/input/gcs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package gcs
import (
"context"
"errors"
"net/url"

"cloud.google.com/go/storage"
"google.golang.org/api/option"
Expand All @@ -15,6 +16,15 @@ import (
)

func fetchStorageClient(ctx context.Context, cfg config, log *logp.Logger) (*storage.Client, error) {
if cfg.AlternativeHost != "" {
var h *url.URL
h, err := url.Parse(cfg.AlternativeHost)
if err != nil {
return nil, err
}
h.Path = "storage/v1/"
return storage.NewClient(ctx, option.WithEndpoint(h.String()), option.WithoutAuthentication())
}
if cfg.Auth.CredentialsJSON != nil {
return storage.NewClient(ctx, option.WithCredentialsJSON([]byte(cfg.Auth.CredentialsJSON.AccountKey)))
} else if cfg.Auth.CredentialsFile != nil {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/filebeat/input/gcs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type config struct {
ParseJSON *bool `config:"parse_json,omitempty"`
BucketTimeOut *time.Duration `config:"bucket_timeout,omitempty"`
Buckets []bucket `config:"buckets" validate:"required"`
// This field is only used for system test purposes, to override the HTTP endpoint.
AlternativeHost string `config:"alternative_host,omitempty"`
}

// bucket contains the config for each specific object storage bucket in the root account
Expand Down

0 comments on commit d1ef41c

Please sign in to comment.