for user deployed the whole compass-ci environment. if they submit job in their own environment, the sched will still verify the account with my_email, my_name and my_uuid. however they cannot build the info in es and the default yaml file by self. to resolve this problem for these users, add this script for them to run to build the info in es and default yaml file.
Signed-off-by: Luan Shengde shdluan@163.com --- sbin/build-my-info.rb | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 sbin/build-my-info.rb
diff --git a/sbin/build-my-info.rb b/sbin/build-my-info.rb new file mode 100755 index 0000000..73f7390 --- /dev/null +++ b/sbin/build-my-info.rb @@ -0,0 +1,50 @@ +#!/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 'json' +require 'fileutils' +require 'io/console' +require_relative '../lib/es_client' + +print 'email: ' +my_email = $stdin.echo = gets.chomp +print 'name: ' +my_name = $stdin.echo = gets.chomp +my_uuid = %x(uuidgen).chomp + +my_info = { + 'my_email' => my_email, + 'my_name' => my_name, + 'my_uuid' => my_uuid +} + +def store_account_info(my_info) + es = ESClient.new(index: 'accounts') + es.put_source_by_id(my_info['my_email'], my_info) +end + +def config_default_yaml(my_info) + yaml_dir = "#{ENV['HOME']}/.config/compass-ci/defaults" + FileUtils.mkdir_p yaml_dir unless File.directory? yaml_dir + yaml_file = "#{yaml_dir}/account.yaml" + FileUtils.touch(yaml_file) unless File.exist? yaml_file + + yaml_info = YAML.load_file(yaml_file) || {} + yaml_info.update my_info + + File.open(yaml_file, 'w') do |f| + f.puts yaml_info.to_yaml + end +end + +def complete_my_info(my_info) + my_info['my_login_name'] = '' + my_info['my_commit_url'] = '' + my_info['my_ssh_pubkey'] = [] +end + +config_default_yaml(my_info) +complete_my_info(my_info) +store_account_info(my_info)
Reviewed-by: Liu Yinsi liuyinsi@163.com
On Wed, Dec 09, 2020 at 11:50:39AM +0800, Luan Shengde wrote:
for user deployed the whole compass-ci environment. if they submit job in their own environment, the sched will still verify the account with my_email, my_name and my_uuid. however they cannot build the info in es and the default yaml file by self. to resolve this problem for these users, add this script for them to run to build the info in es and default yaml file.
Signed-off-by: Luan Shengde shdluan@163.com
sbin/build-my-info.rb | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 sbin/build-my-info.rb
diff --git a/sbin/build-my-info.rb b/sbin/build-my-info.rb new file mode 100755 index 0000000..73f7390 --- /dev/null +++ b/sbin/build-my-info.rb @@ -0,0 +1,50 @@ +#!/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 'json' +require 'fileutils' +require 'io/console' +require_relative '../lib/es_client'
+print 'email: ' +my_email = $stdin.echo = gets.chomp +print 'name: ' +my_name = $stdin.echo = gets.chomp +my_uuid = %x(uuidgen).chomp
+my_info = {
- 'my_email' => my_email,
- 'my_name' => my_name,
- 'my_uuid' => my_uuid
+}
+def store_account_info(my_info)
- es = ESClient.new(index: 'accounts')
- es.put_source_by_id(my_info['my_email'], my_info)
+end
+def config_default_yaml(my_info)
- yaml_dir = "#{ENV['HOME']}/.config/compass-ci/defaults"
- FileUtils.mkdir_p yaml_dir unless File.directory? yaml_dir
- yaml_file = "#{yaml_dir}/account.yaml"
- FileUtils.touch(yaml_file) unless File.exist? yaml_file
- yaml_info = YAML.load_file(yaml_file) || {}
- yaml_info.update my_info
- File.open(yaml_file, 'w') do |f|
- f.puts yaml_info.to_yaml
- end
+end
+def complete_my_info(my_info)
- my_info['my_login_name'] = ''
- my_info['my_commit_url'] = ''
- my_info['my_ssh_pubkey'] = []
+end
+config_default_yaml(my_info) +complete_my_info(my_info)
+store_account_info(my_info)
2.23.0