diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d23f57a..df10e3e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/release-action@v2.10 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/krew-release-bot@v0.0.46 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9562a3d..24d57d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,3 +19,5 @@ jobs: cache: false - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 + with: + args: "--timeout 5m" diff --git a/.krew.yaml b/.krew.yaml new file mode 100644 index 0000000..3b91488 --- /dev/null +++ b/.krew.yaml @@ -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. \ No newline at end of file