Skip to content

Commit

Permalink
feat(config): Add config and config describe cmds (#178)
Browse files Browse the repository at this point in the history
* feat(config): Add config and config describe cmds

- At the moment, `config` only alias to `config describe` until we have newer additions.

* fix: Doc generation for docs.meroxa.com

* chore: update wording

Co-authored-by: Jesse Jordan <[email protected]>

* feat(config) Update docs on describe

Co-authored-by: Jesse Jordan <[email protected]>
  • Loading branch information
raulb and jayjayjpg authored Aug 20, 2021
1 parent 3b4a500 commit fa7903a
Show file tree
Hide file tree
Showing 139 changed files with 692 additions and 278 deletions.
2 changes: 1 addition & 1 deletion cmd/meroxa/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func RegisterGlobalFlags(cmd *cobra.Command) {
cmd.PersistentFlags().StringVar(&flagConfig, "config", "", "config file")
cmd.PersistentFlags().StringVar(&flagAPIURL, "api-url", "", "API url")
cmd.PersistentFlags().BoolVar(&flagDebug, "debug", false, "display any debugging information")
cmd.PersistentFlags().DurationVar(&flagTimeout, "timeout", time.Second*10, "set the client timeout") // nolint:gomnd
cmd.PersistentFlags().DurationVar(&flagTimeout, "timeout", time.Second*10, "set the duration of the client timeout in seconds (default 10s)") // nolint:gomnd,lll

if err := cmd.PersistentFlags().MarkHidden("api-url"); err != nil {
panic(fmt.Sprintf("could not mark flag as hidden: %v", err))
Expand Down
52 changes: 52 additions & 0 deletions cmd/meroxa/root/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright © 2021 Meroxa Inc
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
http://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 impliee.
See the License for the specific language governing permissions and
limitations under the License.
*/

package config

import (
"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/spf13/cobra"
)

type Config struct {
Describe
}

var (
_ builder.CommandWithAliases = (*Config)(nil)
_ builder.CommandWithDocs = (*Config)(nil)
_ builder.CommandWithSubCommands = (*Config)(nil)
)

func (c *Config) Usage() string {
return "config"
}

func (*Config) Docs() builder.Docs {
return builder.Docs{
Short: "Manage your Meroxa CLI configuration",
}
}

func (*Config) Aliases() []string {
return []string{"cfg"}
}

func (*Config) SubCommands() []*cobra.Command {
return []*cobra.Command{
builder.BuildCobraCommand(&Describe{}),
}
}
42 changes: 23 additions & 19 deletions cmd/meroxa/root/env/env.go → cmd/meroxa/root/config/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,50 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package env
package config

import (
"context"
"fmt"
"sort"
"strings"

"github.com/meroxa/cli/cmd/meroxa/global"

"github.com/meroxa/cli/cmd/meroxa/builder"
"github.com/meroxa/cli/cmd/meroxa/global"
"github.com/meroxa/cli/log"
)

var (
_ builder.CommandWithDocs = (*Env)(nil)
_ builder.CommandWithLogger = (*Env)(nil)
_ builder.CommandWithExecute = (*Env)(nil)
_ builder.CommandWithHidden = (*Env)(nil)
_ builder.CommandWithDocs = (*Describe)(nil)
_ builder.CommandWithLogger = (*Describe)(nil)
_ builder.CommandWithExecute = (*Describe)(nil)
)

type Env struct {
type Describe struct {
logger log.Logger
}

func (e *Env) Usage() string {
return "env"
func (e *Describe) Usage() string {
return "describe"
}

func (e *Env) Docs() builder.Docs {
func (e *Describe) Docs() builder.Docs {
return builder.Docs{
Short: "Show Meroxa CLI environment details",
Short: "Show Meroxa CLI configuration details",
Example: "" +
"$ meroxa config describe\n" +
"Using meroxa config located in \"/Users/my-name/Library/Application Support/meroxa/config.env\n\n" +
"access_token: c0f928b...c337a0d\n" +
"actor: [email protected]\n" +
"actor_uuid: c0f928ba-d40e-40c5-a7fa-cf281c337a0d\n" +
"refresh_token: c337a0d...c0f928b\n",
Long: "This command will return the content of your configuration file where you could find your `access_token` " +
"and then `refresh_token` for your `meroxa login`. They're stored in the home directory on your machine. " +
"On Unix, including MacOS, it's stored in `$HOME`, and on Windows is stored in `%USERPROFILE%`.",
}
}

func (e *Env) Execute(ctx context.Context) error {
func (e *Describe) Execute(ctx context.Context) error {
path := global.Config.ConfigFileUsed()

var env struct {
Expand All @@ -76,15 +84,11 @@ func (e *Env) Execute(ctx context.Context) error {
return nil
}

func (e *Env) Hidden() bool {
return true
}

func (e *Env) Logger(logger log.Logger) {
func (e *Describe) Logger(logger log.Logger) {
e.logger = logger
}

func (e *Env) obfuscate(key, value string) string {
func (e *Describe) obfuscate(key, value string) string {
if !strings.Contains(key, "token") {
return value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package env
package config

import (
"context"
Expand All @@ -29,7 +29,7 @@ import (
"github.com/meroxa/cli/log"
)

func TestEnvExecution(t *testing.T) {
func TestConfigDescribeExecution(t *testing.T) {
ctx := context.Background()
logger := log.NewTestLogger()

Expand All @@ -52,7 +52,7 @@ func TestEnvExecution(t *testing.T) {
cfg.SetConfigFile(env.Path)
global.Config = cfg

e := &Env{
e := &Describe{
logger: logger,
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/meroxa/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"github.com/meroxa/cli/cmd/meroxa/root/api"
"github.com/meroxa/cli/cmd/meroxa/root/auth"
"github.com/meroxa/cli/cmd/meroxa/root/billing"
"github.com/meroxa/cli/cmd/meroxa/root/config"
"github.com/meroxa/cli/cmd/meroxa/root/connectors"
"github.com/meroxa/cli/cmd/meroxa/root/endpoints"
"github.com/meroxa/cli/cmd/meroxa/root/env"
"github.com/meroxa/cli/cmd/meroxa/root/login"
"github.com/meroxa/cli/cmd/meroxa/root/logout"
"github.com/meroxa/cli/cmd/meroxa/root/open"
Expand Down Expand Up @@ -82,7 +82,7 @@ meroxa resources list --types
cmd.AddCommand(builder.BuildCobraCommand(&connectors.Connect{}))
cmd.AddCommand(builder.BuildCobraCommand(&connectors.Connectors{}))
cmd.AddCommand(builder.BuildCobraCommand(&endpoints.Endpoints{}))
cmd.AddCommand(builder.BuildCobraCommand(&env.Env{}))
cmd.AddCommand(builder.BuildCobraCommand(&config.Config{}))
cmd.AddCommand(builder.BuildCobraCommand(&login.Login{}))
cmd.AddCommand(builder.BuildCobraCommand(&logout.Logout{}))
cmd.AddCommand(builder.BuildCobraCommand(&open.Open{}))
Expand Down
3 changes: 2 additions & 1 deletion docs/cmd/md/meroxa.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ meroxa resources list --types
--debug display any debugging information
-h, --help help for meroxa
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand All @@ -29,6 +29,7 @@ meroxa resources list --types
* [meroxa auth](meroxa_auth.md) - Authentication commands for Meroxa
* [meroxa billing](meroxa_billing.md) - Open your billing page in a web browser
* [meroxa completion](meroxa_completion.md) - Generate completion script
* [meroxa config](meroxa_config.md) - Manage your Meroxa CLI configuration
* [meroxa connect](meroxa_connect.md) - Connect two resources together
* [meroxa connectors](meroxa_connectors.md) - Manage connectors on Meroxa
* [meroxa endpoints](meroxa_endpoints.md) - Manage endpoints on Meroxa
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ meroxa api POST /v1/endpoints '{"protocol": "HTTP", "stream": "resource-2-499379
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Authentication commands for Meroxa
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_auth_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ meroxa auth login [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_auth_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ meroxa auth logout [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_auth_whoami.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ meroxa whoami
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ meroxa billing [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ meroxa completion [bash|zsh|fish|powershell]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
28 changes: 28 additions & 0 deletions docs/cmd/md/meroxa_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## meroxa config

Manage your Meroxa CLI configuration

```
meroxa config [flags]
```

### Options

```
-h, --help help for config
```

### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO

* [meroxa](meroxa.md) - The Meroxa CLI
* [meroxa config describe](meroxa_config_describe.md) - Show Meroxa CLI configuration details

44 changes: 44 additions & 0 deletions docs/cmd/md/meroxa_config_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## meroxa config describe

Show Meroxa CLI configuration details

### Synopsis

This command will return the content of your configuration file where you could find your `access_token` and then `refresh_token` for your `meroxa login`. They're stored in the home directory on your machine. On Unix, including MacOS, it's stored in `$HOME`, and on Windows is stored in `%USERPROFILE%`.

```
meroxa config describe [flags]
```

### Examples

```
$ meroxa config describe
Using meroxa config located in "/Users/my-name/Library/Application Support/meroxa/config.env
access_token: c0f928b...c337a0d
actor: [email protected]
actor_uuid: c0f928ba-d40e-40c5-a7fa-cf281c337a0d
refresh_token: c337a0d...c0f928b
```

### Options

```
-h, --help help for describe
```

### Options inherited from parent commands

```
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO

* [meroxa config](meroxa_config.md) - Manage your Meroxa CLI configuration

2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ meroxa connect --from RESOURCE-NAME --to RESOURCE-NAME [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Manage connectors on Meroxa
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connectors_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ meroxa connectors create [NAME] --to pg2redshift --input orders --pipeline my-pi
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connectors_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ meroxa connectors describe [NAME] [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connectors_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ meroxa connectors list [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd/md/meroxa_connectors_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ meroxa connectors logs NAME [flags]
--config string config file
--debug display any debugging information
--json output json
--timeout duration set the client timeout (default 10s)
--timeout duration set the duration of the client timeout in seconds (default 10s) (default 10s)
```

### SEE ALSO
Expand Down
Loading

0 comments on commit fa7903a

Please sign in to comment.