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

[Aks]Add parameter CommandContextAttachmentZip to cmdlet Invoke-AzAksRunCommand #18580

Merged
merged 2 commits into from
Jun 17, 2022
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: 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