Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert Out-File to WriteAllLines #125

Merged
merged 1 commit into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions windows/cert-deployer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$InformationPreference = 'SilentlyContinue'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False

Import-Module -WarningAction Ignore -Name "$PSScriptRoot\utils.psm1"
function Normal-Format
Expand All @@ -24,7 +25,7 @@ Get-ChildItem Env: | Select-Object -Property Key,Value | Where-Object {$_.Key -c

$path = "$sslCertsDir\$($key | Normal-Format).pem"
if ((-not (Exist-File -Path $path)) -or ($env:FORCE_DEPLOY -eq "true")) {
$val | Out-File -NoNewline -Encoding ascii -Force -FilePath $path
[System.IO.File]::WriteAllLines($path, $val, $Utf8NoBomEncoding)
}
}
Log-Info "Outputted PEM files for Kubernetes components"
Expand All @@ -36,7 +37,7 @@ Get-ChildItem Env: | Select-Object -Property Key,Value | Where-Object {$_.Key -c

$path = "$sslCertsDir\$($key | Normal-Format).yaml"
if (-not (Exist-File -Path $path)) {
$val | Out-File -NoNewline -Encoding ascii -Force -FilePath $path
[System.IO.File]::WriteAllLines($path, $val, $Utf8NoBomEncoding)
}
}
Log-Info "Outputted YAML files for Kubernetes components"
6 changes: 4 additions & 2 deletions windows/cloud-provider.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ $WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$InformationPreference = 'SilentlyContinue'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False

function Complete-AzureCloudConfig
{
Expand Down Expand Up @@ -140,7 +141,8 @@ function Complete-AzureCloudConfig
$azCloudConfig = $azCloudConfig | Add-Member -Force -NotePropertyMembers $azCloudConfigOverrided -PassThru

# output
$azCloudConfig | ConvertTo-Json -Compress -Depth 32 | Out-File -NoNewline -Force -FilePath $CloudConfigPath
$azCloudConfigJson = $azCloudConfig | ConvertTo-Json -Compress -Depth 32
[System.IO.File]::WriteAllLines($CloudConfigPath, $azCloudConfigJson, $Utf8NoBomEncoding)
Log-Info "Completed Azure cloud configuration successfully"
}
catch
Expand Down Expand Up @@ -231,7 +233,7 @@ function Get-NodeOverridedName
if ($nodeName -match " ") {
$nodeName = $nodeName.split(" ")[0] # take the first to be safe
}
$nodeName | Out-File -NoNewline -Force -FilePath "c:\run\cloud-provider-override-hostname"
[System.IO.File]::WriteAllLines("c:\run\cloud-provider-override-hostname", $nodeName, $Utf8NoBomEncoding)
Log-Info "Got overriding hostname $nodeName from metadata"
}
}
Expand Down
3 changes: 2 additions & 1 deletion windows/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$InformationPreference = 'SilentlyContinue'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False

Import-Module -WarningAction Ignore -Name @(
"$PSScriptRoot\utils.psm1"
Expand Down Expand Up @@ -162,7 +163,7 @@ switch ($command)
$kubeletDockerConfigB64 = $env:RKE_KUBELET_DOCKER_CONFIG
if ($kubeletDockerConfigB64) {
$kubeletDockerConfig = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($kubeletDockerConfigB64))
$kubeletDockerConfig | Out-File -NoNewline -Force -FilePath "c:\host\var\lib\kubelet\config.json"
[System.IO.File]::WriteAllLines("c:\host\var\lib\kubelet\config.json", $kubeletDockerConfig, $Utf8NoBomEncoding)
}
} catch{
Log-Warn "Could not put private registry Docker configuration to the host: $($_.Exception.Message)"
Expand Down
15 changes: 10 additions & 5 deletions windows/sidecar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $WarningPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
$DebugPreference = 'SilentlyContinue'
$InformationPreference = 'SilentlyContinue'
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False

Import-Module -WarningAction Ignore -Name @(
"$PSScriptRoot\utils.psm1"
Expand Down Expand Up @@ -199,7 +200,7 @@ if ($networkConfigObj)
}
}

@{
$flannelConflist = @{
name = $cniInfo.Interface
cniVersion = "0.2.0"
plugins = @(
Expand All @@ -211,7 +212,8 @@ if ($networkConfigObj)
delegate = $cniConfDelegate
}
)
} | ConvertTo-Json -Compress -Depth 32 | Out-File -NoNewline -Force -FilePath "c:\host\etc\cni\net.d\10-flannel.conflist"
} | ConvertTo-Json -Compress -Depth 32
[System.IO.File]::WriteAllLines("c:\host\etc\cni\net.d\10-flannel.conflist", $flannelConflist, $Utf8NoBomEncoding)

}

Expand All @@ -220,7 +222,8 @@ if ($networkConfigObj)
}

# output cni informantion for kube-proxy
$cniInfo | ConvertTo-Json -Compress -Depth 32 | Out-File -NoNewline -Force -FilePath "c:\run\cni-info.json"
$cniInfoJson = $cniInfo | ConvertTo-Json -Compress -Depth 32
[System.IO.File]::WriteAllLines("c:\run\cni-info.json", $cniInfoJson, $Utf8NoBomEncoding)

# start cni management
if ($networkConfigObj)
Expand Down Expand Up @@ -255,15 +258,17 @@ if ($networkConfigObj)
Log-Warn "Could not patch flannel network configration: $($_.Exception.Message)"
}

@{
$netConf = @{
Network = $clusterCIDR
Backend = @{
Name = $cniInfo.Interface
Type = $type
VNI = $vni
Port = $port
}
} | ConvertTo-Json -Compress -Depth 32 | Out-File -NoNewline -Force -FilePath "c:\host\etc\kube-flannel\net-conf.json"
} | ConvertTo-Json -Compress -Depth 32

[System.IO.File]::WriteAllLines("c:\host\etc\kube-flannel\net-conf.json", $netConf, $Utf8NoBomEncoding)

$flannelArgs = @(
# could not use kubernetes in-cluster client, indicate kubeconfig instead
Expand Down