Compare commits

..

6 Commits

Author SHA1 Message Date
ultram4rine
741e2b9986 fix bats tests 2026-03-08 14:49:31 -07:00
ultram4rine
ed644ff0a6 update client-go to 0.28.5 2026-03-08 14:49:31 -07:00
ultram4rine
004cdecf2b use kyaml filters 2026-03-08 14:49:28 -07:00
ultram4rine
267d8dd5a8 update kyaml 2026-03-08 14:49:28 -07:00
ultram4rine
4a91c2170a set indentation if ToYAML func 2026-03-08 14:49:28 -07:00
ultram4rine
042d269721 replace goyaml imports with kyaml 2026-03-08 14:49:28 -07:00
6 changed files with 0 additions and 112 deletions

View File

@@ -1,21 +0,0 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: chore
include: scope
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
commit-message:
prefix: chore
include: scope
groups:
kubernetes:
patterns:
- "k8s.io/*"

View File

@@ -1,24 +0,0 @@
name: Dependabot
on:
pull_request:
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
- name: Enable auto-merge for Dependabot PRs
if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -52,8 +52,6 @@ func parseArgs(argv []string) Op {
return VersionOp{}
case "--current", "-c":
return CurrentOp{}
case "--unset", "-u":
return UnsetOp{}
default:
return getSwitchOp(v, false)
}

View File

@@ -45,12 +45,6 @@ func Test_parseArgs_new(t *testing.T) {
{name: "current long form",
args: []string{"--current"},
want: CurrentOp{}},
{name: "unset shorthand",
args: []string{"-u"},
want: UnsetOp{}},
{name: "unset long form",
args: []string{"--unset"},
want: UnsetOp{}},
{name: "switch by name",
args: []string{"foo"},
want: SwitchOp{Target: "foo"}},

View File

@@ -39,7 +39,6 @@ func printUsage(out io.Writer) error {
%PROG% - : switch to the previous namespace in this context
%PROG% -c, --current : show the current namespace
%PROG% -h,--help : show this message
%PROG% -u,--unset : unset the namespace choice (set to 'default')
%PROG% -V,--version : show version`
// TODO this replace logic is duplicated between this and kubectx

View File

@@ -1,58 +0,0 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"io"
"github.com/pkg/errors"
"github.com/ahmetb/kubectx/internal/kubeconfig"
"github.com/ahmetb/kubectx/internal/printer"
)
// UnsetOp indicates intention to remove current namespace preference.
type UnsetOp struct{}
func (_ UnsetOp) Run(_, stderr io.Writer) error {
kc := new(kubeconfig.Kubeconfig).WithLoader(kubeconfig.DefaultLoader)
defer kc.Close()
if err := kc.Parse(); err != nil {
return errors.Wrap(err, "kubeconfig error")
}
ns, err := clearNamespace(kc)
if err != nil {
return err
}
err = printer.Success(stderr, "Active namespace is \"%s\".", printer.SuccessColor.Sprint(ns))
return err
}
func clearNamespace(kc *kubeconfig.Kubeconfig) (string, error) {
ctx := kc.GetCurrentContext()
ns := "default"
if ctx == "" {
return "", errors.New("current-context is not set")
}
if err := kc.SetNamespace(ctx, ns); err != nil {
return "", errors.Wrapf(err, "failed to clear namespace")
}
if err := kc.Save(); err != nil {
return "", errors.Wrap(err, "failed to save kubeconfig file")
}
return ns, nil
}