Skip to content

Commit

Permalink
feat: Adds krew manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dploeger committed Oct 7, 2024
1 parent eb95a2e commit 6d88f93
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ jobs:
go-version: "1.23"

- name: Build
run: go build -o kc cmd/kc.go
run: go build -o kubectl-cs cmd/kubectl-cs.go

- name: Release file
- name: Package file
run: |
rm kubectl-cs.tar.gz &>/dev/null
tar czf kubectl-cs.tar.gz kubectl-cs LICENSE
- name: Release
uses: djnicholson/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
release-name: ${{ github.event.release.name }}
tag-name: ${{ github.event.release.tag_name }}
asset-name: kc-${{ matrix.goos }}-${{ matrix.goarch }}
file: kc
asset-name: kubectl-cs-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
file: kubectl-cs.tar.gz

- name: Update new version in krew-index
uses: rajatjindal/[email protected]
60 changes: 60 additions & 0 deletions .krew.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: krew.googlecontainertools.github.com/v1alpha2
kind: Plugin
metadata:
name: cs
spec:
version: {{ .TagName }}
homepage: https://github.com/dodevops/kc
platforms:
- selector:
matchLabels:
os: darwin
arch: amd64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-darwin-amd64.tar.gz" .TagName }}
bin: kubectl-cs
- selector:
matchLabels:
os: darwin
arch: arm64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-darwin-arm64.tar.gz" .TagName }}
bin: kubectl-cs
- selector:
matchLabels:
os: windows
arch: amd64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-windows-amd64.tar.gz" .TagName }}
bin: kubectl-cs
- selector:
matchLabels:
os: windows
arch: arm64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-windows-arm64.tar.gz" .TagName }}
bin: kubectl-cs
- selector:
matchLabels:
os: linux
arch: amd64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-linux-amd64.tar.gz" .TagName }}
bin: kubectl-cs
- selector:
matchLabels:
os: linux
arch: arm64
{{addURIAndSha "https://github.com/dodevops/kc/releases/download/{{ .TagName }}/kubectl-cs-linux-arm64.tar.gz" .TagName }}
bin: kubectl-cs
shortDescription: Quick Kubernetes context switcher
description: |
Usage:
kubectl cs [--only-current-context] [target]
Run `kubectl cs` to switch to a Kubernetes context and/or namespace. You can directly specify the context to switch to
in the form of `context:namespace`. If you leave either of the two parts empty, it will only change the remaining part.
Examples:
* `kubectl cs int:` - Switch to the currently active namespace in the `int` context
* `kubectl cs :kube-system` - Switch to the namespace `kube-system` in the currently active context
* `kubectl cs int:kube-system` - Switch to the namespace `kube-system` in the `int` context
If you don't specify anything, `kubectl cs` will present a selection list of all namespaces in all contexts, which can
be filtered and selected. If that takes too long, the flag `--only-current-context` can be used, which only enumerates
the namespaces of the current context.

0 comments on commit 6d88f93

Please sign in to comment.