class Fastlane::Actions::InfluxdbAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 30
def self.authors
  ["giginet"]
end
available_options() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 42
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :db_name,
                            env_name: "INFLUXDB_DB_NAME",
                         description: "DB name of InfluxDB",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :host,
                            env_name: "INFLUXDB_HOST",
                         description: "Host of InfluxDB",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :port,
                            env_name: "INFLUXDB_PORT",
                         description: "Port of InfluxDB",
                            optional: false,
                       default_value: 8086,
                                type: Integer),
    FastlaneCore::ConfigItem.new(key: :use_ssl,
                            env_name: "INFLUXDB_USE_SSL",
                         description: "Whether or not to use SSL (HTTPS)",
                            optional: true,
                       default_value: false,
                           is_string: false),
    FastlaneCore::ConfigItem.new(key: :verify_ssl,
                            env_name: "INFLUXDB_VERIFY_SSL",
                         description: "Verify certificate when using SSL",
                            optional: true,
                       default_value: true,
                           is_string: false),
    FastlaneCore::ConfigItem.new(key: :username,
                            env_name: "INFLUXDB_USERNAME",
                         description: "User name of InfluxDB",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :password,
                            env_name: "INFLUXDB_PASSWORD",
                         description: "Password of InfluxDB",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :table_name,
                            env_name: "INFLUXDB_TABLE_NAME",
                         description: "Table name of InfluxDB",
                            optional: false,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :tags,
                         description: "Tags to post",
                            optional: true,
                                type: Hash),
    FastlaneCore::ConfigItem.new(key: :values,
                         description: "Values to post",
                            optional: false,
                                type: Hash)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 26
def self.description
  "Post values to IndluxDB"
end
details() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 38
def self.details
  "Post values to InfluxDB"
end
example_code() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 98
def self.example_code
  [
    'influxdb(
      db_name: "sample_db",
      host: "fastlane.influxdb.com",
      port: 1234,
      use_ssl: true,
      username: "sample",
      password: "password",
      table_name: "metrics",
      tags: {tag1: "foo", tag2: "bar"}
      values: {a: 100, b: 200, c: 300}
    )'
  ]
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 114
def self.is_supported?(platform)
  true
end
return_value() click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 34
def self.return_value
  "nil or error message"
end
run(params) click to toggle source
# File lib/fastlane/plugin/influxdb/actions/influxdb_action.rb, line 6
def self.run(params)
  client ||= InfluxDB::Client.new(
    params[:db_name],
    host: params[:host],
    port: params[:port],
    use_ssl: params[:use_ssl],
    verify_ssl: params[:verify_ssl],
    username: params[:username],
    password: params[:password]
  )

  begin
    client.write_point(params[:table_name], { tags: params[:tags], values: params[:values] })
    UI.success("Successfully posted values to '#{params[:table_name]}'")
  rescue StandardError => e
    response = JSON.parse(e.to_s)
    UI.user_error!(response['error'])
  end
end