Skip to content

Commit

Permalink
Remove test consoles
Browse files Browse the repository at this point in the history
  • Loading branch information
yinghsugn committed Feb 6, 2023
1 parent 37a75ce commit 9490c92
Showing 1 changed file with 34 additions and 40 deletions.
74 changes: 34 additions & 40 deletions src/ConnectedKubernetes/custom/New-AzConnectedKubernetes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ function New-AzConnectedKubernetes {

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
[System.String]
[ValidateRange(0,3600)]
[Int]
# The timeout for onboarding azure-arc
${OnboardingTimeout} = "600",
${OnboardingTimeout} = 600,

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.ConnectedKubernetes.Category('Path')]
Expand Down Expand Up @@ -260,7 +261,7 @@ function New-AzConnectedKubernetes {
if ($PSBoundParameters.ContainsKey('KubeContext')) {
$Null = $PSBoundParameters.Remove('KubeContext')
}
if (($KubeContext -eq $null) -or ($KubeContext -eq '')) {
if (($null -eq $KubeContext) -or ($KubeContext -eq '')) {
$KubeContext = kubectl config current-context
}

Expand Down Expand Up @@ -406,85 +407,78 @@ function New-AzConnectedKubernetes {
$ChartPath = $HelmChartPath
}

$PSBoundParameters.Add('AgentPublicKeyCertificate', $AgentPublicKey)
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters

$TenantId = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.Tenant.Id

$options = ""
$proxyEnableState = $false
Write-Host ">>> Check args: ProxyHttp (before)"
Write-Host "$ProxyHttp"
if ($null -ne $ProxyHttp) {
if (-not ([string]::IsNullOrEmpty($ProxyHttp))) {
$ProxyHttp = $ProxyHttp -replace ',','\,'
$ProxyHttp = $ProxyHttp -replace '/','\/'
$options += " --set global.httpProxy=$ProxyHttp"
$proxyEnableState = $true
Write-Host ">>> Check args: ProxyHttp (after)"
Write-Host "$ProxyHttp"
$Null = $PSBoundParameters.Remove('ProxyHttp')
}

Write-Host ">>> Check args: ProxyHttps (before)"
Write-Host "$ProxyHttps"
if ($null -ne $ProxyHttps) {
if (-not ([string]::IsNullOrEmpty($ProxyHttps))) {
$ProxyHttps = $ProxyHttps -replace ',','\,'
$ProxyHttps = $ProxyHttps -replace '/','\/'
$options += " --set global.httpsProxy=$ProxyHttps"
$proxyEnableState = $true
Write-Host ">>> Check args: ProxyHttps (after)"
Write-Host "$ProxyHttps"
$Null = $PSBoundParameters.Remove('ProxyHttps')
}

Write-Host ">>> Check args: ProxyNo (before)"
Write-Host "$ProxyNo"
if ($null -ne $ProxyNo) {
if (-not ([string]::IsNullOrEmpty($ProxyNo))) {
$ProxyNo = $ProxyNo -replace ',','\,'
$ProxyNo = $ProxyNo -replace '/','\/'
$options += " --set global.noProxy=$ProxyNo"
$proxyEnableState = $true
Write-Host ">>> Check args: ProxyNo (after)"
Write-Host "$ProxyNo"
$Null = $PSBoundParameters.Remove('ProxyNo')
}

if($proxyEnableState) {
$options += " --set global.isProxyEnabled=true"
}

try {
if (($PSBoundParameters.ContainsKey('ProxyCredential')) -and (Test-Path $ProxyCredential)) {
$options += " --set-file global.proxyCert=$ProxyCredential"
$options += " --set global.isCustomCert=true"
}
} catch {
Write-Error "Unable to find ProxyCrendial"
throw
}

if($DisableAutoUpgrade) {
$options += " --set systemDefaultValues.azureArcAgents.autoUpdate=false"
$Null = $PSBoundParameters.Remove('DisableAutoUpgrade')
}

if($null -ne $ContainerLogPath) {
if(-not ([string]::IsNullOrEmpty($ContainerLogPath))) {
$options += " --set systemDefaultValues.fluent-bit.containerLogPath=$ContainerLogPath"
$Null = $PSBoundParameters.Remove('ContainerLogPath')
}

# Write-Host ">>> Check args: ProxyCredential"
# Write-Host "$ProxyCredential"
# Write-Host ">>> Check args: ProxyUseDefaultCredentials"
# Write-Host "$ProxyUseDefaultCredentials"

Write-Host ">>> Check args: KubeConfig"
Write-Host "$KubeConfig"
if ($null -ne $KubeConfig) {
if (-not ([string]::IsNullOrEmpty($KubeConfig))) {
$options += " --kubeconfig $KubeConfig"
}

Write-Host ">>> Check args: KubeContext"
Write-Host "$KubeContext"
if ($null -ne $KubeContext) {
if (-not ([string]::IsNullOrEmpty($KubeContext))) {
$options += " --kube-context $KubeContext"
}

Write-Host ">>> Check args: NoWait"
Write-Host "$NoWait"
if (!$NoWait) {
$options += " --wait --timeout $OnboardingTimeout"
$options += "s"
}

Write-Host ">>> Check options:"
Write-Host $options
Write-Host "helm upgrade --install azure-arc $ChartPath"
if ($PSBoundParameters.ContainsKey('OnboardingTimeout')) {
$PSBoundParameters.Remove('OnboardingTimeout')
}

$PSBoundParameters.Add('AgentPublicKeyCertificate', $AgentPublicKey)
$Response = Az.ConnectedKubernetes.internal\New-AzConnectedKubernetes @PSBoundParameters

$TenantId = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext.Tenant.Id

helm upgrade --install azure-arc $ChartPath --set global.subscriptionId=$SubscriptionId --set global.resourceGroupName=$ResourceGroupName --set global.resourceName=$ClusterName --set global.tenantId=$TenantId --set global.location=$Location --set global.onboardingPrivateKey=$AgentPrivateKey --set systemDefaultValues.spnOnboarding=false --set global.azureEnvironment=AZUREPUBLICCLOUD --set systemDefaultValues.clusterconnect-agent.enabled=true --set global.kubernetesDistro=$Distribution --set global.kubernetesInfra=$Infrastructure (-split $options)
Return $Response
}
Expand Down

0 comments on commit 9490c92

Please sign in to comment.