mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #84434 from yliaog/windows
removed powershell-yaml module dependency
This commit is contained in:
commit
59e7a4f474
@ -147,6 +147,43 @@ function Dump-DebugInfoToConsole {
|
|||||||
} Catch { }
|
} Catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Converts the kube-env string in Yaml
|
||||||
|
#
|
||||||
|
# Returns: a PowerShell Hashtable object containing the key-value pairs from
|
||||||
|
# kube-env.
|
||||||
|
function ConvertFrom-Yaml-KubeEnv {
|
||||||
|
param (
|
||||||
|
[parameter(Mandatory=$true)] [string]$kube_env_str
|
||||||
|
)
|
||||||
|
$kube_env_table = @{}
|
||||||
|
$currentLine = $null
|
||||||
|
switch -regex (${kube_env_str} -split '\r?\n') {
|
||||||
|
'^(\S.*)' {
|
||||||
|
# record start pattern, line that doesn't start with a whitespace
|
||||||
|
if ($null -ne $currentLine) {
|
||||||
|
$key, $val = $currentLine -split ":",2
|
||||||
|
$kube_env_table[$key] = $val.Trim("'", " ", "`"")
|
||||||
|
}
|
||||||
|
$currentLine = $matches.1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
'^(\s+.*)' {
|
||||||
|
# line that start with whitespace
|
||||||
|
$currentLine += $matches.1
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle the last line if any
|
||||||
|
if ($currentLine) {
|
||||||
|
$key, $val = $currentLine -split ":",2
|
||||||
|
$kube_env_table[$key] = $val.Trim("'", " ", "`"")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ${kube_env_table}
|
||||||
|
}
|
||||||
|
|
||||||
# Fetches the kube-env from the instance metadata.
|
# Fetches the kube-env from the instance metadata.
|
||||||
#
|
#
|
||||||
# Returns: a PowerShell Hashtable object containing the key-value pairs from
|
# Returns: a PowerShell Hashtable object containing the key-value pairs from
|
||||||
@ -157,13 +194,13 @@ function Fetch-KubeEnv {
|
|||||||
# ${kube_env} = Get-InstanceMetadataAttribute 'kube-env'
|
# ${kube_env} = Get-InstanceMetadataAttribute 'kube-env'
|
||||||
# or:
|
# or:
|
||||||
# ${kube_env} = [IO.File]::ReadAllText(".\kubeEnv.txt")
|
# ${kube_env} = [IO.File]::ReadAllText(".\kubeEnv.txt")
|
||||||
# ${kube_env_table} = ConvertFrom-Yaml ${kube_env}
|
# ${kube_env_table} = ConvertFrom-Yaml-KubeEnv ${kube_env}
|
||||||
# ${kube_env_table}
|
# ${kube_env_table}
|
||||||
# ${kube_env_table}.GetType()
|
# ${kube_env_table}.GetType()
|
||||||
|
|
||||||
# The type of kube_env is a powershell String.
|
# The type of kube_env is a powershell String.
|
||||||
$kube_env = Get-InstanceMetadataAttribute 'kube-env'
|
$kube_env = Get-InstanceMetadataAttribute 'kube-env'
|
||||||
$kube_env_table = ConvertFrom-Yaml ${kube_env}
|
$kube_env_table = ConvertFrom-Yaml-KubeEnv ${kube_env}
|
||||||
return ${kube_env_table}
|
return ${kube_env_table}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,10 +275,6 @@ function Set-PrerequisiteOptions {
|
|||||||
# Use TLS 1.2: needed for Invoke-WebRequest downloads from github.com.
|
# Use TLS 1.2: needed for Invoke-WebRequest downloads from github.com.
|
||||||
[Net.ServicePointManager]::SecurityProtocol = `
|
[Net.ServicePointManager]::SecurityProtocol = `
|
||||||
[Net.SecurityProtocolType]::Tls12
|
[Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
# https://github.com/cloudbase/powershell-yaml
|
|
||||||
Log-Output "Installing powershell-yaml module from external repo"
|
|
||||||
Install-Module -Name powershell-yaml -Force
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Creates directories where other functions in this module will read and write
|
# Creates directories where other functions in this module will read and write
|
||||||
|
Loading…
Reference in New Issue
Block a user