-
Notifications
You must be signed in to change notification settings - Fork 324
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
Task: Get config cmd #3552
Task: Get config cmd #3552
Conversation
* upstream/master: (24 commits) account type with zero init nonce (iotexproject#3387) [api] Separate Server and Server Handler (iotexproject#3485) [ioctl] Build hdwallet derive command line into new ioctl (iotexproject#3418) [ioctl] Build hdwallet create command line into new ioctl (iotexproject#3470) [makefile] add go mod tidy (iotexproject#3471) [api] update chain metrics (iotexproject#3484) remove config.EVMNetworkID() (iotexproject#3460) [filedao] remove checkMasterChainDBFile() (iotexproject#3463) [api] add crashlog (iotexproject#3456) [api] Move generateBlockMeta to grpcserver.go (iotexproject#3303) [ioctl] Build action hash command line into new ioctl (iotexproject#3425) [ioctl] Build hdwallet export command line into new ioctl (iotexproject#3423) [ioctl] Refactor nodereward command in new ioctl (iotexproject#3416) [ioctl] Cleanup TestNewNodeDelegateCmd (iotexproject#3421) [blockchain] Remove BoltDBDaoOption (iotexproject#3465) remove InMemDaoOption (iotexproject#3464) [action] add evm london test (iotexproject#3402) [ioctl] create main for ioctl/newcmd (iotexproject#3296) [ioctl] Build block bucket command line into new ioctl (iotexproject#3386) [ioctl] Build hdwallet import command line into new ioctl (iotexproject#3419) ...
@pocockn Thanks! |
Pls fix ci fail, thx. |
ioctl/newcmd/config/config_get.go
Outdated
long, _ := client.SelectTranslation(_configGetUseCmdLong) | ||
|
||
return &cobra.Command{ | ||
Use: "VARIABLE", |
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.
"get VARIABLE"
, add translate get 变量
ioctl/newcmd/config/config.go
Outdated
} | ||
|
||
func (m *endpointMessage) String() string { | ||
if output.Format == "" { |
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.
delete output package
ioctl/newcmd/config/config.go
Outdated
|
||
func (m *endpointMessage) String() string { | ||
if output.Format == "" { | ||
message := fmt.Sprint(m.Endpoint, " secure connect(TLS):", m.SecureConnect) |
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.
directly move to line142
ioctl/newcmd/config/config_test.go
Outdated
defer func() { | ||
testutil.CleanupPath(testPath) | ||
}() | ||
_configDir = testPath |
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.
_configDir = os.TempDir()
ioctl/newcmd/config/config_test.go
Outdated
defer func() { | ||
testutil.CleanupPath(testPath) | ||
}() | ||
_configDir = testPath |
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.
_configDir = os.TempDir()
ioctl/newcmd/config/config_test.go
Outdated
for _, tc := range tcs { | ||
cfgItem, err := info.get(tc.arg) | ||
require.NoError(err) | ||
require.Contains(cfgItem, tc.expected) |
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.
expected data should be set before checking if no error
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.
Would it be worth implementing the config set PR before this to use that functionality here?
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.
@huof6829 :)
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.
no need, here just test function get()
ioctl/newcmd/config/config_test.go
Outdated
cfg, cfgFilePath, err := InitConfig() | ||
info := newInfo(cfg, cfgFilePath) | ||
|
||
tcs := []struct { |
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.
combine into line50
if err!=nil {require.Contains(err.Error() }
ioctl/newcmd/config/config_test.go
Outdated
} | ||
} | ||
|
||
func TestConfigGetError(t *testing.T) { |
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.
delete
ioctl/newcmd/config/config.go
Outdated
// get retrieves a config item from its key. | ||
func (c *info) get(arg string) (string, error) { | ||
switch arg { | ||
default: |
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.
move to end
…witch, improve test setup
…task/config-get * 'task/config-get' of github.com:pocockn/iotex-core: [ioctl] Build action command line into new ioctl (iotexproject#3472) fix potential file inclusion via variable (iotexproject#3549)
Codecov Report
@@ Coverage Diff @@
## master #3552 +/- ##
==========================================
- Coverage 75.43% 74.09% -1.35%
==========================================
Files 247 254 +7
Lines 22845 23385 +540
==========================================
+ Hits 17233 17326 +93
- Misses 4685 5133 +448
+ Partials 927 926 -1
|
@pocockn I set |
I see what you mean now, thank you! Are there any more changes? |
ioctl/newcmd/config/config.go
Outdated
case "analyserEndpoint": | ||
return c.readConfig.AnalyserEndpoint, nil | ||
case "all": | ||
return c.readConfig.String(), nil |
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.
line146 and line156 calls output's function.
iotex-core/ioctl/output/format.go
Line 180 in 2ed5b03
func JSONString(out interface{}) string { |
directly refactor it here and call. don't use output
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.
Thanks for your help, done.
…task/config-get * 'task/config-get' of github.com:pocockn/iotex-core: modify test move chanid metrics to chainservice (iotexproject#3544) [ioctl] fix log entries created from user input (iotexproject#3546) add log in rolldposctx (iotexproject#3553) fix uncontrolled data used in path expression (iotexproject#3547) [api] impl. TestGrpcServer_GetServerMeta (iotexproject#3559)
ioctl/newcmd/config/config.go
Outdated
message := endpointMessage{Endpoint: c.readConfig.Endpoint, SecureConnect: c.readConfig.SecureConnect} | ||
return fmt.Sprint(message.Endpoint, " secure connect(TLS):", message.SecureConnect), nil |
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.
delete endpointMessage
, directly use value in line141
ioctl/newcmd/config/config.go
Outdated
} | ||
} | ||
|
||
type endpointMessage struct { |
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.
delete
ioctl/newcmd/config/config.go
Outdated
func jsonString(out interface{}) string { | ||
byteAsJSON, err := json.MarshalIndent(out, "", " ") | ||
if err != nil { | ||
log.Panic(err) |
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.
return err
…task/config-get * 'task/config-get' of github.com:pocockn/iotex-core: [staking] unexport namespace (iotexproject#3551)
@pocockn Thanks for your help! |
ioctl/newcmd/config/config_get.go
Outdated
Short: short, | ||
Long: long, | ||
ValidArgs: _validGetArgs, | ||
Args: func(cmd *cobra.Command, args []string) error { |
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.
@huof6829 pls help fix args issue
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.
fixed. use cobra.ExactValidArgs(1)
* upstream/master: (45 commits) Task: Get config cmd (iotexproject#3552) [ioctl] fix Errors unhandled (iotexproject#3567) fix dir permission and file inclusion (iotexproject#3566) [test] Disable workingset cache in the benchmark test (iotexproject#3558) [pkg] fix deferring unsafe method "Close" on type "*os.File" (iotexproject#3548) [action] Refactor handleTransfer() (iotexproject#3557) Add MinVersion in tls.Config (iotexproject#3562) [ioctl] Modify file permission as 0600 (iotexproject#3563) [httputil] add ReadHeaderTimeout (iotexproject#3550) [staking] unexport namespace (iotexproject#3551) move chanid metrics to chainservice (iotexproject#3544) [ioctl] fix log entries created from user input (iotexproject#3546) add log in rolldposctx (iotexproject#3553) fix uncontrolled data used in path expression (iotexproject#3547) [api] impl. TestGrpcServer_GetServerMeta (iotexproject#3559) [ioctl] Build action command line into new ioctl (iotexproject#3472) fix potential file inclusion via variable (iotexproject#3549) [ioctl] Incorrect conversion between integer types (iotexproject#3522) [action] fix incorrect conversion between integer types (iotexproject#3545) [test] fix TestLoadBlockchainfromDB (iotexproject#3521) ...
Description
Step 1: refactor command _configGetCmd into ./ioctl/newcmd/config/config_get.go
Step 2: create ./ioctl/newcmd/config/config_get_test.go to add unit test
Fixes #3467
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration