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

@ #493 | should validate plugin params before proceeding #494

Conversation

hieptranquoc
Copy link

connect #493
please review this PR!

@hieptranquoc
Copy link
Author

@hoatle I checked every case, and now the plugin configuration will work properly.

reload_required = true
name_validate = validate(plugin, 'name' => plugin['name'])
if !name_validate
logger.warn("Plugin name must be configured, not nil, and not empty")
Copy link
Contributor

Choose a reason for hiding this comment

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

"Plugin name must be configured"

if installed_plugins.empty?
source_validate = validate(plugin, 'sources' => plugin['sources'])
if !source_validate
logger.warn("Plugin sources should be configured when no plugin installed, or we will use default")
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this warn

reload_required = true
end
else
logger.debug('Plugin state not be set, do nothing')
Copy link
Contributor

Choose a reason for hiding this comment

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

when plugin.enabled is true and state is not setted, we should fill it with installed state

Copy link
Member

Choose a reason for hiding this comment

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

plugin state is not set, then do nothing is expected. It means that if the plugin is installed or not installed, users don't care.

Copy link
Contributor

Choose a reason for hiding this comment

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

okey, by the way, the message should be "The plugin state is not set, no action will be taken."

@hieptranquoc hieptranquoc force-pushed the bug/#493-should-validate-plugin-params-before-proceeding branch from 2b98cd7 to c556f84 Compare October 9, 2018 03:56
@hieptranquoc
Copy link
Author

@datphan I've updated! please check again.

@hieptranquoc hieptranquoc force-pushed the bug/#493-should-validate-plugin-params-before-proceeding branch from c556f84 to 7ff558d Compare October 9, 2018 07:31
datphan
datphan previously approved these changes Oct 9, 2018
@hieptranquoc hieptranquoc force-pushed the bug/#493-should-validate-plugin-params-before-proceeding branch from 7ff558d to 8a28422 Compare October 9, 2018 07:38
datphan
datphan previously approved these changes Oct 9, 2018
@hoatle hoatle assigned hoatle and unassigned datphan Oct 9, 2018
@@ -45,5 +58,33 @@ def self.sync(plugins)
def self.installed?(plugin_name)
return Vagrant.has_plugin?(plugin_name)
end

def self.validate(plugin, config)
Copy link
Member

Choose a reason for hiding this comment

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

don't introduce this type of complexity, as I can see it just checks the existence. So use Util.exist? instead

plugin_manager.install_plugin(plugin['name'], Util.symbolize(plugin))
reload_required = true
name_validate = validate(plugin, 'name' => plugin['name'])
if !name_validate
Copy link
Member

@hoatle hoatle Oct 9, 2018

Choose a reason for hiding this comment

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

unless Util.exist? plugin['name'] is enough for example

@hieptranquoc hieptranquoc force-pushed the bug/#493-should-validate-plugin-params-before-proceeding branch from 8a28422 to fc1d021 Compare October 9, 2018 10:16
@hieptranquoc
Copy link
Author

@hoatle I've updated! please review again!

Copy link
Member

@hoatle hoatle left a comment

Choose a reason for hiding this comment

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

LGTM

@hoatle hoatle merged commit 673384e into teracyhq:develop Oct 9, 2018
@ghost ghost removed the stag:under-review label Oct 9, 2018
@hieptranquoc hieptranquoc deleted the bug/#493-should-validate-plugin-params-before-proceeding branch October 29, 2018 10:11
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.

3 participants