Module: Fluent::KafkaPluginUtil::GsmSettings
- Included in:
- Fluent::Kafka2Output, Fluent::KafkaOutput, Fluent::KafkaOutputBuffered
- Defined in:
- lib/fluent/plugin/kafka_plugin_util.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fluent/plugin/kafka_plugin_util.rb', line 70 def self.included(klass) klass.instance_eval { config_param :secretName, :string, :default => nil, :desc => "the gsm secret name" config_param :projectId, :string, :default => nil, :desc => "the gsm project id" config_param :version, :string, :default => "latest", :desc => "version of secret to fetch, default: latest" } end |
Instance Method Details
#fetch ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fluent/plugin/kafka_plugin_util.rb', line 81 def fetch puts "using following to fetch from GSM" puts "project id: #{@projectId}" puts "secret name: #{@secretName}" puts "version: #{@version}" client = Google::Cloud::SecretManager.secret_manager_service req = client.secret_version_path( project: @projectId, secret: @secretName, secret_version: @version ) res = client.access_secret_version name: req s = res.payload.data.split("\n") if s.length < 1 raise Fluent::ConfigError, "GSM response too short" end @username = s[0] @password = s[1] s end |