Skip to content

Commit 9033fbd

Browse files
v-davegillies-upscalecw-Guo
authored andcommitted
allow s3 output plugin to get keys from secrets
Signed-off-by: Dave Gillies <[email protected]>
1 parent 5585e9b commit 9033fbd

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

apis/fluentd/v1alpha1/plugins/output/s3.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package output
22

3+
import "github.com/fluent/fluent-operator/v3/apis/fluentd/v1alpha1/plugins"
4+
35
// S3 defines the parameters for out_s3 output plugin
46
type S3 struct {
57
// The AWS access key id.
6-
AwsKeyId *string `json:"awsKeyId,omitempty"`
8+
AwsKeyId *plugins.Secret `json:"awsKeyId,omitempty"`
79
// The AWS secret key.
8-
AwsSecKey *string `json:"awsSecKey,omitempty"`
10+
AwsSecKey *plugins.Secret `json:"awsSecKey,omitempty"`
911
// The Amazon S3 bucket name.
1012
S3Bucket *string `json:"s3Bucket,omitempty"`
1113
// The Amazon S3 region name

apis/fluentd/v1alpha1/plugins/output/types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,18 @@ func (o *Output) kafka2Plugin(parent *params.PluginStore, loader plugins.SecretL
678678

679679
func (o *Output) s3Plugin(parent *params.PluginStore, loader plugins.SecretLoader) *params.PluginStore {
680680
if o.S3.AwsKeyId != nil {
681-
parent.InsertPairs("aws_key_id", fmt.Sprint(*o.S3.AwsKeyId))
681+
value, err := loader.LoadSecret(*o.S3.AwsKeyId)
682+
if err != nil {
683+
return nil
684+
}
685+
parent.InsertPairs("aws_key_id", value)
682686
}
683687
if o.S3.AwsSecKey != nil {
684-
parent.InsertPairs("aws_sec_key", fmt.Sprint(*o.S3.AwsSecKey))
688+
value, err := loader.LoadSecret(*o.S3.AwsSecKey)
689+
if err != nil {
690+
return nil
691+
}
692+
parent.InsertPairs("aws_sec_key", value)
685693
}
686694
if o.S3.S3Bucket != nil {
687695
parent.InsertPairs("s3_bucket", fmt.Sprint(*o.S3.S3Bucket))

docs/plugins/fluentd/output/s3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ S3 defines the parameters for out_s3 output plugin
55

66
| Field | Description | Scheme |
77
| ----- | ----------- | ------ |
8-
| awsKeyId | The AWS access key id. | *string |
9-
| awsSecKey | The AWS secret key. | *string |
8+
| awsKeyId | | *[plugins.Secret](../secret.md) |
9+
| awsSecKey | | *[plugins.Secret](../secret.md) |
1010
| s3Bucket | The Amazon S3 bucket name. | *string |
1111
| s3Region | The Amazon S3 region name | *string |
1212
| s3Endpoint | The endpoint URL (like \"http://localhost:9000/\") | *string |

0 commit comments

Comments
 (0)