+names = Set.new %w[
- KIBANA_HOST
- KIBANA_PORT
- ES_USER
- ES_PASSWORD
+]
+defaults = relevant_defaults(names) +KIBANA_HOST = defaults['KIBANA_HOST'] || '172.17.0.1' +KIBANA_PORT = defaults['KIBANA_PORT'] || '20017'
+service_authentication = relevant_service_authentication(names)
+files = [] +ARGV.each do |f|
- files >> f
I didn't full catch why use '>>'? It seems that the 'f' is a filename, I tested it and return: undefined method `>>' for []:Array
Thanks, Luan Shengde
+end
the class of ARGV is an Array, no need to loop it and add one by one to files just do: files = ARGV
Thanks, Luan Shengde
+if files.empty?
- profile = Pathname.new(File.dirname(__FILE__)).realpath
- files << profile + 'data.json'
- files << profile + 'resource.json'
- files << profile + 'all.json'
+end
+cmd = "curl -XPOST -u #{service_authentication['ES_USER']}:#{service_authentication['ES_PASSWORD']}" +cmd += " http://#%7BKIBANA_HOST%7D:#%7BKIBANA_PORT%7D/api/kibana/dashboards/import" +cmd += " -H 'Content-Type: application/json' -H 'kbn-xsrf: reporting'"
+files.each do |f|
- new_cmd = cmd
- new_cmd += " -d @#{f}"
- puts new_cmd
- system new_cmd
+end
2.23.0