Skip to content

Comments

More configurer validation changes, should fill in missing defaults into config#147

Open
mracine wants to merge 1 commit intoHalibot:configurer-overhaulfrom
mracine:configurer-superhaul
Open

More configurer validation changes, should fill in missing defaults into config#147
mracine wants to merge 1 commit intoHalibot:configurer-overhaulfrom
mracine:configurer-superhaul

Conversation

@mracine
Copy link
Contributor

@mracine mracine commented Oct 29, 2019

Not sure if any of this will make sense, or if it makes sense in the grand scheme of things. Basically the goal was to add logic to fix broken config files. From a few local tests I've run this seems to be working okay. A few things:

  • I have a copy of the irc module as an example, but I basically modified the configurer's configure() method and added the depends parameter for any dependency of an option. One example of this is tls-verify, where depends="tls"
  • I noticed when setting up the irc module on just richteer's changes that it seems to query for all parameters, even optional ones. It has the effect of outputting a lot of <option>: null in the config file. It doesn't seem to break anything, and I tried working around this by having the required local variable in my changes, more in the item below.
  • There's a weird edge case where both an option and an option it depends on might be missing from a config file. Right now it's just carrying on with the default behavior of fixing the option, but maybe we want to do something more clever (such as determining whether that option is needed in the first place based on the parent)?

Again, maybe this is wrong but hopefully helpful in some way, or at least guiding this in the right direction. Please feel free to post feedback on this.

@mracine
Copy link
Contributor Author

mracine commented Oct 29, 2019

Ah yeah, there's conflicts with the base branch that I think we'd need to merge together, it's in the validate code. I modified some things when I was messing with the logic a bit but I think maybe I can revert some of my changes there that are basically doing the same thing in the original branch.

@richteer richteer requested review from richteer and sjrct October 29, 2019 23:58
# Ensure the key exists, and if we aren't taking defaults, ensure we report
if not tmp and not fill_default:
if not tmp and not required:
break
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be a continue instead? if we break we don't validate the rest of the keys


if obj.config != conf:
self.config[key + "-instances"][k] = obj.config
self.config._write_config()
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that I am a fan of this, maybe we should just give a warning instead? I can be convinced otherwise though.

If I am convinced otherwise, we probably should set a bool and do the write after the loop though.

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.

2 participants