-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): Add config and config describe cmds (#178)
* 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
Showing
139 changed files
with
692 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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{}), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.