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

base: Remove packer package #494

Merged
merged 1 commit into from
Oct 10, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion linux/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ RUN tdnf update -y --refresh && \
golang \
ruby \
rubygems \
packer \
dcos-cli \
ripgrep \
helm \
Expand Down
73 changes: 36 additions & 37 deletions linux/powershell/PSCloudShellUtility/PSCloudShellUtility.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ function Copy-FromCloudShell
-ExceptionObject $PSCmdlet
return
}

if ($item -is [System.IO.FileInfo])
{
# item is a file, go ahead to download. Note: No check is necessary because get-item has done that.
Expand All @@ -480,7 +480,7 @@ function Copy-FromCloudShell

# Zip the directory. Note using jar instead of zip is to ignore original top-level folder structure.
$null = jar cMvf $tmp -C $fullPath .

if ((Microsoft.PowerShell.Management\Test-Path -Path $tmp) -or (Microsoft.PowerShell.Management\Test-Path -LiteralPath $tmp))
{
Write-Verbose "Downloading $tmp" -Verbose
Expand Down Expand Up @@ -770,7 +770,7 @@ function Get-CloudShellTip

if(-not [string]::IsNullOrEmpty($randomTip))
{
$message = "MOTD: " + $randomTip
$message = "MOTD: " + $randomTip
$message = "`r`n" + $message + "`r`n";
}
}
Expand Down Expand Up @@ -889,8 +889,8 @@ function Invoke-AzVMCommand
Provide UserName when connecting to Linux Targets. When used with KeyFilePath parameter, identifies the user on the remote computer

.PARAMETER KeyFilePath
Provide SSH KeyFile Path when connecting to Linux Targets, if connection uses Key based authentication
Provide SSH KeyFile Path when connecting to Linux Targets, if connection uses Key based authentication

.EXAMPLE
Invoke-AzVMCommand -Name WindowsVM -ResourceGroupName ResourceGroupName -ScriptBlock ScriptBlock -Credential credential

Expand Down Expand Up @@ -928,7 +928,7 @@ function Invoke-AzVMCommand
[ValidateNotNullOrEmpty()]
[string]$KeyFilePath
)

if(-not (Test-AzResourceGroup -ResourceGroupName $ResourceGroupName)) {
$badResourceGroup = $LocalizedData.TestAzResourceGroup -f ($ResourceGroupName)
throw [System.ArgumentException] $badResourceGroup
Expand All @@ -948,25 +948,25 @@ function Invoke-AzVMCommand
{
$message = $LocalizedData.CredentialError
throw [System.ArgumentException] $message
}
}
}

$cName = Test-AzVM @testAzVMParams
if(-not $cName) {
$message = $LocalizedData.GetAzureVMError -f ($Name)
throw [System.ArgumentException] $message
}

if ([OStype]::Windows -eq $OsType)
{
$invokeCommandParams = @{
ComputerName = $cName
UseSSL = $true
Credential = $Credential
SessionOption = $script:sessionOption
ScriptBlock = $ScriptBlock
ScriptBlock = $ScriptBlock
Authentication = 'Basic'
}
}
}
elseif ([OStype]::Linux -eq $OsType)
{
Expand All @@ -992,7 +992,7 @@ function Invoke-AzVMCommand
}
}

Invoke-Command @invokeCommandParams -ErrorAction Stop
Invoke-Command @invokeCommandParams -ErrorAction Stop
}

function Get-AzVmNsg
Expand Down Expand Up @@ -1024,7 +1024,7 @@ function Get-AzVmNsg
| Foreach-Object `
{ `
if ($_.NetworkInterfaces -and ($_.NetworkInterfaces.Id -eq $azVMNetInterfacesId)) `
{
{
$nsg+=$_
} `
}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ function Get-AzVMPSRemoting

[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
$Nsg
)
)

$protocol = @{https = $false; http = $false; ssh = $false}

Expand Down Expand Up @@ -1138,7 +1138,7 @@ function Enable-AzVMPSRemoting

[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string]$ResourceGroupName,

[ValidateSet('http','https','ssh')]
[string]$Protocol,

Expand Down Expand Up @@ -1186,10 +1186,10 @@ function Enable-AzVMPSRemoting
if($Protocol -eq 'https')
{
if (-not $psremoting.Https)
{
{
$null = Az.Network\Add-AzNetworkSecurityRuleConfig -Name 'allow-winrm-https' -DestinationPortRange 5986 @parameters | Az.Network\Set-AzNetworkSecurityGroup
}

# Setup WinRM HTTPS based remoting using Self-Signed Certificate
$runCommandParameters =
@{
Expand Down Expand Up @@ -1274,7 +1274,7 @@ function Enable-AzVMPSRemoting
# 1) Install powershellcore in linux, if not already present
# 2) backup current sshd_config, configure sshd_config to enable PasswordAuthentication, register powershell subsystem with ssh daemon
# (#2 is required to support interactive username/password authentication over powershell-ssh)
# 3) Restart the ssh daemon service to pick up the new config changes
# 3) Restart the ssh daemon service to pick up the new config changes
$runCommandParameters =
@{
commandId = 'RunShellScript'
Expand All @@ -1286,8 +1286,8 @@ function Enable-AzVMPSRemoting

$null = Az.Resources\Invoke-AzResourceAction -ResourceId $azureVM.Id -Action runCommand -Parameters $runCommandParameters -ApiVersion 2017-03-30 -Force
}
}
}
}
}
}

