Skip to content

Commit

Permalink
Add parameter CommandContextAttachmentZip to cmdlet Invoke-AzAksRunCo…
Browse files Browse the repository at this point in the history
…mmand (#18580)
  • Loading branch information
wyunchi-ms authored Jun 17, 2022
1 parent 7d4bc91 commit e125e5b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Aks/Aks/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added parameter `CommandContextAttachmentZip` for `Invoke-AzAksRunCommand`. [#17454]
* Added ManagedIdentity support for Aks[#15656].
* Added property `PowerState` for the output of `Get-AzAksCluster`[#18271]
* Updated the logic of `Set-AzAksCluster` for parameter `NodeImageOnly`.
Expand Down
10 changes: 10 additions & 0 deletions src/Aks/Aks/Commands/RunAzureRmAksCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public class RunAzureRmAksCommand : KubeCmdletBase
[ValidateNotNullOrEmpty]
public string[] CommandContextAttachment { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Path of the zip file containing the files required by the command.")]
[ValidateNotNullOrEmpty]
public string CommandContextAttachmentZip { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

Expand All @@ -97,6 +101,11 @@ public class RunAzureRmAksCommand : KubeCmdletBase

private string GetCommandContext()
{
if (this.IsParameterBound(c => c.CommandContextAttachmentZip))
{
var zipContent = File.ReadAllBytes(CommandContextAttachmentZip);
return Convert.ToBase64String(zipContent);
}
if (CommandContextAttachment == null || CommandContextAttachment.Length == 0)
{
return "";
Expand Down Expand Up @@ -156,6 +165,7 @@ private string GetCommandContext()
}
}
memoryStream.Flush();

return Convert.ToBase64String(memoryStream.ToArray());
}
}
Expand Down
31 changes: 24 additions & 7 deletions src/Aks/Aks/help/Invoke-AzAksRunCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,24 @@ Run a shell command (with kubectl, helm) on your aks cluster, support attaching
### GroupNameParameterSet (Default)
```
Invoke-AzAksRunCommand [-ResourceGroupName] <String> [-Name] <String> -Command <String>
[-CommandContextAttachment <String[]>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
[-CommandContextAttachment <String[]>] [-CommandContextAttachmentZip <String>] [-AsJob] [-Force]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
```

### InputObjectParameterSet
```
Invoke-AzAksRunCommand -InputObject <PSKubernetesCluster> -Command <String>
[-CommandContextAttachment <String[]>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
[-CommandContextAttachment <String[]>] [-CommandContextAttachmentZip <String>] [-AsJob] [-Force]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
```

### IdParameterSet
```
Invoke-AzAksRunCommand [-Id] <String> -Command <String> [-CommandContextAttachment <String[]>] [-AsJob]
[-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
[<CommonParameters>]
Invoke-AzAksRunCommand [-Id] <String> -Command <String> [-CommandContextAttachment <String[]>]
[-CommandContextAttachmentZip <String>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -103,6 +105,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -CommandContextAttachmentZip
Path of the zip file containing the files required by the command.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Expand Down

0 comments on commit e125e5b

Please sign in to comment.