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

Fix unsafe-reset-all for working with default home #9103

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

rootwarp
Copy link
Contributor

Ref. #9102
close #9102

tendermint unsafe-reset-all command should clear client's home directory
but this command is not working with default home flags.

Ad described #9102, unsafe-reset-all command try to clear #HOME/data directory by default
where is not client's home.

To resolve this issue, ParseConfig function explicitly get client's home
and set it into config.

Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, could you rebase your PR against main instead of v0.34.x

@rootwarp rootwarp changed the base branch from v0.34.x to main July 27, 2022 08:18
@rootwarp
Copy link
Contributor Author

Thanks for the fix, could you rebase your PR against main instead of v0.34.x

Fixed :)

@cmwaters cmwaters added the S:backport-to-v0.34.x Tell mergify to backport the PR to v0.34.x label Jul 27, 2022
Copy link
Contributor

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Looks great thanks!

@@ -29,12 +29,20 @@ func registerFlagsRootCmd(cmd *cobra.Command) {

// ParseConfig retrieves the default environment configuration,
// sets up the Tendermint root and ensures that the root exists
func ParseConfig() (*cfg.Config, error) {
func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be better to pass the home path string instead of an entire command but we can clean this up in a later PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx for your comment. I'll clean this up on next issue.

@cmwaters
Copy link
Contributor

There seems to be a failure in one of the integration tests. I wonder if you need to let viper know the path to read the config from. Something like this:

func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) {
        home, err := cmd.Flags().GetString(cli.HomeFlag)
	if err != nil {
		return nil, err
	}

	// name of config file (without extension)
	viper.SetConfigName("config")
	// search root directory
	viper.AddConfigPath(home)
	// search root directory /config
	viper.AddConfigPath(filepath.Join(home, defaultConfigDir))

        conf := cfg.DefaultConfig()
	err := viper.Unmarshal(conf)
	if err != nil {
		return nil, err
	}

	conf.RootDir = home
        ...

@rootwarp
Copy link
Contributor Author

There seems to be a failure in one of the integration tests. I wonder if you need to let viper know the path to read the config from. Something like this:

func ParseConfig(cmd *cobra.Command) (*cfg.Config, error) {
        home, err := cmd.Flags().GetString(cli.HomeFlag)
	if err != nil {
		return nil, err
	}

	// name of config file (without extension)
	viper.SetConfigName("config")
	// search root directory
	viper.AddConfigPath(home)
	// search root directory /config
	viper.AddConfigPath(filepath.Join(home, defaultConfigDir))

        conf := cfg.DefaultConfig()
	err := viper.Unmarshal(conf)
	if err != nil {
		return nil, err
	}

	conf.RootDir = home
        ...

Sorry my bad, I should to test before push PR.
I fixed code to pass test. TMHOME also should be accepted for home directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:backport-to-v0.34.x Tell mergify to backport the PR to v0.34.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants