diff --git a/.travis.yml b/.travis.yml index 96938a1..12c058d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,6 @@ env: nstall: - go get -u golang.org/x/lint/golint script: - - go build -o kubesql cmd/kubectl-sql/*.go + - go build -o kubectl-sql cmd/kubectl-sql/*.go - golint cmd/kubectl-sql/*.go && golint pkg/cmd/*.go - test -s $(gofmt -s -l cmd/kubectl-sql/*.go pkg/cmd/*.go) diff --git a/Makefile b/Makefile index 9bd3d06..b5ce715 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ kubesql_pkg := $(wildcard ./pkg/cmd/*.go) all: kubectl-sql kubectl-sql: $(kubesql_cmd) $(kubesql_pkg) - go build -ldflags='-X github.com/yaacov/kubesql/pkg/cmd.clientVersion=${VERSION}' -o kubectl-sql $(kubesql_cmd) + go build -ldflags='-X github.com/yaacov/kubectl-sql/pkg/cmd.clientVersion=${VERSION}' -o kubectl-sql $(kubesql_cmd) .PHONY: lint lint: diff --git a/README.md b/README.md index fa479cb..5cf185a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -[![Go Report Card](https://goreportcard.com/badge/github.com/yaacov/kubesql)](https://goreportcard.com/report/github.com/yaacov/kubesql) -[![Build Status](https://travis-ci.org/yaacov/kubesql.svg?branch=master)](https://travis-ci.org/yaacov/kubesql) +[![Go Report Card](https://goreportcard.com/badge/github.com/yaacov/kubectl-sql)](https://goreportcard.com/report/github.com/yaacov/kubectl-sql) +[![Build Status](https://travis-ci.org/yaacov/kubectl-sql.svg?branch=master)](https://travis-ci.org/yaacov/kubectl-sql) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

- kubectl-sql Logo + kubectl-sql Logo

# kubectl-sql @@ -40,21 +40,21 @@ Using `go get` command: ``` bash -GO111MODULE=on go get -v github.com/yaacov/kubesql/cmd/kubectl-sql +GO111MODULE=on go get -v github.com/yaacov/kubectl-sql/cmd/kubectl-sql ``` Using Fedora Copr: ``` -dnf copr enable yaacov/kubesql -dnf install kubesql +dnf copr enable yaacov/kubectl-sql +dnf install kubectl-sql ``` From source: ``` bash -git clone git@github.com:yaacov/kubesql.git -cd kubesql +git clone git@github.com:yaacov/kubectl-sql.git +cd kubectl-sql make ``` @@ -79,7 +79,7 @@ Example: kubectl-sql --all-namespaces get rs where "status.readyReplicas < status.replicas" ``` -For other ways to select Kubernetes resources see [#Alternatives](https://github.com/yaacov/kubesql#alternatives). +For other ways to select Kubernetes resources see [#Alternatives](https://github.com/yaacov/kubectl-sql#alternatives). #### Available Operators: @@ -209,13 +209,13 @@ kubectl-sql --help ## Config File Users can add aliases and edit the fields displayed in table view using json config files, -[see the example config file](https://github.com/yaacov/kubesql/blob/master/kubesql.json). +[see the example config file](https://github.com/yaacov/kubectl-sql/blob/master/kubectl-sql.json). -Flag: `--kubesql ` (default: `$HOME/.kube/kubesql.json`) +Flag: `--kubectl-sql ` (default: `$HOME/.kube/kubectl-sql.json`) Example: ``` bash -kubectl-sql --kubesql ./kubesql.json get pods +kubectl-sql --kubectl-sql ./kubectl-sql.json get pods ... ``` diff --git a/cmd/kubectl-sql/main.go b/cmd/kubectl-sql/main.go index 0511d8a..76d691a 100644 --- a/cmd/kubectl-sql/main.go +++ b/cmd/kubectl-sql/main.go @@ -25,7 +25,7 @@ import ( "github.com/spf13/pflag" "k8s.io/cli-runtime/pkg/genericclioptions" - "github.com/yaacov/kubesql/pkg/cmd" + "github.com/yaacov/kubectl-sql/pkg/cmd" ) func main() { diff --git a/go.mod b/go.mod index bab5f76..c5d29de 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/yaacov/kubesql +module github.com/yaacov/kubectl-sql go 1.13 diff --git a/kubesql.json b/kubesql.json deleted file mode 100644 index cbd8ebc..0000000 --- a/kubesql.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "aliases": { - "owner.name": "metadata.ownerReferences.1.name", - "owner.kind": "metadata.ownerReferences.1.kind", - "hostIP": "status.hostIP", - "podIP": "status.podIP" - }, - "table-fields": { - "VirtualMachineInstance": [ - { - "title": "NAMESPACE", - "name": "namespace" - }, - { - "title": "NAME", - "name": "name" - }, - { - "title": "PHASE", - "name": "status.phase" - }, - { - "title": "IP", - "name": "status.interfaces.1.ipAddress" - }, - { - "title": "CREATION_TIME(RFC3339)", - "name": "created" - } - ], - "VirtualMachineInstanceMigration": [ - { - "title": "NAMESPACE", - "name": "namespace" - }, - { - "title": "NAME", - "name": "name" - }, - { - "title": "VMI", - "name": "spec.vmiName" - }, - { - "title": "CREATION_TIME(RFC3339)", - "name": "created" - } - ], - "ReplicaSet": [ - { - "title": "NAMESPACE", - "name": "namespace" - }, - { - "title": "NAME", - "name": "name" - }, - { - "title": "READY", - "name": "status.readyReplicas" - }, - { - "title": "REPLI", - "name": "status.replicas" - }, - { - "title": "CREATION_TIME(RFC3339)", - "name": "created" - } - ] - } -} \ No newline at end of file diff --git a/kubesql.spec b/kubesql.spec deleted file mode 100644 index 6ff4327..0000000 --- a/kubesql.spec +++ /dev/null @@ -1,77 +0,0 @@ -%global provider github -%global provider_tld com -%global project yaacov -%global repo kubesql -%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} -%global import_path %{provider_prefix} - -%undefine _missing_build_ids_terminate_build -%define debug_package %{nil} - -Name: %{repo} -Version: 0.2.2 -Release: 1%{?dist} -Summary: kubectl-sql uses sql like language to query the Kubernetes cluster manager -License: Apache -URL: https://%{import_path} -Source0: https://github.com/yaacov/kubesql/archive/%{version}.tar.gz - -BuildRequires: git -BuildRequires: golang >= 1.2.8 - -%description -kubectl-sql let you select Kubernetes resources based on the value of one or more resource fields, using human readable easy to use SQL like query langauge. - -%prep -%setup -q -n kubesql-%{version} - -%build -# set up temporary build gopath, and put our directory there -mkdir -p ./_build/src/github.com/yaacov -ln -s $(pwd) ./_build/src/github.com/yaacov/kubesql - -VERSION=%{version} make - -%install -install -d %{buildroot}%{_bindir} -install -p -m 0755 ./kubectl-sql %{buildroot}%{_bindir}/kubectl-sql - -%files -%defattr(-,root,root,-) -%doc LICENSE README.md -%{_bindir}/kubectl-sql - -%changelog - -* Thu Mar 4 2020 Yaacov Zamir 0.2.2-1 -- use git version number - -* Thu Mar 4 2020 Yaacov Zamir 0.2.1-1 -- Fix multiple resources - -* Thu Mar 4 2020 Yaacov Zamir 0.2.0-1 -- Use kubectl plugin kit - -* Thu Feb 22 2020 Yaacov Zamir 0.1.18-1 -- Fix float printing - -* Thu Feb 22 2020 Yaacov Zamir 0.1.17-1 -- Add config option - -* Thu Feb 22 2020 Yaacov Zamir 0.1.16-1 -- Fix parsing of anotations - -* Thu Feb 22 2020 Yaacov Zamir 0.1.15-1 -- Fix parsing of labels and anotations - -* Thu Feb 22 2020 Yaacov Zamir 0.1.14-1 -- Fix parsing of numbers - -* Thu Feb 22 2020 Yaacov Zamir 0.1.13-1 -- Parse dates and booleans - -* Thu Feb 20 2020 Yaacov Zamir 0.1.12-1 -- No debug rpm - -* Thu Feb 20 2020 Yaacov Zamir 0.1.11-1 -- Initial RPM release diff --git a/pkg/cmd/sql.go b/pkg/cmd/sql.go index a8df210..3cc350e 100644 --- a/pkg/cmd/sql.go +++ b/pkg/cmd/sql.go @@ -90,9 +90,9 @@ func NewSQLOptions(streams genericclioptions.IOStreams) *SQLOptions { outputFormat: "table", } - // Look for a default kubesql.json config file. + // Look for a default kubectl-sql.json config file. if home, err := os.UserHomeDir(); err == nil { - options.defaultSQLConfigPath = fmt.Sprintf("%s/.kube/kubesql.json", home) + options.defaultSQLConfigPath = fmt.Sprintf("%s/.kube/kubectl-sql.json", home) } return options @@ -125,8 +125,8 @@ func NewCmdSQL(streams genericclioptions.IOStreams) *cobra.Command { cmd.Flags().BoolVarP(&o.allNamespaces, "all-namespaces", "A", o.allNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.") - cmd.Flags().StringVarP(&o.requestedSQLConfigPath, "kubesql", "q", o.defaultSQLConfigPath, - "Path to the kubesql.json file to use for kubesql requests.") + cmd.Flags().StringVarP(&o.requestedSQLConfigPath, "kubectl-sql", "q", o.defaultSQLConfigPath, + "Path to the kubectl-sql.json file to use for kubectl-sql requests.") cmd.Flags().StringVarP(&o.outputFormat, "output", "o", o.outputFormat, "Output format. One of: json|yaml|table|name")