Skip to content

Commit ec4f50c

Browse files
authored
Merge pull request #106 from lpabon/args-conflicts
Update docs and arguments
2 parents d375ebe + a4fa3bf commit ec4f50c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+952
-202
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
pxc
2+
pxc.exe
3+
*.code-workspace
4+
kubectl-pxc
5+
kubectl-pxc.exe
26
.*.swp
37
*.px
48
*.zip
59
.code-workspace*
10+
dist/

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ script:
88
- go vet $(go list ./... | grep -v vendor)
99
- make install
1010
- make test
11+
- make docs

Makefile

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
CLINAME := kubectl-pxc
1+
CLINAME := pxc
2+
KUBECTL_PLUGIN := kubectl-$(CLINAME)
23
SHA := $(shell git rev-parse --short HEAD)
34
BRANCH := $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
45
VER := $(shell git describe --tags)
@@ -19,18 +20,20 @@ LDFLAGS :=-ldflags "-X github.com/portworx/pxc/cmd.PxVersion=$(VERSION)"
1920

2021
ifneq (windows,$(GOOS))
2122
PKG_NAME = $(CLINAME)
23+
PLUGIN_PKG_NAME = $(KUBECTL_PLUGIN)
2224
else
2325
PKG_NAME = $(CLINAME).exe
26+
PLUGIN_PKG_NAME = $(KUBECTL_PLUGIN).exe
2427
endif
2528

2629
ZIPPACKAGE := $(CLINAME)-$(VERSION).$(GOOS).$(ARCH).zip
2730
TGZPACKAGE := $(CLINAME)-$(VERSION).$(GOOS).$(ARCH).tar.gz
2831

29-
all: pxc
32+
all: pxc $(PLUGIN_PKG_NAME)
3033

3134
install: all
3235
cp $(PKG_NAME) $(GOPATH)/bin
33-
36+
cp $(PKG_NAME) $(GOPATH)/bin/$(PLUGIN_PKG_NAME)
3437

3538
imports:
3639
goimports -w ./cmd
@@ -61,29 +64,36 @@ distzip: $(ZIPPACKAGE)
6164

6265
dist: $(TGZPACKAGE)
6366

67+
# This also tests for any conflicts
68+
docs: all
69+
./pxc gendocs --output-dir=docs/usage
70+
6471
test:
6572
./hack/test.sh
6673

6774
verify: all test
6875
go fmt $(go list ./... | grep -v vendor) | wc -l | grep 0
6976
go vet $(go list ./... | grep -v vendor)
7077

78+
$(PLUGIN_PKG_NAME): pxc
79+
cp pxc $(PLUGIN_PKG_NAME)
80+
7181
$(ZIPPACKAGE): all
7282
@echo Packaging pxc ...
7383
@mkdir -p dist
74-
@zip dist/$@ $(PKG_NAME)
84+
@zip dist/$@ $(PLUGIN_PKG_NAME)
7585
@rm -f $(PKG_NAME)
7686

7787
$(TGZPACKAGE): all
7888
@echo Packaging Binaries...
7989
@mkdir -p tmp/$(PKG_NAME)
80-
@cp $(PKG_NAME) tmp/$(PKG_NAME)/
90+
@cp $(PLUGIN_PKG_NAME) tmp/$(PKG_NAME)/
8191
@mkdir -p $(DIR)/dist/
8292
tar -czf $(DIR)/dist/$@ -C tmp $(PKG_NAME)
8393
@rm -rf tmp
8494

8595
clean:
86-
rm -f $(PKG_NAME)
96+
rm -f $(PKG_NAME) $(PLUGIN_PKG_NAME)
8797
rm -rf dist
8898

8999
.PHONY: dist all clean darwin_amd64_dist windows_amd64_dist linux_amd64_dist \

README.md

+4-44
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
`pxc` is a client side application which communicates with Portworx, Kubernetes,
55
and other services to provide users with an integrated tool.
66

