From ae765b99ac1c7fd16df4198cf798354226eac784 Mon Sep 17 00:00:00 2001 From: johnpaul Date: Tue, 12 Dec 2023 18:04:36 +0100 Subject: [PATCH] update unless --- manifests/repo.pp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/manifests/repo.pp b/manifests/repo.pp index 742265f..d8848b6 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -89,12 +89,6 @@ Optional[String] $url = undef, ) { include ::helm::params - if $repo_config != undef { - $unless_repo = "helm repo list --repository-config ${repo_config} | awk '{if(NR>1)print \$1}' | grep -w ${repo_name}" - } else { - $unless_repo = "helm repo list | awk '{if(NR>1)print \$1}' | grep -w ${repo_name}" - } - notify { "unless_repo -> '${unless_repo}'": } if $ensure == present { $helm_repo_add_flags = helm_repo_add_flags({ ensure => $ensure, @@ -117,6 +111,12 @@ } ) $exec_repo = "helm repo add ${helm_repo_add_flags}" + if $repo_config != undef { + $unless_repo = "helm repo list --repository-config ${repo_config} | awk '{if (\$1 == \"${repo_name}\") exit 0}'" + } else { + $unless_repo = "helm repo list | awk '{if (\$1 == \"${repo_name}\") exit 0}'" + } + notify { "unless_repo -> '${unless_repo}'": } } if $ensure == absent { @@ -133,6 +133,12 @@ } ) $exec_repo = "helm repo remove ${helm_repo_remove_flags}" + if $repo_config != undef { + $unless_repo = "helm repo list --repository-config ${repo_config} | awk '{if (\$1 == \"${repo_name}\") exit 1}'" + } else { + $unless_repo = "helm repo list | awk '{if (\$1 == \"${repo_name}\") exit 1}'" + } + notify { "unless_repo -> '${unless_repo}'": } } exec { "helm repo ${repo_name}":