Skip to content

Commit

Permalink
docs: add Cobra docs generator
Browse files Browse the repository at this point in the history
  • Loading branch information
froblesmartin committed Nov 24, 2024
1 parent c18e322 commit a7aad29
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 0 deletions.
48 changes: 48 additions & 0 deletions cmd/gendocs/gen_cloud-sql-proxy_docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2024 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
//
// https://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 (
"fmt"
"os"

"github.com/GoogleCloudPlatform/cloud-sql-proxy/v2/cmd"
"github.com/spf13/cobra/doc"
"k8s.io/kubernetes/cmd/genutils"
)

func main() {
path := "docs/cmd"
if len(os.Args) == 2 {
path = os.Args[1]
} else if len(os.Args) > 2 {
fmt.Fprintf(os.Stderr, "usage: %s [output directory]\n", os.Args[0])
os.Exit(1)
}

outDir, err := genutils.OutDir(path)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to get output directory: %v\n", err)
os.Exit(1)
}

// Set environment variables used so the output is consistent,
// regardless of where we run.
os.Setenv("TMPDIR", "/tmp")

cloudSQLProxy := cmd.NewCommand()
cloudSQLProxy.Execute()
doc.GenMarkdownTree(cloudSQLProxy.Command, outDir)
}
300 changes: 300 additions & 0 deletions docs/cmd/cloud-sql-proxy.md

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions docs/cmd/cloud-sql-proxy_completion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## cloud-sql-proxy completion

Generate the autocompletion script for the specified shell

### Synopsis

Generate the autocompletion script for cloud-sql-proxy for the specified shell.
See each sub-command's help for details on how to use the generated script.


### Options