7+
The first release of pxc is focused on being a kubectl plugin.
8+
79
# Downloads
810
Please refer to the [Releases](https://github.com/portworx/pxc/releases) page to
911
download the latest build.
@@ -13,12 +15,12 @@ download the latest build.
1315
Please see [documentation](docs/usage/pxc.md)
1416

1517
# Usage
16-
`pxc` is a tool that communicates with Portworx as well as Container
18+
`pxc` is a command line client that communicates with Portworx as well as Container
1719
Orchestration systems like Kubernetes. It can be run standalone or as a plugin
1820
to kubectl.
1921

2022
## Kubectl Plugin
21-
Install `pxc` binary anywhere in your PATH and name it `kubectl-pxc`. You will
23+
Install `kubectl-pxc` binary anywhere in your PATH. You will
2224
then be able to run it like this:
2325

2426
```
@@ -27,48 +29,6 @@ $ kubectl pxc get pvc
2729
$ kubectl pxc get pvc --kubeconfig=/path/to/kubeconfig.conf
2830
```
2931

30-
If you are running Portworx installed on a Kubernetes Cloud like GKE, EKS, etc,
31-
please use this model.
32-
33-
`pxc` will automatically discover how to communicate with Portworx. No need for
34-
any prior setup.
35-
36-
## Standalone
37-
38-
You must first create a context with the appropriate information. `pxc` uses the context to connect to
39-
the appropriate Portworx cluster to execute the requested command.
40-
41-
### Creating a context
42-
You can create a context using the following command:
43-
44-
```
45-
$ pxc context create mycluster --endpoint=<ip of cluster>:9020 --kubeconfig=/path/to/kubeconfig
46-
```
47-
48-
> NOTE: The default gRPC SDK port for Portworx is 9020
49-
50-
#### What if you don't have a Portworx cluster?
51-
`pxc` uses the [OpenStorage SDK](https://libopenstorage.github.io) to communicate
52-
with Portworx, therefore it is fully compatible with OpenStorage's
53-
`mock-sdk-server`. If you do not have a Portworx cluster, you can run the
54-
following to start the `mock-sdk-server`:
55-
56-
```
57-
$ docker run --rm --name sdk -d -p 9100:9100 -p 9110:9110 openstorage/mock-sdk-server
58-
$ pxc context create --name=mycluster --endpoint=localhost:9100
59-
```
60-
61-
### pxc sample commands
62-
Now that `pxc` has been setup with a context, you can do the following commands:
63-
64-
```
65-
$ pxc describe cluster
66-
$ pxc get volume
67-
$ pxc get volume -o wide
68-
$ pxc get nodes
69-
$ pxc get nodes -o wide
70-
```
71-
7232
# Development
7333
Please visit [Development](docs/devel.md)
7434

cmd/gendoc.go

+29-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ limitations under the License.
1616
package cmd
1717

1818
import (
19+
"fmt"
1920
"os"
2021

2122
"github.com/portworx/pxc/pkg/commander"
@@ -24,12 +25,18 @@ import (
2425
"github.com/spf13/cobra/doc"
2526
)
2627

28+
type gendocCmdArgs struct {
29+
outputDir string
30+
format string
31+
}
32+
2733
var (
28-
gendocCmd *cobra.Command
29-
gendocOutputDir string
34+
gendocCmd *cobra.Command
35+
gendocArgs *gendocCmdArgs
3036
)
3137

3238
var _ = commander.RegisterCommandVar(func() {
39+
gendocArgs = &gendocCmdArgs{}
3340
gendocCmd = &cobra.Command{
3441
Use: "gendoc",
3542
Aliases: []string{"gendocs"},
@@ -43,16 +50,32 @@ var _ = commander.RegisterCommandVar(func() {
4350
var _ = commander.RegisterCommandInit(func() {
4451
RootAddCommand(gendocCmd)
4552

46-
gendocCmd.Flags().StringVar(&gendocOutputDir, "output-dir", "pxdocs", "Output directory")
53+
gendocCmd.Flags().StringVar(&gendocArgs.format, "format", "md", "Output formats: md, man")
54+
gendocCmd.Flags().StringVar(&gendocArgs.outputDir, "output-dir", "pxdocs", "Output directory")
4755
})
4856

4957
func GenDocAddCommand(cmd *cobra.Command) {
5058
gendocCmd.AddCommand(cmd)
5159
}
5260

5361
func gendocExec(cmd *cobra.Command, args []string) error {
54-
util.Printf("Creating docs in %s...\n", gendocOutputDir)
62+
switch gendocArgs.format {
63+
case "md":
64+
util.Printf("Creating markdown docs in %s...\n", gendocArgs.outputDir)
65+
66+
os.MkdirAll(gendocArgs.outputDir, 0755)
67+
return doc.GenMarkdownTree(rootCmd, gendocArgs.outputDir)
68+
case "man":
69+
util.Printf("Creating man pages in %s...\n", gendocArgs.outputDir)
70+
71+
os.MkdirAll(gendocArgs.outputDir, 0755)
72+
manHeader := &doc.GenManHeader{
73+
Title: "pxc Portworx client",
74+
}
75+
return doc.GenManTree(rootCmd, manHeader, gendocArgs.outputDir)
76+
77+
default:
78+
return fmt.Errorf("Unknown format: %s", gendocArgs.format)
79+
}
5580

56-
os.MkdirAll(gendocOutputDir, 0755)
57-
return doc.GenMarkdownTree(rootCmd, gendocOutputDir)
5881
}

docs/usage/pxc.md

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,48 @@
11
## pxc
22

3-
Portworx command line tool
3+
Portworx client
44

55
### Synopsis
66

7-
Portworx command line tool
7+
Portworx client
88

99
### Options
1010

1111
```
12-
--config string Config file (default is $HOME/.pxc/config.yml)
13-
--context string Force context name for the command
14-
--v int32 [0-4] Log level verbosity
15-
-h, --help help for pxc
12+
--as string Username to impersonate for the operation
13+
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
14+
--cache-dir string Default HTTP cache directory (default "/home/lpabon/.kube/http-cache")
15+
--certificate-authority string Path to a cert file for the certificate authority
16+
--client-certificate string Path to a client certificate file for TLS
17+
--client-key string Path to a client key file for TLS
18+
--cluster string The name of the kubeconfig cluster to use
19+
--context string The name of the kubeconfig context to use
20+
-h, --help help for pxc
21+
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
22+
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
23+
-n, --namespace string If present, the namespace scope for this CLI request
24+
--pxc.config string Config file (default is $HOME/.pxc/config.yml)
25+
--pxc.secret-name string Kubernetes secret name containing authentication token
26+
--pxc.secret-namespace string Kubernetes namespace where secret contains token
27+
--pxc.token string Portworx authentication token
28+
--pxc.v int32 [0-3] Log level verbosity
29+
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
30+
-s, --server string The address and port of the Kubernetes API server
31+
--token string Bearer token for authentication to the API server
32+
--user string The name of the kubeconfig user to use
1633
```
1734

1835
### SEE ALSO
1936

20-
* [pxc context](pxc_context.md) - Manage connections to Portworx and other systems
37+
* [pxc config](pxc_config.md) - Setup pxc configuration
2138
* [pxc create](pxc_create.md) - Create an object in Portworx
2239
* [pxc delete](pxc_delete.md) - Delete an object in Portworx
2340
* [pxc describe](pxc_describe.md) - Show detailed information of Portworx resources
2441
* [pxc get](pxc_get.md) - Get information from Portworx
42+
* [pxc login](pxc_login.md) - Set authentication information for Portworx cluster
2543
* [pxc logs](pxc_logs.md) - Print Portworx logs
2644
* [pxc patch](pxc_patch.md) - Update field(s) of a Portworx resource
45+
* [pxc script](pxc_script.md) - Run a script against the current cluster
2746
* [pxc version](pxc_version.md) - Show pxc version information
2847

29-
###### Auto generated by spf13/cobra on 6-Nov-2019
48+
###### Auto generated by spf13/cobra on 3-Feb-2020

docs/usage/pxc_config.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## pxc config
2+
3+
Setup pxc configuration
4+
5+
### Synopsis
6+
7+
Setup pxc configuration
8+
9+
```
10+
pxc config [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for config
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
--as string Username to impersonate for the operation
23+
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
24+
--cache-dir string Default HTTP cache directory (default "/home/lpabon/.kube/http-cache")
25+
--certificate-authority string Path to a cert file for the certificate authority
26+
--client-certificate string Path to a client certificate file for TLS
27+
--client-key string Path to a client key file for TLS
28+
--cluster string The name of the kubeconfig cluster to use
29+
--context string The name of the kubeconfig context to use
30+
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
31+
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
32+
-n, --namespace string If present, the namespace scope for this CLI request
33+
--pxc.config string Config file (default is $HOME/.pxc/config.yml)
34+
--pxc.secret-name string Kubernetes secret name containing authentication token
35+
--pxc.secret-namespace string Kubernetes namespace where secret contains token
36+
--pxc.token string Portworx authentication token
37+
--pxc.v int32 [0-3] Log level verbosity
38+
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
39+
-s, --server string The address and port of the Kubernetes API server
40+
--token string Bearer token for authentication to the API server
41+
--user string The name of the kubeconfig user to use
42+
```
43+
44+
### SEE ALSO
45+
46+
* [pxc](pxc.md) - Portworx client
47+
* [pxc config delete-cluster](pxc_config_delete-cluster.md) - Delete pxc cluster configuration
48+
* [pxc config set-cluster](pxc_config_set-cluster.md) - Setup pxc cluster configuration
49+
50+
###### Auto generated by spf13/cobra on 3-Feb-2020
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## pxc config delete-cluster
2+
3+
Delete pxc cluster configuration
4+
5+
### Synopsis
6+
7+
Delete pxc cluster configuration
8+
9+
```
10+
pxc config delete-cluster [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for delete-cluster
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
--as string Username to impersonate for the operation
23+
--as-group stringArray Group to impersonate for the operation, this flag can be repeated to specify multiple groups.
24+
--cache-dir string Default HTTP cache directory (default "/home/lpabon/.kube/http-cache")
25+
--certificate-authority string Path to a cert file for the certificate authority
26+
--client-certificate string Path to a client certificate file for TLS
27+
--client-key string Path to a client key file for TLS
28+
--cluster string The name of the kubeconfig cluster to use
29+
--context string The name of the kubeconfig context to use
30+
--insecure-skip-tls-verify If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure
31+
--kubeconfig string Path to the kubeconfig file to use for CLI requests.
32+
-n, --namespace string If present, the namespace scope for this CLI request
33+
--pxc.config string Config file (default is $HOME/.pxc/config.yml)
34+
--pxc.secret-name string Kubernetes secret name containing authentication token
35+
--pxc.secret-namespace string Kubernetes namespace where secret contains token
36+
--pxc.token string Portworx authentication token
37+
--pxc.v int32 [0-3] Log level verbosity
38+
--request-timeout string The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests. (default "0")
39+
-s, --server string The address and port of the Kubernetes API server
40+
--token string Bearer token for authentication to the API server
41+
--user string The name of the kubeconfig user to use
42+
```
43+
44+
### SEE ALSO
45+
46+
* [pxc config](pxc_config.md) - Setup pxc configuration
47+
48+
###### Auto generated by spf13/cobra on 3-Feb-2020

0 commit comments

Comments
 (0)