diff options
Diffstat (limited to 'bootstrap/pillar_config.rb')
| -rwxr-xr-x | bootstrap/pillar_config.rb | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/bootstrap/pillar_config.rb b/bootstrap/pillar_config.rb index 8b4abb4..9b0b1bb 100755 --- a/bootstrap/pillar_config.rb +++ b/bootstrap/pillar_config.rb @@ -2,6 +2,7 @@ require_relative 'http_client' require 'digest' +require 'getoptlong' require "json" require 'socket' require "yaml" @@ -27,7 +28,7 @@ def get_ip_address() end end -def get_jar_versions(yml) +def get_jar_versions(yml, branch) ret = Hash.new begin http_client = HttpClient.new(url: yml["jars"]["url"], @@ -35,7 +36,7 @@ def get_jar_versions(yml) password: yml["jars"]["password"]) http_client.do_http(method: :propfind) http_client.response.each_line do |line| - if line =~ /D:href.*\.jar/ + if line =~ /D:href.*#{branch}.*\.jar/ jar_name = line.chomp.split(/[<>]/)[2] jarparts = jar_name.split(/\//) name, *version_parts, junk1 = jarparts[jarparts.length - 1].split(".") @@ -72,8 +73,18 @@ def process_yaml() end def main() + branch = "" + opts = GetoptLong.new(["--branch", "-b", GetoptLong::REQUIRED_ARGUMENT]) + + opts.each do |opt, arg| + case opt + when "--branch" + branch = arg + end + end + yml = process_yaml() - puts yml.merge(get_jar_versions(yml)).to_json + puts yml.merge(get_jar_versions(yml, branch)).to_json end main() |
