From b2d6820d5db1a973aa9a0ce26c03d67257a5e558 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Fri, 7 Apr 2023 11:13:45 +0900 Subject: [PATCH] Refactor handling of tmpauth account line This replaces the existing implementation using inline_template by more native functions, to help us maintain the logic more easily. Change-Id: Ib775edfa6a3a62a6889c9de334b1563f3819146a --- manifests/proxy/tempauth.pp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/manifests/proxy/tempauth.pp b/manifests/proxy/tempauth.pp index 64134b61..5aea97ce 100644 --- a/manifests/proxy/tempauth.pp +++ b/manifests/proxy/tempauth.pp @@ -120,14 +120,18 @@ class swift::proxy::tempauth ( # ex: user_admin_admin=admin .admin .reseller_admin # account_data is an array with each element containing a single account string: # ex [user__, . .] - if $account_user_list { - $account_data = split(inline_template( - "<% @account_user_list.each do |user| %>\ - user_<%= user['account'] %>_<%= user['user'] %>,\ - <%= user['key'] %> <%= user['groups'].map { |g| '.' + g }.join(' ') %> ; <% end %>"),';') + $account_user_list.each |$account_user| { + validate_legacy(Array, 'validate_array', $account_user['groups']) + + $account_base = "user_${account_user['account']}_${account_user['user']}, ${account_user['key']}" + $groups = empty($account_user) ? { + true => undef, + default => join([''] + $account_user['groups'], ' .') + } + + $account_data = join(delete_undef_values([$account_base, $groups]), '') # write each temauth account line to file - # TODO replace/simplify with iterators once all supported puppet versions support them. swift::proxy::tempauth_account { $account_data: } } }