```
-h, --help help for completion
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy](cloud-sql-proxy.md) - cloud-sql-proxy authorizes and encrypts connections to Cloud SQL.
* [cloud-sql-proxy completion bash](cloud-sql-proxy_completion_bash.md) - Generate the autocompletion script for bash
* [cloud-sql-proxy completion fish](cloud-sql-proxy_completion_fish.md) - Generate the autocompletion script for fish
* [cloud-sql-proxy completion powershell](cloud-sql-proxy_completion_powershell.md) - Generate the autocompletion script for powershell
* [cloud-sql-proxy completion zsh](cloud-sql-proxy_completion_zsh.md) - Generate the autocompletion script for zsh

###### Auto generated by spf13/cobra on 24-Nov-2024
51 changes: 51 additions & 0 deletions docs/cmd/cloud-sql-proxy_completion_bash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## cloud-sql-proxy completion bash

Generate the autocompletion script for bash

### Synopsis

Generate the autocompletion script for the bash shell.

This script depends on the 'bash-completion' package.
If it is not installed already, you can install it via your OS's package manager.

To load completions in your current shell session:

source <(cloud-sql-proxy completion bash)

To load completions for every new session, execute once:

#### Linux:

cloud-sql-proxy completion bash > /etc/bash_completion.d/cloud-sql-proxy

#### macOS:

cloud-sql-proxy completion bash > $(brew --prefix)/etc/bash_completion.d/cloud-sql-proxy

You will need to start a new shell for this setup to take effect.


```
cloud-sql-proxy completion bash
```

### Options

```
-h, --help help for bash
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy completion](cloud-sql-proxy_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 24-Nov-2024
42 changes: 42 additions & 0 deletions docs/cmd/cloud-sql-proxy_completion_fish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## cloud-sql-proxy completion fish

Generate the autocompletion script for fish

### Synopsis

Generate the autocompletion script for the fish shell.

To load completions in your current shell session:

cloud-sql-proxy completion fish | source

To load completions for every new session, execute once:

cloud-sql-proxy completion fish > ~/.config/fish/completions/cloud-sql-proxy.fish

You will need to start a new shell for this setup to take effect.


```
cloud-sql-proxy completion fish [flags]
```

### Options

```
-h, --help help for fish
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy completion](cloud-sql-proxy_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 24-Nov-2024
39 changes: 39 additions & 0 deletions docs/cmd/cloud-sql-proxy_completion_powershell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## cloud-sql-proxy completion powershell

Generate the autocompletion script for powershell

### Synopsis

Generate the autocompletion script for powershell.

To load completions in your current shell session:

cloud-sql-proxy completion powershell | Out-String | Invoke-Expression

To load completions for every new session, add the output of the above command
to your powershell profile.


```
cloud-sql-proxy completion powershell [flags]
```

### Options

```
-h, --help help for powershell
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy completion](cloud-sql-proxy_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 24-Nov-2024
53 changes: 53 additions & 0 deletions docs/cmd/cloud-sql-proxy_completion_zsh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## cloud-sql-proxy completion zsh

Generate the autocompletion script for zsh

### Synopsis

Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:

echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions in your current shell session:

source <(cloud-sql-proxy completion zsh)

To load completions for every new session, execute once:

#### Linux:

cloud-sql-proxy completion zsh > "${fpath[1]}/_cloud-sql-proxy"

#### macOS:

cloud-sql-proxy completion zsh > $(brew --prefix)/share/zsh/site-functions/_cloud-sql-proxy

You will need to start a new shell for this setup to take effect.


```
cloud-sql-proxy completion zsh [flags]
```

### Options

```
-h, --help help for zsh
--no-descriptions disable completion descriptions
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy completion](cloud-sql-proxy_completion.md) - Generate the autocompletion script for the specified shell

###### Auto generated by spf13/cobra on 24-Nov-2024
67 changes: 67 additions & 0 deletions docs/cmd/cloud-sql-proxy_wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
## cloud-sql-proxy wait

Wait for another Proxy process to start

### Synopsis


Waiting for Proxy Startup

Sometimes it is necessary to wait for the Proxy to start.

To help ensure the Proxy is up and ready, the Proxy includes a wait
subcommand with an optional --max flag to set the maximum time to wait.
The wait command uses a separate Proxy's startup endpoint to determine
if the other Proxy process is ready.

Invoke the wait command, like this:

# waits for another Proxy process' startup endpoint to respond
./cloud-sql-proxy wait

Configuration

By default, the Proxy will wait up to the maximum time for the startup
endpoint to respond. The wait command requires that the Proxy be started in
another process with the HTTP health check enabled. If an alternate health
check port or address is used, as in:

./cloud-sql-proxy <INSTANCE_CONNECTION_NAME> \
--http-address 0.0.0.0 \
--http-port 9191

Then the wait command must also be told to use the same custom values:

./cloud-sql-proxy wait \
--http-address 0.0.0.0 \
--http-port 9191

By default the wait command will wait 30 seconds. To alter this value,
use:

./cloud-sql-proxy wait --max 10s


```
cloud-sql-proxy wait [flags]
```

### Options

```
-h, --help help for wait
-m, --max duration maximum amount of time to wait for startup (default 30s)
```

### Options inherited from parent commands

```
--http-address string Address for Prometheus and health check server (default "localhost")
--http-port string Port for Prometheus and health check server (default "9090")
```

### SEE ALSO

* [cloud-sql-proxy](cloud-sql-proxy.md) - cloud-sql-proxy authorizes and encrypts connections to Cloud SQL.

###### Auto generated by spf13/cobra on 24-Nov-2024
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
golang.org/x/sys v0.27.0
google.golang.org/api v0.208.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
k8s.io/kubernetes v1.13.0
)

require (
Expand All @@ -34,6 +35,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
Expand Down Expand Up @@ -64,6 +66,7 @@ require (
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/prometheus v0.35.0 // indirect
github.com/prometheus/statsd_exporter v0.22.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -1022,6 +1023,7 @@ github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZV
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
Expand Down Expand Up @@ -1920,6 +1922,7 @@ k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd/go.mod h1:WOJ3KddDSol4tAG
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65/go.mod h1:sX9MT8g7NVZM5lVL/j8QyCCJe8YSMW30QvGZWaCIDIk=
k8s.io/kubernetes v1.13.0 h1:qTfB+u5M92k2fCCCVP2iuhgwwSOv1EkAkvQY1tQODD8=
k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
Expand Down

0 comments on commit a7aad29

Please sign in to comment.