Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Google Cloud Storage] Add support for alternative_host for system tests #34413

Merged
merged 3 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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