function Disable-AzVMPSRemoting
Expand Down Expand Up @@ -1339,7 +1339,7 @@ function Disable-AzVMPSRemoting
{
$OsType = Get-OsType -Name $Name -ResourceGroupName $ResourceGroupName
}

$azVMNsgs = Get-AzVmNsg -Name $Name -ResourceGroupName $ResourceGroupName

if ([OStype]::Windows -eq $OsType)
Expand Down Expand Up @@ -1500,7 +1500,7 @@ function Test-AzVM
[string]$ResourceGroupName,

[Parameter(Mandatory=$true)]
[OSType]$OsType
[OSType]$OsType
)

$azVMNsgs = Get-AzVmNsg -Name $Name -ResourceGroupName $ResourceGroupName
Expand All @@ -1511,10 +1511,10 @@ function Test-AzVM
$psRemoting = Get-AzVMPSRemoting -Name $Name -ResourceGroupName $ResourceGroupName -Nsg $azVMNsg

if ((([OStype]::Windows -eq $OsType) -and (-not $psRemoting.https)) -or (([OStype]::Linux -eq $OsType) -and (-not $psRemoting.ssh)))
{
{
$errMsg = $LocalizedData.TestAzPsRemotingError -f ($Name, $ResourceGroupName)
throw $errMsg
}
throw $errMsg
}
}

# Check the communication with the remote machine
Expand Down Expand Up @@ -1695,7 +1695,7 @@ function GetCommand {
return $commands
}

function GetAcronymContent
function GetAcronymContent
{
# Get the acronyms file
$path = Join-Path -Path $PSScriptRoot -ChildPath 'PSCloudShellUtilityAcronyms.json'
Expand All @@ -1710,25 +1710,25 @@ function GetAcronymContent
}

function RedirectOnlineHelp($Parameters)
{
{
try {
Microsoft.PowerShell.Core\Get-Help @Parameters
}
catch [System.Management.Automation.PSInvalidOperationException]
{
$err = $_
$matchFound = $err.Exception.Message -match "No program or browser is associated to open the URI (?<link>\w+:\/\/[\w@][\w.:@]+\/?[\w\.?=%&=\-@/$,]*)."

if(($matchFound -eq $True) -and (-not [string]::IsNullOrEmpty($env:ACC_TERM_ID))) {
$targetLink = $matches["link"]
Write-Verbose "Redirecting to $targetLink"

$uri = "http://localhost:8888/openLink/$($env:ACC_TERM_ID)"
$uri = "http://localhost:8888/openLink/$($env:ACC_TERM_ID)"

try{
$null = Invoke-RestMethod -Method Post -Uri $uri -Body "{""url"":""$targetLink""}" -ContentType "application/json"
}catch{
Write-Warning -Message "Redirecting to $targetLink failed, please open the link in another page."
Write-Warning -Message "Redirecting to $targetLink failed, please open the link in another page."
throw
}
}
Expand Down Expand Up @@ -1765,14 +1765,14 @@ function Get-PackageVersion() {

# Apt and some other programs write to stderr, which fails tests without this
$ErrorActionPreference = "Continue"

# Enumerate all APT packages with versions
$packages = New-Object -TypeName System.Collections.ArrayList

# TODO - find the regular expression to seperate the package name from the package version
# apt list --installed 2> /dev/null | % {
# apt list --installed 2> /dev/null | % {
# Write-Verbose "Apt: $_"
# if ($_ -match "([^/]*)/[^ ]* ([^ ]*)") {
# if ($_ -match "([^/]*)/[^ ]* ([^ ]*)") {
# $p = New-PackageInfo -Name $matches[1] -Version $matches[2] -Type "Apt"
# $null = $packages.Add($p)
# }
Expand All @@ -1789,7 +1789,7 @@ function Get-PackageVersion() {
catch {
return "Error"
}

$version = ($output | % {
if ($_ -match $package.match) {
Write-Verbose "matched $_"
Expand All @@ -1806,7 +1806,6 @@ function Get-PackageVersion() {
@{displayname = "Ansible"; command = "ansible"; args = "--version"; match = "ansible \[core ([\d\.]+)\]"},
@{displayname = "Istio"; command = "istioctl"; args = "version -s --remote=false"; match = "(.+)"},
@{displayname = "Go"; command = "go"; args = "version"; match = "go version go(\S+) .*"},
@{displayname = "Packer"; command = "packer"; args = "version"; match = "Packer v(.+)"},
@{displayname = "DC/OS CLI"; command = "dcos"; args = "--version"; match = "dcoscli.version=(.*)"},
@{displayname = "Ripgrep"; command = "rg"; args = "--help | head"; match = "ripgrep ([\d\.]+)$"},
@{displayname = "Helm"; command = "helm"; args = "version --short"; match = "v(.+)"},
Expand All @@ -1826,8 +1825,8 @@ function Get-PackageVersion() {
}

# PIP3 packages
& pip3 list | % {
if ($_ -match "(\w+)\s+(.*)") {
& pip3 list | % {
if ($_ -match "(\w+)\s+(.*)") {
$p = New-PackageInfo -Name $matches[1] -Version $matches[2] -Type "PIP"
$null = $packages.Add($p)
}
Expand Down
1 change: 0 additions & 1 deletion tests/command_list
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,6 @@ oomctl
openssl
p11-kit
p11tool
packer
pam_namespace_helper
pam_timestamp_check
parallel
Expand Down
Loading