Skip to content

Commit

Permalink
kube-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyisan committed Sep 16, 2022
0 parents commit cf4c3d9
Show file tree
Hide file tree
Showing 7 changed files with 674 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
bin/
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: build-linux build-osx build-windows clean

build-linux:
@GOARCH=amd64 CGO_ENABLED=1 GOOS=linux go build -ldflags "-s -w" -o bin/kube-resource_linux

build-osx:
@GOARCH=amd64 CGO_ENABLED=1 GOOS=darwin go build -ldflags "-s -w" -o bin/kube-resource_darwin

build-windows:
@GOARCH=amd64 CGO_ENABLED=1 GOOS=windows go build -ldflags "-s -w" -o bin/kube-resource_windows

clean:
@if [ -f bin/kube-resource_linux ] ; then rm bin/kube-resource_linux ; fi
@if [ -f bin/kube-resource_darwin ] ; then rm bin/kube-resource_darwin ; fi
@if [ -f bin/kube-resource_windows ] ; then rm bin/kube-resource_windows ; fi
Empty file added README.md
Empty file.
26 changes: 26 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package config

import (
"github.com/spf13/pflag"
"os"
"path/filepath"
)

func InitKubeConfig() *string {
var kubeConfig *string
kubeConfig = pflag.StringP("kubeconfig", "c", "", "(optional) absolute path to the kubeconfig file")
if *kubeConfig == "" {
if home := homeDir(); home != "" {
c := filepath.Join(home, ".kube", "config")
*kubeConfig = c
}
}
return kubeConfig
}

func homeDir() string {
if h := os.Getenv("HOME"); h != "" {
return h
}
return os.Getenv("USERPROFILE") // windows
}
49 changes: 49 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module kubernetes-resource-list

go 1.19

require (
github.com/spf13/pflag v1.0.5
k8s.io/client-go v0.25.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.25.0 // indirect
k8s.io/apimachinery v0.25.0 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)
Loading

0 comments on commit cf4c3d9

Please sign in to comment.