@@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved. +# frozen_string_literal: true
+require 'set' +require 'pathname' +require_relative '../defconfig.rb'
+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
+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