-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conf cli #170
Closed
Closed
Conf cli #170
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
880a50b
CLI
liran-funaro e9cd14e
orion cli - skeleton and config command
MayRosenbaum a26b643
new cli skeleton - wip
MayRosenbaum a3f4d30
temporal with config + test
MayRosenbaum 9640365
get config command and version command + tests
MayRosenbaum 49bf48f
CLI - config & version commands + tests
MayRosenbaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,48 @@ | ||
# Config Orion via CLI | ||
|
||
This command-line tool provides a simple way to config an orion database server. | ||
|
||
## Building the tool | ||
1. Run from `orion-sdk` root folder | ||
2. Run `make binary` to create an executable file named bcdbadmin under `bin` directory. | ||
|
||
## Commands | ||
|
||
Here we list and describe the available commands. | ||
We give a short explanation of their usage and describe the flags for each command. | ||
We provide real-world examples demonstrating how to use the CLI tool for various tasks. | ||
|
||
|
||
### Version Command | ||
This command prints the version of the CLI tool. | ||
1. Run from `orion-sdk` root folder. | ||
2. Run `bin/bcdbadmin version`. This command has no flags. | ||
|
||
|
||
|
||
### Config Command | ||
This command enables to config an orion server or ask for the configuration of an orion server. | ||
|
||
#### Get Config Command | ||
1. Run from 'orion-sdk' root folder. | ||
2. For Get Config Run `bin/bcdbadmin config get [args]`. | ||
|
||
Replace `[args]` with flags. | ||
|
||
### | ||
##### Flags | ||
| Flags | Description | | ||
|-----------------------------|---------------------------------------------------------------------| | ||
| `-c, --cli-config-path` | the absolute or relative path of CLI connection configuration file | | ||
| `-p, --cluster-config-path` | the absolute path to which the server configuration will be saved | | ||
|
||
Both flags are necessary flags. If any flag is missing, the cli will raise an error. | ||
|
||
### | ||
##### Example: | ||
|
||
Running | ||
`bin/bcdbadmin config get -c "connection-session-config.yaml" -p "A/B/C"` | ||
reads the connection and session details needed for connecting to a server from `connection-session-config.yaml` and | ||
sends a config TX. | ||
It creates a directory in `A/B/C` with the respective certificates and a yaml file, named shared_cluster_config.yaml, that includes the cluster 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func adminCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "admin", | ||
Short: "manage administrators", | ||
Args: nil, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
} | ||
|
||
cmd.AddCommand(&cobra.Command{ | ||
Use: "add", | ||
Short: "Add an admin", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
}) | ||
|
||
cmd.AddCommand(&cobra.Command{ | ||
Use: "remove", | ||
Short: "Remove an admin", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
}) | ||
|
||
cmd.AddCommand(&cobra.Command{ | ||
Use: "update", | ||
Short: "Update an admin", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
}) | ||
|
||
return cmd | ||
} |
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,27 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/hyperledger-labs/orion-sdk-go/examples/util" | ||
"github.com/stretchr/testify/require" | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestAdminCommand(t *testing.T) { | ||
// 1. Create crypto material and start server | ||
tempDir, err := ioutil.TempDir(os.TempDir(), "ExampleTest") | ||
require.NoError(t, err) | ||
|
||
testServer, _, _, err := util.SetupTestEnv(t, tempDir, uint32(6003)) | ||
require.NoError(t, err) | ||
defer testServer.Stop() | ||
util.StartTestServer(t, testServer) | ||
|
||
// 2. Check cas command response | ||
rootCmd := InitializeOrionCli() | ||
rootCmd.SetArgs([]string{"admin"}) | ||
err = rootCmd.Execute() | ||
require.Error(t, err) | ||
require.Equal(t, err.Error(), "not implemented yet") | ||
} |
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,35 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func casCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "CAs", | ||
Short: "manage CA's", | ||
Args: nil, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
} | ||
|
||
cmd.AddCommand(&cobra.Command{ | ||
Use: "add", | ||
Short: "Add CA", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
}) | ||
|
||
cmd.AddCommand(&cobra.Command{ | ||
Use: "remove", | ||
Short: "Remove CA", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return errors.New("not implemented yet") | ||
}, | ||
}) | ||
|
||
return cmd | ||
} |
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,27 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/hyperledger-labs/orion-sdk-go/examples/util" | ||
"github.com/stretchr/testify/require" | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestCasCommand(t *testing.T) { | ||
// 1. Create crypto material and start server | ||
tempDir, err := ioutil.TempDir(os.TempDir(), "ExampleTest") | ||
require.NoError(t, err) | ||
|
||
testServer, _, _, err := util.SetupTestEnv(t, tempDir, uint32(6003)) | ||
require.NoError(t, err) | ||
defer testServer.Stop() | ||
util.StartTestServer(t, testServer) | ||
|
||
// 2. Check cas command response | ||
rootCmd := InitializeOrionCli() | ||
rootCmd.SetArgs([]string{"CAs"}) | ||
err = rootCmd.Execute() | ||
require.Error(t, err) | ||
require.Equal(t, err.Error(), "not implemented yet") | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add a section about building the tool.