Skip to content

Commit ab70aa0

Browse files
feat: Allow skip of pre-helm install check
1 parent ad01f74 commit ab70aa0

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

functions/helm.ps1

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.2.0
2+
.VERSION 1.3.0
33
.GUID 04273f72-e001-415b-add0-e5e95e378355
44
.AUTHOR Code Dx
55
.DESCRIPTION Includes Helm-related helpers
@@ -67,12 +67,6 @@ function Invoke-HelmCommand([string] $message,
6767
[switch] $dryRun,
6868
[switch] $skipCRDs) {
6969

70-
if (-not $dryRun) {
71-
if (-not (Test-Namespace $namespace)) {
72-
New-Namespace $namespace
73-
}
74-
}
75-
7670
if (test-path $chartReference -pathtype container) {
7771
Write-Verbose 'Running helm dependency update...'
7872
helm dependency update $chartReference | Out-Null
@@ -82,7 +76,11 @@ function Invoke-HelmCommand([string] $message,
8276
}
8377

8478
if (-not $dryRun) {
85-
Wait-AllRunningPods "Pre-Helm Install: $message" $waitSeconds $namespace
79+
if (Test-Namespace $namespace) {
80+
Wait-AllRunningPods "Pre-Helm Install: $message" $waitSeconds $namespace
81+
} else {
82+
Write-Verbose "Skipping pre-helm install check because namespace '$namespace' does not exist or insufficient privileges affected the namespace test."
83+
}
8684
}
8785

8886
# NOTE: Latter values files take precedence over former ones
@@ -118,7 +116,7 @@ function Invoke-HelmCommand([string] $message,
118116
}
119117

120118
$crdAction = $skipCRDs ? '--skip-crds' : ''
121-
$helmOutput = helm upgrade --namespace $namespace --install $valuesParam $releaseName --timeout $timeout @($values) $chartReference @($versionParam) $crdAction $dryRunParam $debugParam
119+
$helmOutput = helm upgrade --namespace $namespace --install --create-namespace $valuesParam $releaseName --timeout $timeout @values $chartReference @versionParam $crdAction $dryRunParam $debugParam
122120
if ($LASTEXITCODE -ne 0) {
123121
throw "Unable to run helm upgrade/install, helm exited with code $LASTEXITCODE."
124122
}

functions/k8s.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.0
2+
.VERSION 1.0.1
33
.GUID bfaf255e-8e7b-4354-824f-46ac9625cab5
44
.AUTHOR Code Dx
55
.DESCRIPTION Includes Kubernetes-related helpers
@@ -107,7 +107,7 @@ function Get-KubectlContexts([switch] $nameOnly) {
107107
if ($nameOnly) {
108108
$output = '-o','name'
109109
}
110-
$contexts = kubectl config get-contexts @($output)
110+
$contexts = kubectl config get-contexts @output
111111
if ($LASTEXITCODE -ne 0) {
112112
throw "Unable to get kubectl contexts, kubectl exited with code $LASTEXITCODE."
113113
}

guided-setup.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'guided-setup'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.11.0'
15+
ModuleVersion = '1.12.0'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Core')

0 commit comments

Comments
 (0)