cosmos-sdk/cosmovisor/args_test.go

637 lines
20 KiB
Go
Raw Normal View History

package cosmovisor
import (
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
"bytes"
"fmt"
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
"io"
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
"os"
"path/filepath"
"testing"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
"time"
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
"github.com/rs/zerolog"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
"github.com/cosmos/cosmos-sdk/cosmovisor/errors"
)
type argsTestSuite struct {
suite.Suite
}
func TestArgsTestSuite(t *testing.T) {
suite.Run(t, new(argsTestSuite))
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
// cosmovisorEnv are the string values of environment variables used to configure Cosmovisor.
type cosmovisorEnv struct {
Home string
Name string
DownloadBin string
RestartUpgrade string
SkipBackup string
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
DataBackupPath string
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
Interval string
PreupgradeMaxRetries string
}
// ToMap creates a map of the cosmovisorEnv where the keys are the env var names.
func (c cosmovisorEnv) ToMap() map[string]string {
return map[string]string{
EnvHome: c.Home,
EnvName: c.Name,
EnvDownloadBin: c.DownloadBin,
EnvRestartUpgrade: c.RestartUpgrade,
EnvSkipBackup: c.SkipBackup,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
EnvDataBackupPath: c.DataBackupPath,
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
EnvInterval: c.Interval,
EnvPreupgradeMaxRetries: c.PreupgradeMaxRetries,
}
}
// Set sets the field in this cosmovisorEnv corresponding to the provided envVar to the given envVal.
func (c *cosmovisorEnv) Set(envVar, envVal string) {
switch envVar {
case EnvHome:
c.Home = envVal
case EnvName:
c.Name = envVal
case EnvDownloadBin:
c.DownloadBin = envVal
case EnvRestartUpgrade:
c.RestartUpgrade = envVal
case EnvSkipBackup:
c.SkipBackup = envVal
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
case EnvDataBackupPath:
c.DataBackupPath = envVal
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
case EnvInterval:
c.Interval = envVal
case EnvPreupgradeMaxRetries:
c.PreupgradeMaxRetries = envVal
default:
panic(fmt.Errorf("Unknown environment variable [%s]. Ccannot set field to [%s]. ", envVar, envVal))
}
}
// clearEnv clears environment variables and what they were.
// Designed to be used like this:
// initialEnv := clearEnv()
// defer setEnv(nil, initialEnv)
func (s *argsTestSuite) clearEnv() *cosmovisorEnv {
s.T().Logf("Clearing environment variables.")
rv := cosmovisorEnv{}
for envVar := range rv.ToMap() {
rv.Set(envVar, os.Getenv(envVar))
s.Require().NoError(os.Unsetenv(envVar))
}
return &rv
}
// setEnv sets environment variables to the values provided.
// If t is not nil, and there's a problem, the test will fail immediately.
// If t is nil, problems will just be logged using s.T().
func (s *argsTestSuite) setEnv(t *testing.T, env *cosmovisorEnv) {
if t == nil {
s.T().Logf("Restoring environment variables.")
}
for envVar, envVal := range env.ToMap() {
var err error
var msg string
if len(envVal) != 0 {
err = os.Setenv(envVar, envVal)
msg = fmt.Sprintf("setting %s to %s", envVar, envVal)
} else {
err = os.Unsetenv(envVar)
msg = fmt.Sprintf("unsetting %s", envVar)
}
switch {
case t != nil:
require.NoError(t, err, msg)
case err != nil:
s.T().Logf("error %s: %v", msg, err)
default:
s.T().Logf("done %s", msg)
}
}
}
func (s *argsTestSuite) TestConfigPaths() {
cases := map[string]struct {
cfg Config
upgradeName string
expectRoot string
expectGenesis string
expectUpgrade string
}{
"simple": {
cfg: Config{Home: "/foo", Name: "myd"},
upgradeName: "bar",
expectRoot: fmt.Sprintf("/foo/%s", rootName),
expectGenesis: fmt.Sprintf("/foo/%s/genesis/bin/myd", rootName),
expectUpgrade: fmt.Sprintf("/foo/%s/upgrades/bar/bin/myd", rootName),
},
"handle space": {
cfg: Config{Home: "/longer/prefix/", Name: "yourd"},
upgradeName: "some spaces",
expectRoot: fmt.Sprintf("/longer/prefix/%s", rootName),
expectGenesis: fmt.Sprintf("/longer/prefix/%s/genesis/bin/yourd", rootName),
expectUpgrade: "/longer/prefix/cosmovisor/upgrades/some%20spaces/bin/yourd",
},
}
for _, tc := range cases {
s.Require().Equal(tc.cfg.Root(), filepath.FromSlash(tc.expectRoot))
s.Require().Equal(tc.cfg.GenesisBin(), filepath.FromSlash(tc.expectGenesis))
s.Require().Equal(tc.cfg.UpgradeBin(tc.upgradeName), filepath.FromSlash(tc.expectUpgrade))
}
}
// Test validate
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// add more test in test validate
func (s *argsTestSuite) TestValidate() {
relPath := filepath.Join("testdata", "validate")
absPath, err := filepath.Abs(relPath)
s.Require().NoError(err)
testdata, err := filepath.Abs("testdata")
s.Require().NoError(err)
cases := map[string]struct {
cfg Config
valid bool
}{
"happy": {
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
cfg: Config{Home: absPath, Name: "bind", DataBackupPath: absPath},
valid: true,
},
"happy with download": {
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
cfg: Config{Home: absPath, Name: "bind", AllowDownloadBinaries: true, DataBackupPath: absPath},
valid: true,
},
"happy with skip data backup": {
cfg: Config{Home: absPath, Name: "bind", UnsafeSkipBackup: true, DataBackupPath: absPath},
valid: true,
},
"happy with skip data backup and empty data backup path": {
cfg: Config{Home: absPath, Name: "bind", UnsafeSkipBackup: true, DataBackupPath: ""},
valid: true,
},
"happy with skip data backup and no such data backup path dir": {
cfg: Config{Home: absPath, Name: "bind", UnsafeSkipBackup: true, DataBackupPath: filepath.FromSlash("/no/such/dir")},
valid: true,
},
"happy with skip data backup and relative data backup path": {
cfg: Config{Home: absPath, Name: "bind", UnsafeSkipBackup: true, DataBackupPath: relPath},
valid: true,
},
"missing home": {
cfg: Config{Name: "bind"},
valid: false,
},
"missing name": {
cfg: Config{Home: absPath},
valid: false,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
"relative home path": {
cfg: Config{Home: relPath, Name: "bind"},
valid: false,
},
"no upgrade manager subdir": {
cfg: Config{Home: testdata, Name: "bind"},
valid: false,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
"no such home dir": {
cfg: Config{Home: filepath.FromSlash("/no/such/dir"), Name: "bind"},
valid: false,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
"empty data backup path": {
cfg: Config{Home: absPath, Name: "bind", DataBackupPath: ""},
valid: false,
},
"no such data backup path dir": {
cfg: Config{Home: absPath, Name: "bind", DataBackupPath: filepath.FromSlash("/no/such/dir")},
valid: false,
},
"relative data backup path": {
cfg: Config{Home: absPath, Name: "bind", DataBackupPath: relPath},
valid: false,
},
}
for _, tc := range cases {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
errs := tc.cfg.validate()
if tc.valid {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
s.Require().Len(errs, 0)
} else {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
s.Require().Greater(len(errs), 0, "number of errors returned")
}
}
}
func (s *argsTestSuite) TestEnsureBin() {
relPath := filepath.Join("testdata", "validate")
absPath, err := filepath.Abs(relPath)
s.Require().NoError(err)
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
cfg := Config{Home: absPath, Name: "dummyd", DataBackupPath: absPath}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
s.Require().Len(cfg.validate(), 0, "validation errors")
s.Require().NoError(EnsureBinary(cfg.GenesisBin()))
cases := map[string]struct {
upgrade string
hasBin bool
}{
"proper": {"chain2", true},
"no binary": {"nobin", false},
"not executable": {"noexec", false},
"no directory": {"foobarbaz", false},
}
for _, tc := range cases {
err := EnsureBinary(cfg.UpgradeBin(tc.upgrade))
if tc.hasBin {
s.Require().NoError(err)
} else {
s.Require().Error(err)
}
}
}
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
func (s *argsTestSuite) TestBooleanOption() {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
initialEnv := s.clearEnv()
defer s.setEnv(nil, initialEnv)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
name := "COSMOVISOR_TEST_VAL"
check := func(def, expected, isErr bool, msg string) {
v, err := booleanOption(name, def)
if isErr {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
s.Require().Error(err)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
return
}
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
s.Require().NoError(err)
s.Require().Equal(expected, v, msg)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
}
os.Setenv(name, "")
check(true, true, false, "should correctly set default value")
check(false, false, false, "should correctly set default value")
os.Setenv(name, "wrong")
check(true, true, true, "should error on wrong value")
os.Setenv(name, "truee")
check(true, true, true, "should error on wrong value")
os.Setenv(name, "false")
check(true, false, false, "should handle false value")
check(false, false, false, "should handle false value")
os.Setenv(name, "faLSe")
check(true, false, false, "should handle false value case not sensitive")
check(false, false, false, "should handle false value case not sensitive")
os.Setenv(name, "true")
check(true, true, false, "should handle true value")
check(false, true, false, "should handle true value")
os.Setenv(name, "TRUE")
check(true, true, false, "should handle true value case not sensitive")
check(false, true, false, "should handle true value case not sensitive")
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
}
func (s *argsTestSuite) TestDetailString() {
home := "/home"
name := "test-name"
allowDownloadBinaries := true
restartAfterUpgrade := true
pollInterval := 406 * time.Millisecond
unsafeSkipBackup := false
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
dataBackupPath := "/home"
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
preupgradeMaxRetries := 8
cfg := &Config{
Home: home,
Name: name,
AllowDownloadBinaries: allowDownloadBinaries,
RestartAfterUpgrade: restartAfterUpgrade,
PollInterval: pollInterval,
UnsafeSkipBackup: unsafeSkipBackup,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
DataBackupPath: dataBackupPath,
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
PreupgradeMaxRetries: preupgradeMaxRetries,
}
expectedPieces := []string{
"Configurable Values:",
fmt.Sprintf("%s: %s", EnvHome, home),
fmt.Sprintf("%s: %s", EnvName, name),
fmt.Sprintf("%s: %t", EnvDownloadBin, allowDownloadBinaries),
fmt.Sprintf("%s: %t", EnvRestartUpgrade, restartAfterUpgrade),
fmt.Sprintf("%s: %s", EnvInterval, pollInterval),
fmt.Sprintf("%s: %t", EnvSkipBackup, unsafeSkipBackup),
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
fmt.Sprintf("%s: %s", EnvDataBackupPath, home),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
fmt.Sprintf("%s: %d", EnvPreupgradeMaxRetries, preupgradeMaxRetries),
"Derived Values:",
fmt.Sprintf("Root Dir: %s", home),
fmt.Sprintf("Upgrade Dir: %s", home),
fmt.Sprintf("Genesis Bin: %s", home),
fmt.Sprintf("Monitored File: %s", home),
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
fmt.Sprintf("Data Backup Dir: %s", home),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
}
actual := cfg.DetailString()
for _, piece := range expectedPieces {
s.Assert().Contains(actual, piece)
}
}
func (s *argsTestSuite) TestGetConfigFromEnv() {
initialEnv := s.clearEnv()
defer s.setEnv(nil, initialEnv)
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
relPath := filepath.Join("testdata", "validate")
absPath, perr := filepath.Abs(relPath)
s.Require().NoError(perr)
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
newConfig := func(home, name, dataBackupPath string, downloadBin, restartUpgrade, skipBackup bool, interval, preupgradeMaxRetries int) *Config {
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
return &Config{
Home: home,
Name: name,
AllowDownloadBinaries: downloadBin,
RestartAfterUpgrade: restartUpgrade,
PollInterval: time.Millisecond * time.Duration(interval),
UnsafeSkipBackup: skipBackup,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
DataBackupPath: dataBackupPath,
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
PreupgradeMaxRetries: preupgradeMaxRetries,
}
}
tests := []struct {
name string
envVals cosmovisorEnv
expectedCfg *Config
expectedErrCount int
}{
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// EnvHome, EnvName, EnvDownloadBin, EnvRestartUpgrade, EnvSkipBackup, EnvDataBackupPath, EnvDataBackupPath, EnvInterval, EnvPreupgradeMaxRetries
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{
name: "all bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{"", "", "bad", "bad", "bad", "", "bad", "bad"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
expectedErrCount: 8,
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
},
{
name: "all good",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "nothing set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{"", "", "", "", "", "", "", ""},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
expectedErrCount: 3,
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
},
// Note: Home and Name tests are done in TestValidate
{
name: "download bin bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "bad", "false", "true", "", "303", "1"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "download bin not set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "download bin true",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "download bin false",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// EnvHome, EnvName, EnvDownloadBin, EnvRestartUpgrade, EnvSkipBackup, EnvDataBackupPath, EnvInterval, EnvPreupgradeMaxRetries
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{
name: "restart upgrade bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "bad", "true", "", "303", "1"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "restart upgrade not set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, true, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "restart upgrade true",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "true", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, true, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "restart upgrade true",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// EnvHome, EnvName, EnvDownloadBin, EnvRestartUpgrade, EnvSkipBackup, EnvDataBackupPath, EnvInterval, EnvPreupgradeMaxRetries
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{
name: "skip unsafe backups bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "bad", "", "303", "1"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "skip unsafe backups not set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, false, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "skip unsafe backups true",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "true", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, true, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "skip unsafe backups false",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "true", "false", "false", "", "303", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, true, false, false, 303, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// EnvHome, EnvName, EnvDownloadBin, EnvRestartUpgrade, EnvSkipBackup, EnvDataBackupPath, EnvInterval, EnvPreupgradeMaxRetries
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{
name: "poll interval bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "bad", "1"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "poll interval 0",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "0", "1"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "poll interval not set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 300, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "poll interval 987",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "987", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 987, 1),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
{
name: "poll interval 1s",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "1s", "1"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 1000, 1),
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
expectedErrCount: 0,
},
{
name: "poll interval -3m",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "-3m", "1"},
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
// EnvHome, EnvName, EnvDownloadBin, EnvRestartUpgrade, EnvSkipBackup, EnvDataBackupPath, EnvInterval, EnvPreupgradeMaxRetries
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
{
name: "prepupgrade max retries bad",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "406", "bad"},
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedCfg: nil,
expectedErrCount: 1,
},
{
name: "prepupgrade max retries 0",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "406", "0"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 406, 0),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "prepupgrade max retries not set",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "406", ""},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 406, 0),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
{
name: "prepupgrade max retries 5",
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
envVals: cosmovisorEnv{absPath, "testname", "false", "false", "false", "", "406", "5"},
expectedCfg: newConfig(absPath, "testname", absPath, false, false, false, 406, 5),
feat: Add cosmovisor --help (#10229) * [10126]: Create the help text and a func for checking if help is requested. * [10126]: Check if help is requested and print it if so. * [10126]: If help is requested, and it's possible, also run the binary with the --help flag. * [10126]: Add a Config method for creating a detailed string. * [10126]: Include the config detail string if the config is okay. * [10126]: Create a MultiError error. * [10126]: Get all configuration errors rather than just one at a time. * [10126]: Create unit tests on the MultiError. * [10126]: Remove an extra space from an output string. * [10126]: Add unit tests on more of the args stuff. * [10126]: Export the environment variable name strings. * [10126]: Move the help command stuff into the new cmd area. * [10126]: Move the unit tests on the help stuff that just got moved. * [10126]: Lint fixes. * [10126]: Export the EnvPreupgradeMaxRetries const and handle its error the same way as the others. * [10126]: Update the args test with the new config entry. * [10126]: Add EnvPreupgradeMaxRetries to the help text. * [10126]: Output the full path in the error when the root isn't a directory. * [10126]: Add some newlines that were missing from some help output. * [10126]: Add a link to the documentation to the help text. * [10126]: Don't allow MultiErrors to be in MultiErrors by extracting sub-errors while flattening. * [10126]: Add some missing function comments. * [10126]: Add changelog entry. * [10126]: Fix changelog pull link. * [10126]: Move multierror into its own errors package, then rename it to just multi. * [10126]: Change the Config DetailString to use the environment variables instead of Config field names. Also add the missing PreupgradeMaxRetries entry to it. * [10126]: Remove the environment variables from the help text and just defer to the cosmovisor README. * [10126]: Update the help text as suggested. * [10126]: Update ShouldGiveHelp. Give help if either name or home env vars aren't set. Give help if the first arg is help or any args are -h or --help. This reflects cobra defaults. * [10126]: Pass all args when running a help command rather than just using --help. * [10126]: Undo the changes to process.go. Instead, if an app is configured, just call it with the provided args. * [10126]: Output help if any arg is help. * [10126]: Reorg imports. * [10126]: Change 'Monitored Upgrade Info File' to just 'Monitored File'. The rest of the filename gives the rest of the context. * [10126]: Move the config error handling and output out of DoHelp and put it into the main Run function. That way, it's not being done twice in two different ways, and the setup is always logged. * [10126]: Make checking for a help request case-insensitive (to match what's done in version). * [10126]: Fix unit test that broke when I changed the Monitored File title. * [10126]: Change some unit test env var stuff to use a struct instead of string slices.
2021-09-28 16:08:31 -07:00
expectedErrCount: 0,
},
}
for _, tc := range tests {
s.T().Run(tc.name, func(t *testing.T) {
s.setEnv(t, &tc.envVals)
cfg, err := GetConfigFromEnv()
if tc.expectedErrCount == 0 {
assert.NoError(t, err)
} else {
if assert.Error(t, err) {
errCount := 1
if multi, isMulti := err.(*errors.MultiError); isMulti {
errCount = multi.Len()
}
assert.Equal(t, tc.expectedErrCount, errCount, "error count")
}
}
assert.Equal(t, tc.expectedCfg, cfg, "config")
})
}
feat(cosmovisor): strict boolean argument parsing (#10018) ## Description Closes: #10017 --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [x] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-08-30 08:17:12 -07:00
}
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
func (s *argsTestSuite) TestLogConfigOrError() {
cfg := &Config{
Home: "/no/place/like/it",
Name: "cosmotestvisor",
AllowDownloadBinaries: true,
RestartAfterUpgrade: true,
PollInterval: 999,
UnsafeSkipBackup: false,
feat: add backup path (#10649) ## Description Closes: #10533 Cosmovisor can cause problems related to disk space when they try backing up, not enough space might fail the node. A new feature is added to allow user to set a backup path, which can be separated from the node-home directory. A new env var `DAEMON_BACKUP_DIR` is added. If `DAEMON_BACKUP_DIR` is set, backups will go there instead of `DAEMON_HOME`. - [x] add custom data backup dir - [x] add tests --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2022-01-04 06:25:45 -08:00
DataBackupPath: "/no/place/like/it",
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
PreupgradeMaxRetries: 20,
}
errNormal := fmt.Errorf("this is a single error")
errs := []error{
fmt.Errorf("multi-error error 1"),
fmt.Errorf("multi-error error 2"),
fmt.Errorf("multi-error error 3"),
}
errMulti := errors.FlattenErrors(errs...)
makeTestLogger := func(testName string, out io.Writer) zerolog.Logger {
output := zerolog.ConsoleWriter{Out: out, TimeFormat: time.Kitchen, NoColor: true}
return zerolog.New(output).With().Str("test", testName).Timestamp().Logger()
}
tests := []struct {
name string
cfg *Config
err error
contains []string
notcontains []string
}{
{
name: "normal error",
cfg: nil,
err: errNormal,
contains: []string{"configuration error", errNormal.Error()}, // TODO: Fix this.
notcontains: nil,
},
{
name: "multi error",
cfg: nil,
err: errMulti,
fix(cosmovisor): udpate the help and version command output (#10458) ## Description Closes: #10450 * `cosmovisor help` should not print any error. * `cosmovisor version` should print more clear message if it can't run `app version`. ## Before ``` ~/tmp ❯ cosmovisor version Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ❯ cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ``` ## After ``` ❯ ./cosmovisor version Cosmovisor Version: v1.0.0-76-g66bddfb04 8:05PM ERR Can't run APP version 8:05PM ERR 1: error="DAEMON_NAME is not set" 8:05PM ERR 2: error="DAEMON_HOME is not set" ❯ ./cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md To get help for the configured binary: cosmovisor run help ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-19 09:35:56 -08:00
contains: []string{"configuration errors found", errs[0].Error(), errs[1].Error(), errs[2].Error()},
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
notcontains: nil,
},
{
name: "config",
cfg: cfg,
err: nil,
fix(cosmovisor): udpate the help and version command output (#10458) ## Description Closes: #10450 * `cosmovisor help` should not print any error. * `cosmovisor version` should print more clear message if it can't run `app version`. ## Before ``` ~/tmp ❯ cosmovisor version Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ❯ cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md 8:03PM ERR multiple configuration errors found: module=cosmovisor 8:03PM ERR 1: error="DAEMON_NAME is not set" module=cosmovisor 8:03PM ERR 2: error="DAEMON_HOME is not set" module=cosmovisor 8:03PM ERR error="2 errors: 1: DAEMON_NAME is not set, 2: DAEMON_HOME is not set" module=cosmovisor ``` ## After ``` ❯ ./cosmovisor version Cosmovisor Version: v1.0.0-76-g66bddfb04 8:05PM ERR Can't run APP version 8:05PM ERR 1: error="DAEMON_NAME is not set" 8:05PM ERR 2: error="DAEMON_HOME is not set" ❯ ./cosmovisor help Cosmosvisor - A process manager for Cosmos SDK application binaries. Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required DAEMON_NAME env variable). It starts the App by passing all provided arguments and monitors the DAEMON_HOME/data/upgrade-info.json file to perform an update. The upgrade-info.json file is created by the App x/upgrade module when the blockchain height reaches an approved upgrade proposal. The file includes data from the proposal. Cosmovisor interprets that data to perform an update: switch a current binary and restart the App. Configuration of Cosmovisor is done through environment variables, which are documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md To get help for the configured binary: cosmovisor run help ``` --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [x] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [x] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
2021-11-19 09:35:56 -08:00
contains: []string{"Configurable Values", cfg.DetailString()},
feat: Add cosmovisor run command (#10316) * [10285]: Move the Run function into a new cmd/run.go and have main call the renamed/updated RunCosmovisorCommand function. * [10285]: Shorten the run warning to a single line and log it at the start and end of a run. * [10285]: Make the version.go funcs public. Allow for --version. Limit help request to just the first argument. * [10285]: Create a LogConfigOrError that logs the config or config errors in a standard way. * [10285]: Output config info/errors with the help command. * [10285]: Update the Run command to use the new config/error logging. * [10285]: Only provide the first arg to the cmd tester funcs, since that's all that really matters. * [10285]: Tweak a function comment. * [10285]: For the version command, run the binary with version too. * [10285]: Trim whitespace from the first argument before checking if it's any commands. * [10285]: Update and add some unit tests. * [10285]: In GetConfigFromEnv, make sure the cfg isn't null before trying to use it. * [10285]: Add some unit tests for LogConfigOrError. * [10285]: Allow for the poll interval to be defined as a duration. * [10285]: Add changelog line. * [10285]: Update the README to reflect the addition of the run action. * [10285]: slight tweak to changlog. * [10285]: Add a couple lines to the help text about getting help from the configured binary. * [10285]: Remove a println from a unit test. * [10285]: Put the help command first in the README. Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-10-18 08:32:24 -07:00
notcontains: nil,
},
{
name: "error and config - no config details",
cfg: cfg,
err: errNormal,
contains: []string{"error"},
notcontains: []string{"Configuration is valid", EnvName, cfg.Home}, // Just some spot checks.
},
{
name: "nil nil - no output",
cfg: nil,
err: nil,
contains: nil,
notcontains: []string{" "},
},
}
for _, tc := range tests {
s.T().Run(tc.name, func(t *testing.T) {
var b bytes.Buffer
logger := makeTestLogger(tc.name, &b)
LogConfigOrError(logger, tc.cfg, tc.err)
output := b.String()
for _, expected := range tc.contains {
assert.Contains(t, output, expected)
}
for _, unexpected := range tc.notcontains {
assert.NotContains(t, output, unexpected)
}
})
}
}