Sha256: 46d562a0faea80cce25f465a9fccb7ee92a7be1e46dde668c444393c84757f96

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

class Caco::Prometheus::AdapterInstallPostgresql < Trailblazer::Operation
  step :check_root
  step :build_url
  step :mkdir_target

  step Subprocess(Caco::Downloader),
    input: ->(ctx, url:, dest:, **) {{
      url: url,
      dest: dest,
      stubbed_file: ctx[:stubbed_file]    
    }}

  step Subprocess(Caco::Unpacker),
    input: ->(ctx, adapter_root:, dest:, **) {{
      pack: dest,
      dest: adapter_root
    }}

  step Subprocess(Caco::FileLink),
    input: ->(ctx, current_target:, current_link:, **) {{
      target: current_target,
      link: current_link
    }}

  step Subprocess(Caco::Debian::ServiceInstall),
    input: ->(ctx, current_link:, database:, host:, username:, password:, **) {{
      name: "prometheus-adapter-postgresql",
      command: "#{current_link}/prometheus-postgresql-adapter -pg-database #{database} -pg-host #{host} -pg-user #{username} -pg-password #{password} -log-level warn"
    }}

  def check_root(ctx, version:, **)
    ctx[:root] = Settings.prometheus.root
    ctx[:adapter_root] = "#{Settings.prometheus.root}/postgresql-adapter-#{version}.linux-amd64"
    FileUtils.mkdir_p(ctx[:adapter_root])
  end

  def build_url(ctx, version:, root:, adapter_root:, **)
    ctx[:url] = "https://github.com/timescale/prometheus-postgresql-adapter/releases/download/v#{version}/prometheus-postgresql-adapter-#{version}-linux-amd64.tar.gz"
    ctx[:dest] = "#{root}/prometheus-postgresql-adapter-#{version}-linux-amd64.tar.gz"
    ctx[:current_target] = adapter_root
    ctx[:current_link] = "#{root}/postgresql-adapter-current"
  end

  def mkdir_target(ctx, current_target:, **)
    FileUtils.mkdir_p(current_target)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caco-0.1.0 lib/caco/prometheus/adapter_install_postgresql.rb