elastic / jarvis

Logstash's ChatOps bot, J.A.R.V.I.S.
41 stars 28 forks source link

Feat: LOGSTASH_PATH auto expanding #100

Closed kares closed 4 years ago

kares commented 4 years ago

this is mostly to be able to publish LS plugins, a Gemfile usually looks like:

logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"

if Dir.exist?(logstash_path) && use_logstash_source
  gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
  gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
end

plugins usually depend on logstash-core and/or logstash-code-plugin-api gems plugin-api hasn't been released in a while and possible logstash-core releases will halt as well

publish command adds --env "LOGSTASH_SOURCE=1 LOGSTASH_PATH=#{releases[last]}" defaults where LOGSTASH_PATH='#{latest}' is tracked and #(enclosed) value gets substituted based on LS' release information (one could also override a specific version with LOGSTASH_PATH='#{7.5.1}')

the brackets #{...} part (#(...) also works - did not figure out anything more suitable) causes a LS release tar.gz download and gems extraction into a temp dir to substitute a valid LOGSTASH_PATH=...

kares commented 4 years ago

should have noted that both @jarvis publish ... and the new @jarvis run ... rake release where tested manually (using --env "LOGSTASH_SOURCE=1 LOGSTASH_PATH=#{latest}" for run cmd)