Skip to content

Commit

Permalink
Basic kubeconfig clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashley committed Jun 28, 2018
1 parent 9fa7055 commit b8b0eee
Show file tree
Hide file tree
Showing 7 changed files with 457 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor
30 changes: 30 additions & 0 deletions cleanup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"

"github.com/ashleyschuett/kubeconfig-cleanup/pkg/config"
)

func main() {
m := config.NewManager()
valid := make(map[string]bool, 0)

for id, context := range m.Original.Contexts {
fmt.Printf("Testing cluster for context %s...\n", id)
ok, tested := valid[context.Cluster]

if !tested {
ok = m.Validate(context)
valid[context.Cluster] = ok
}

if !ok {
m.RemoveContext(id, context)
}
fmt.Println()
}

m.RemoveUnusedUsers()
m.Finish()
}
204 changes: 204 additions & 0 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package: github.com/ashleyschuett/kubeconfig-cleanup
import:
- package: k8s.io/client-go
version: ^7.0.0
- package: k8s.io/kubernetes
version: ^1.12.0-alpha.0
- package: k8s.io/apimachinery
Loading

0 comments on commit b8b0eee

Please sign in to comment.