Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Validation warnings #73

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

featalion
Copy link
Contributor

Print configuration file validation warnings if:

  • no files to watch supplied
  • port is not defined, when host is

Exit with error code if no files to watch specified at all (in config and via command line).

Related to #43

@@ -35,6 +35,16 @@ type ConfigFile struct {
ExcludePatterns *RegexCollection `yaml:"exclude_patterns"`
}

func (cf ConfigFile) printValidationWarnings() {
if len(cf.Files) == 0 {
log.Warningf("Configuration file contains no files to watch")
Copy link
Contributor

Choose a reason for hiding this comment

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

@leonsodhi: Do you think this is worth printing?

Choose a reason for hiding this comment

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

I'd say the more error handling the better. Silence is a right PITA to troubleshoot, and means we have no error message to work from when customers get in touch.

Copy link
Contributor

Choose a reason for hiding this comment

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

Works for me

@troy
Copy link
Contributor

troy commented Jun 19, 2015

@leonsodhi: Code looks good to me. Can you edit the error messages (and if you think they can be clearer, comments), either by merging and creating a new branch+PR or by branching from this branch?

@featalion
Copy link
Contributor Author

@leonsodhi @troy I added more validation warnings. They will come before daemonization on parent stage or if no daemonization required. To determine the stage, I updated VividCortex/godaemon dependency. This update is workaround for #23 .

@troy
Copy link
Contributor

troy commented Jun 23, 2015

@leonsodhi this looks good to me other than wording and grammar on the error strings and error code variable name ("Exists"). If it saves you time to put revisions in here for Yury to implement, go for it.

@@ -189,7 +206,7 @@ func (cm *ConfigManager) loadConfigFile() error {
file, err := ioutil.ReadFile(cm.Flags.ConfigFile)
// don't error if the default config file isn't found
if os.IsNotExist(err) && cm.Flags.ConfigFile == DefaultConfigFile {
return nil
return defaultConfigDoesNotExist

Choose a reason for hiding this comment

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

It's totally fine for someone to only pass in params via the CLI switches and not have a config file. I'd vote for removing this warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If user misplaced config file, there is no way to know that. In common, users do not read the code to understand why utility fails. They write to support. One notification line can save your and users' time.

Choose a reason for hiding this comment

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

Completely agree on users not wanting to read code on failures, and they definitely shouldn't have to. However, IMO, we should validate that all required parameters have been supplied and not worry about where they came from. If a user specifies all required parameters via the CLI, a config file isn't necessary and thus we can't justify suggesting something is wrong.

The only situation I can think of where this falls down is when an optional parameter is specified in a config file and r_s2 is never asked to load it. One solution to that might be printing the state of all settings when -D is used. I'd prefer to hold off doing that ATM as it hasn't been something that comes up in practice. We can always revisit if things change.

Let me know if I've missed a scenario here or there's a hole in my logic.

@featalion
Copy link
Contributor Author

Summing all comments above, do you want to have -D option for validations warnings? Defaults to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants