From 4dc8a9413d04a27fac953e33ce32e85fddca8a9d Mon Sep 17 00:00:00 2001 From: Peter Wilcsinszky Date: Fri, 5 Jan 2024 10:29:17 +0100 Subject: [PATCH] feat: inline credentials support Signed-off-by: Peter Wilcsinszky --- lib/fluent/plugin/out_gcs.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/fluent/plugin/out_gcs.rb b/lib/fluent/plugin/out_gcs.rb index 43b6526..e8e5c77 100644 --- a/lib/fluent/plugin/out_gcs.rb +++ b/lib/fluent/plugin/out_gcs.rb @@ -22,6 +22,8 @@ def initialize desc: "Project identifier for GCS" config_param :keyfile, :string, default: nil, desc: "Path of GCS service account credentials JSON file" + config_param :credentials_json, :hash, default: nil, secret: true, + desc: "GCS service account credentials in JSON format" config_param :client_retries, :integer, default: nil, desc: "Number of times to retry requests on server error" config_param :client_timeout, :integer, default: nil, @@ -94,12 +96,18 @@ def configure(conf) # TODO: Remove time_slice_format when end of support compat_parameters @configured_time_slice_format = conf['time_slice_format'] @time_slice_with_tz = Fluent::Timezone.formatter(@timekey_zone, @configured_time_slice_format || timekey_to_timeformat(@buffer_config['timekey'])) + + if @credentials_json + @credentials = @credentials_json + else + @credentials = keyfile + end end def start @gcs = Google::Cloud::Storage.new( project: @project, - keyfile: @keyfile, + keyfile: @credentials, retries: @client_retries, timeout: @client_timeout )