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

Fixes #12751 - --plugin-name renamed to --provider #187

Merged
merged 1 commit into from Dec 10, 2015

Conversation

mbacovsky
Copy link
Member

  • renamed option in defaults add
  • fixed minor formatting issues
  • fixed plugin/provider inconsistencies in the code
  • removed default provider_name

I propose removal of the provider default name generated from the plugin name. The reason is that there is no relation between the provider name and the plugin name. I'd prefer one plugin to offer rather more simplier defaults providers then one complex provider. E.g. foreman plugin could implement taxonomies provider providing orgs and locations.

It would be nice to add description to the provider and print it in defaults providers so that the user knows what is it good for. What do you think? @alongoldboim, @tstrachota

@alongoldboim
Copy link
Member

@mbacovsky @tstrachota I think those changes are good, sticking with 1 name convention to reduce confusion (provider vs plugin).
Placing the name of the provider in the provider hands is also good, will be more flexible.
👍

@mbacovsky
Copy link
Member Author

In the second commit I've added some thoughts on refactoring. I changed Providers to be used as an instance, added description and renamed method support?.

The foreman provider would look like this:

require 'hammer_cli'
module HammerCLIForeman
  class TaxonomiesDefaults < HammerCLI::BaseDefaultsProvider
    def initialize
      @provider_name = 'taxonomies'
      @supported_defaults = [:organization_id, :location_id]
      @description = _('Use the default organization and/or location from the server')
    end

    def get_defaults(param)
      param = "default_organization" if param == :organization_id
      param = "default_location" if param == :location_id
      user = HammerCLIForeman.foreman_resource(:users).action(:index).call(:search =>"login="+HammerCLIForeman.credentials.username)
      val = nil
      if user
        val = user["results"].first[param] if user["results"]
        val = val["id"] if val.is_a?(Hash) && param.include?("default")
      end
      val
    end
  end
  HammerCLI.defaults.register_provider(TaxonomiesDefaults.new())
end

@alongoldboim, please take a look if this is something we want in.

@alongoldboim
Copy link
Member

@mbacovsky it looks good to me and i like that we are using instance variables instead of methods so BaseDefaultsProvider is clearer, I still think keeping the provider name as foreman is more user friendly but i have been mistaken before... :)
Lets wait and see what @tstrachota has to say about this change.

@tstrachota
Copy link
Member

  • +1 for the plugin/provider unification
  • big +1 for registering the providers as instances
  • I like throwing NotImplementedexceptions more but no strong opinion here, it's a cosmetic thing
  • Giving more freedom in provider names is probably good.
  • Calling the provider taxonomy would enable for creating more providers for foreman from the start, but: Do we use the name taxonomies anywhere else in UI/cli/api? I think it's org/loc everywhere so it could be a bit confusing for new users. Sticking with "foreman" and re-evaluating later if needed is fine by me. It's not a big issue.

- fixed minor formatting issues
- fixed someplugin/provider inconsistencies
- updated tests
- added description
- Provider to be used as a instance
@mbacovsky
Copy link
Member Author

Squashed

@tstrachota
Copy link
Member

I forgot to mention I like the provider description too. Good idea!
Thanks @mbacovsky @alongoldboim, merging

tstrachota pushed a commit that referenced this pull request Dec 10, 2015
Fixes #12751 - --plugin-name renamed to --provider
@tstrachota tstrachota merged commit f282725 into theforeman:master Dec 10, 2015
@alongoldboim
Copy link
Member

BTW changing the tests to work with regex is a lot better then the previous version 👍

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