Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path config edit command #97

Merged
merged 4 commits into from
Aug 24, 2023

Conversation

dongrie
Copy link
Contributor

@dongrie dongrie commented Aug 18, 2023

Add edit command to config commands

$RELAY paths edit $PATH_NAME [key] [src/dst] [value]

example

$RLY paths edit $PATH_NAME src client-id clinet-id-src
$RLY paths edit $PATH_NAME dst client-id clinet-id-dst

$RLY paths edit $PATH_NAME src connection-id connection-id-src
$RLY paths edit $PATH_NAME dst connection-id connection-id-dst

$RLY paths edit $PATH_NAME src channel-id channel-id-src
$RLY paths edit $PATH_NAME dst channel-id channel-id-dst

$RLY paths edit $PATH_NAME src port-id port-id-src
$RLY paths edit $PATH_NAME dst port-id port-id-dst

$RLY paths edit $PATH_NAME aaa port-id port-id-dst

@dongrie dongrie requested a review from a team as a code owner August 18, 2023 08:13
cmd/config.go Outdated
switch key {
case "client-id":
configPath.Src.ClientID = value
configPath.Dst.ClientID = value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, src client id can be different from dst client id.
The same can be said about connection id, channel id, and port id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add src/dst args

$RLY paths edit $PATH_NAME client-id src clinet-id-src
$RLY paths edit $PATH_NAME client-id dst clinet-id-dst

cmd/config.go Outdated
@@ -23,6 +22,7 @@ func configCmd(ctx *config.Context) *cobra.Command {
cmd.AddCommand(
configShowCmd(ctx),
configInitCmd(),
configEditCmd(ctx),
Copy link
Contributor

@siburu siburu Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you add this feature to the paths subcommand instead of the config subcommand?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to the paths subcommand
e39fd4c

cmd/config.go Show resolved Hide resolved
Signed-off-by: Dongri Jin <[email protected]>
@dongrie dongrie requested a review from siburu August 23, 2023 01:24
cmd/paths.go Show resolved Hide resolved
cmd/paths.go Outdated
@@ -108,14 +110,76 @@ func pathsAddCmd(ctx *config.Context) *cobra.Command {
return fileFlag(cmd)
}

func pathsEditCmd(ctx *config.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "edit [path-name] [key] [src/dst] [value]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following order is more preferable.

  1. path-name
  2. src or dst
  3. key
  4. value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix order
ad6a4b7

Signed-off-by: Dongri Jin <[email protected]>
@dongrie dongrie requested a review from siburu August 23, 2023 04:59
cmd/paths.go Outdated
if err := overWriteConfig(ctx, cmd); err != nil {
return err
}
fmt.Println("config file updated")
Copy link
Contributor

@siburu siburu Aug 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dongrie
This message is unnecessary and please delete it.
return overWriteConfig(ctx, cmd)

The other part looks perfect. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8923490
Fixed

Signed-off-by: Dongri Jin <[email protected]>
Copy link
Contributor

@siburu siburu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks.

@siburu siburu merged commit 43e8592 into hyperledger-labs:main Aug 24, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants