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

GCS: fix the WithoutAuthentication option #290

Merged
merged 3 commits into from
Sep 20, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ log:
level: INFO
console: true
files:
- logs/nebula-importer.log
- logs/nebula-importer.log
```

* `log.level`: **Optional**. Specifies the log level, optional values is `DEBUG`, `INFO`, `WARN`, `ERROR`, `PANIC` or `FATAL`. The default value is `INFO`.
Expand Down Expand Up @@ -299,13 +299,15 @@ gcs:
key: <key>
credentialsFile: <Service account or refresh token JSON credentials file>
credentialsJSON: <Service account or refresh token JSON credentials>
withoutAuthentication: <false | true>
```

* `endpoint`: **Optional**. The endpoint of GCS service.
* `bucket`: **Required**. The bucket of file in GCS service.
* `key`: **Required**. The object key of file in GCS service.
* `credentialsFile`: **Optional**. Path to the service account or refresh token JSON credentials file. Not required for public data.
* `credentialsJSON`: **Optional**. Content of the service account or refresh token JSON credentials file. Not required for public data.
* `withoutAuthentication`: **Optional**. Specifies that no authentication should be used, defaults to `false`.

#### batch

Expand Down
13 changes: 7 additions & 6 deletions pkg/source/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ var _ Source = (*gcsSource)(nil)

type (
GCSConfig struct {
Endpoint string `yaml:"endpoint,omitempty"`
CredentialsFile string `yaml:"credentialsFile,omitempty"`
CredentialsJSON string `yaml:"credentialsJSON,omitempty"`
Bucket string `yaml:"bucket,omitempty"`
Key string `yaml:"key,omitempty"`
Endpoint string `yaml:"endpoint,omitempty"`
CredentialsFile string `yaml:"credentialsFile,omitempty"`
CredentialsJSON string `yaml:"credentialsJSON,omitempty"`
WithoutAuthentication bool `yaml:"withoutAuthentication,omitempty"`
Bucket string `yaml:"bucket,omitempty"`
Key string `yaml:"key,omitempty"`
}

gcsSource struct {
Expand Down Expand Up @@ -46,7 +47,7 @@ func (s *gcsSource) Open() error {
gcsOptions = append(gcsOptions, option.WithCredentialsFile(s.c.GCS.CredentialsFile))
} else if s.c.GCS.CredentialsJSON != "" {
gcsOptions = append(gcsOptions, option.WithCredentialsJSON([]byte(s.c.GCS.CredentialsJSON)))
} else {
} else if s.c.GCS.WithoutAuthentication {
gcsOptions = append(gcsOptions, option.WithoutAuthentication())
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/source/gcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ var _ = Describe("gcsSource", func() {

c := Config{
GCS: &GCSConfig{
Endpoint: httpServer.URL,
Bucket: "bucket",
Key: "key",
Endpoint: httpServer.URL,
Bucket: "bucket",
Key: "key",
WithoutAuthentication: true,
},
}

Expand Down