Skip to content

Commit e125e5b

Browse files
authored
Add parameter CommandContextAttachmentZip to cmdlet Invoke-AzAksRunCommand (Azure#18580)
1 parent 7d4bc91 commit e125e5b

File tree

3 files changed

+35
-7
lines changed

3 files changed

+35
-7
lines changed

src/Aks/Aks/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added parameter `CommandContextAttachmentZip` for `Invoke-AzAksRunCommand`. [#17454]
2122
* Added ManagedIdentity support for Aks[#15656].
2223
* Added property `PowerState` for the output of `Get-AzAksCluster`[#18271]
2324
* Updated the logic of `Set-AzAksCluster` for parameter `NodeImageOnly`.

src/Aks/Aks/Commands/RunAzureRmAksCommand.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public class RunAzureRmAksCommand : KubeCmdletBase
8989
[ValidateNotNullOrEmpty]
9090
public string[] CommandContextAttachment { get; set; }
9191

92+
[Parameter(Mandatory = false, HelpMessage = "Path of the zip file containing the files required by the command.")]
93+
[ValidateNotNullOrEmpty]
94+
public string CommandContextAttachmentZip { get; set; }
95+
9296
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
9397
public SwitchParameter AsJob { get; set; }
9498

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

98102
private string GetCommandContext()
99103
{
104+
if (this.IsParameterBound(c => c.CommandContextAttachmentZip))
105+
{
106+
var zipContent = File.ReadAllBytes(CommandContextAttachmentZip);
107+
return Convert.ToBase64String(zipContent);
108+
}
100109
if (CommandContextAttachment == null || CommandContextAttachment.Length == 0)
101110
{
102111
return "";
@@ -156,6 +165,7 @@ private string GetCommandContext()
156165
}
157166
}
158167
memoryStream.Flush();
168+
159169
return Convert.ToBase64String(memoryStream.ToArray());
160170
}
161171
}

src/Aks/Aks/help/Invoke-AzAksRunCommand.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,24 @@ Run a shell command (with kubectl, helm) on your aks cluster, support attaching
1515
### GroupNameParameterSet (Default)
1616
```
1717
Invoke-AzAksRunCommand [-ResourceGroupName] <String> [-Name] <String> -Command <String>
18-
[-CommandContextAttachment <String[]>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
19-
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
18+
[-CommandContextAttachment <String[]>] [-CommandContextAttachmentZip <String>] [-AsJob] [-Force]
19+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
20+
[<CommonParameters>]
2021
```
2122

2223
### InputObjectParameterSet
2324
```
2425
Invoke-AzAksRunCommand -InputObject <PSKubernetesCluster> -Command <String>
25-
[-CommandContextAttachment <String[]>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
26-
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
26+
[-CommandContextAttachment <String[]>] [-CommandContextAttachmentZip <String>] [-AsJob] [-Force]
27+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
28+
[<CommonParameters>]
2729
```
2830

2931
### IdParameterSet
3032
```
31-
Invoke-AzAksRunCommand [-Id] <String> -Command <String> [-CommandContextAttachment <String[]>] [-AsJob]
32-
[-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-SubscriptionId <String>]
33-
[<CommonParameters>]
33+
Invoke-AzAksRunCommand [-Id] <String> -Command <String> [-CommandContextAttachment <String[]>]
34+
[-CommandContextAttachmentZip <String>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
35+
[-Confirm] [-SubscriptionId <String>] [<CommonParameters>]
3436
```
3537

3638
## DESCRIPTION
@@ -103,6 +105,21 @@ Accept pipeline input: False
103105
Accept wildcard characters: False
104106
```
105107
108+
### -CommandContextAttachmentZip
109+
Path of the zip file containing the files required by the command.
110+
111+
```yaml
112+
Type: System.String
113+
Parameter Sets: (All)
114+
Aliases:
115+
116+
Required: False
117+
Position: Named
118+
Default value: None
119+
Accept pipeline input: False
120+
Accept wildcard characters: False
121+
```
122+
106123
### -DefaultProfile
107124
The credentials, account, tenant, and subscription used for communication with Azure.
108125

0 commit comments

Comments
 (0)