Skip to content

Commit

Permalink
feat: rename Update-KubeResource to Publish-KubeResource
Browse files Browse the repository at this point in the history
Closes #8
  • Loading branch information
felixfbecker committed Sep 21, 2019
1 parent 776ec87 commit 131b247
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion PSKubectl/PSKubectl.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
'Get-KubeResourceKinds',
'Remove-KubePod',
'Set-KubeConfig',
'Update-KubeResource',
'Publish-KubeResource',
'Use-KubeContext'
)

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ There are also specialised cmdlets for common kinds like `Get-KubePod` and `Get-
Equivalent to `kubectl logs`. Pass `-Follow` to stream logs.
The cmdlet accepts pipeline input from `Get-KubePod`.

#### `Update-KubeResource`
#### `Publish-KubeResource`

Equivalent to `kubectl apply`.
Takes Kubernetes objects or YAML file paths as pipeline or parameter input and sends them to the server to apply the difference.
Expand All @@ -56,8 +56,8 @@ Pass `-Force` to resolve the conflict in these cases.
Example:

```powershell
Update-KubeResource *.yml
Get-ChildItem *.yml -Recurse | Update-KubeResource
Publish-KubeResource *.yml
Get-ChildItem *.yml -Recurse | Publish-KubeResource
```

Editing a field before updating:
Expand All @@ -67,7 +67,7 @@ Get-ChildItem *.Deployment.yml -Recurse |
Get-Content -Raw |
ConvertFrom-KubeYaml |
ForEach-Object { $_.Spec.Template.Spec.Containers[0].Image = $newImage; $_ } |
Update-KubeResource
Publish-KubeResource
```

#### `ConvertFrom-KubeYaml`
Expand All @@ -80,7 +80,7 @@ Other cmdlets take these objects as input.

Compare two Kubernetes objects and output a JSON Patch.

Example that replicates the logic of `Update-KubeResource`:
Example that replicates the logic of `Publish-KubeResource`:

```powershell
$modified = Get-Content -Raw deployment.yml | ConvertFrom-KubeYaml
Expand Down
12 changes: 6 additions & 6 deletions Tests/PSKubectl.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Describe Get-KubeNamespace {
}
}

Describe Update-KubeResource {
Describe Publish-KubeResource {
BeforeAll { Initialize-TestNamespace }
BeforeEach {
# Delete everything for each test to make sure field managers are not messed up.
Expand Down Expand Up @@ -178,7 +178,7 @@ Describe Update-KubeResource {
}
}
}
$result = $modified | Update-KubeResource
$result = $modified | Publish-KubeResource
$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType KubeClient.Models.DeploymentV1
$result.Metadata.Annotations['hello'] | Should -Be 'changed'
Expand All @@ -189,7 +189,7 @@ Describe Update-KubeResource {
It 'Should update the resource from a path to a YAML file' {
$before = (Invoke-Executable { kubectl get deploy -n pskubectltest -o json } | ConvertFrom-Json).Items
$before.Metadata.Annotations.hello | Should -Be 'world'
$result = Update-KubeResource -Path $PSScriptRoot/modified.Deployment.yml
$result = Publish-KubeResource -Path $PSScriptRoot/modified.Deployment.yml
$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType KubeClient.Models.DeploymentV1
$result.Metadata.Annotations['hello'] | Should -Be 'changed'
Expand All @@ -205,7 +205,7 @@ Describe Update-KubeResource {
It 'Should fail with a Conflict error if it was with kubectl create or client-side apply before' {
Invoke-Executable { kubectl create -f $PSScriptRoot/test.Deployment.yml }
Invoke-Executable { kubectl rollout status --namespace pskubectltest deploy/hello-world } | Out-Stream -SuccessTarget 6
{ Update-KubeResource -Path $PSScriptRoot/modified.Deployment.yml } | Should -Throw "Conflict"
{ Publish-KubeResource -Path $PSScriptRoot/modified.Deployment.yml } | Should -Throw "Conflict"
}

It 'Should update the resource if it was updated before with kubectl create or client-side apply and -Force was given' {
Expand All @@ -215,7 +215,7 @@ Describe Update-KubeResource {
$before = (Invoke-Executable { kubectl get deploy -n pskubectltest -o json } | ConvertFrom-Json).Items
$before.Metadata.Annotations.hello | Should -Be 'world'

$result = Update-KubeResource -Path $PSScriptRoot/modified.Deployment.yml -Force
$result = Publish-KubeResource -Path $PSScriptRoot/modified.Deployment.yml -Force
$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType KubeClient.Models.DeploymentV1
$result.Metadata.Annotations.hello | Should -Be 'changed'
Expand All @@ -231,7 +231,7 @@ Describe Update-KubeResource {
$before = (Invoke-Executable { kubectl get deploy -n pskubectltest -o json } | ConvertFrom-Json).Items
$before | Should -BeNullOrEmpty

$result = Update-KubeResource -Path $PSScriptRoot/test.Deployment.yml
$result = Publish-KubeResource -Path $PSScriptRoot/test.Deployment.yml
$result | Should -Not -BeNullOrEmpty
$result | Should -BeOfType KubeClient.Models.DeploymentV1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using Microsoft.Extensions.Logging;

namespace Kubectl.Cmdlets {
[Cmdlet(VerbsData.Update, "KubeResource", SupportsShouldProcess = true)]
[Cmdlet(VerbsData.Publish, "KubeResource", SupportsShouldProcess = true)]
[OutputType(new[] { typeof(KubeResourceV1) })]
public sealed class UpdateKubeResourceCmdlet : KubeApiCmdlet {
public sealed class DeployKubeResourceCmdlet : KubeApiCmdlet {
private static readonly string fieldManager = "kubectl";

[Parameter(Mandatory = true, Position = 0, ParameterSetName = "Path", ValueFromPipelineByPropertyName = true)]
Expand Down

0 comments on commit 131b247

Please sign in to comment.