[PATCH compass-ci] container/mail-robot: fix bugs

fix no file errors: it may throw error if the specified file not exists: Errno::ENOENT: No such file or directory @ rb_sysopen Signed-off-by: Luan Shengde <shdluan@163.com> --- container/mail-robot/lib/apply-account.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/container/mail-robot/lib/apply-account.rb b/container/mail-robot/lib/apply-account.rb index 798546a..6b9bdfe 100755 --- a/container/mail-robot/lib/apply-account.rb +++ b/container/mail-robot/lib/apply-account.rb @@ -56,7 +56,11 @@ class ApplyAccount @es_port = ES_PORT # email info file for account issuers. - @account_issuer = YAML.load_file ENV['ACCOUNT_ISSUER'] + @account_issuer = if File.exists? ENV['ACCOUNT_ISSUER'] + YAML.load_file ENV['ACCOUNT_ISSUER'] + else + {} + end @my_info = {} end -- 2.23.0

On Tue, Apr 06, 2021 at 09:44:06AM +0800, Luan Shengde wrote:
fix no file errors: it may throw error if the specified file not exists:
Errno::ENOENT: No such file or directory @ rb_sysopen
Signed-off-by: Luan Shengde <shdluan@163.com> --- container/mail-robot/lib/apply-account.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/container/mail-robot/lib/apply-account.rb b/container/mail-robot/lib/apply-account.rb index 798546a..6b9bdfe 100755 --- a/container/mail-robot/lib/apply-account.rb +++ b/container/mail-robot/lib/apply-account.rb @@ -56,7 +56,11 @@ class ApplyAccount @es_port = ES_PORT
# email info file for account issuers. - @account_issuer = YAML.load_file ENV['ACCOUNT_ISSUER'] + @account_issuer = if File.exists? ENV['ACCOUNT_ISSUER'] + YAML.load_file ENV['ACCOUNT_ISSUER'] + else + {} + end
Use ?: operation? Thanks, Xueliang
@my_info = {} end -- 2.23.0

diff --git a/container/mail-robot/lib/apply-account.rb b/container/mail-robot/lib/apply-account.rb index 798546a..6b9bdfe 100755 --- a/container/mail-robot/lib/apply-account.rb +++ b/container/mail-robot/lib/apply-account.rb @@ -56,7 +56,11 @@ class ApplyAccount @es_port = ES_PORT
# email info file for account issuers. - @account_issuer = YAML.load_file ENV['ACCOUNT_ISSUER'] + @account_issuer = if File.exists? ENV['ACCOUNT_ISSUER'] + YAML.load_file ENV['ACCOUNT_ISSUER'] + else + {} + end
Use ?: operation?
I didn't catch what do you mean. the ENV['ACCOUNT_ISSUER'] is an environment variable for account issuer file. to avoid unexpected no file errors, do some check. Thanks, Luan Shengde
Thanks, Xueliang
@my_info = {} end -- 2.23.0

On Wed, Apr 07, 2021 at 09:11:15AM +0800, Luan Shengde wrote:
diff --git a/container/mail-robot/lib/apply-account.rb b/container/mail-robot/lib/apply-account.rb index 798546a..6b9bdfe 100755 --- a/container/mail-robot/lib/apply-account.rb +++ b/container/mail-robot/lib/apply-account.rb @@ -56,7 +56,11 @@ class ApplyAccount @es_port = ES_PORT
# email info file for account issuers. - @account_issuer = YAML.load_file ENV['ACCOUNT_ISSUER'] + @account_issuer = if File.exists? ENV['ACCOUNT_ISSUER'] + YAML.load_file ENV['ACCOUNT_ISSUER'] + else + {} + end
Use ?: operation?
I didn't catch what do you mean. the ENV['ACCOUNT_ISSUER'] is an environment variable for account issuer file. to avoid unexpected no file errors, do some check.
the ?: is ternary operation, example: msg = possible_new_refs == -1 ? 'git fetch fail' : 'git clone fail' Thanks, Xueliang
Thanks, Luan Shengde
Thanks, Xueliang
@my_info = {} end -- 2.23.0

the ENV['ACCOUNT_ISSUER'] is an environment variable for account issuer file. to avoid unexpected no file errors, do some check.
the ?: is ternary operation, example: msg = possible_new_refs == -1 ? 'git fetch fail' : 'git clone fail'
ok, I got it Thanks, Luan Shengde
Thanks, Xueliang
Thanks, Luan Shengde
Thanks, Xueliang
@my_info = {} end -- 2.23.0
participants (2)
-
Cao Xueliang
-
Luan Shengde