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 #10832 - separating lookup keys into puppet and variable #2466

Closed
wants to merge 1 commit into from

Conversation

unorthodoxgeek
Copy link
Member

this PR is a combination @orrabin's and my work

@elobato 's edit - a bit more context https://dl.dropboxusercontent.com/u/5892944/Foreman-Parameters-2015-04-16.pdf

@@ -13,4 +13,6 @@
gem 'factory_girl_rails', '~> 4.5', :require => false
gem 'rubocop-checkstyle_formatter', '~> 0.1'
gem "poltergeist"
gem "pry"
Copy link
Member

Choose a reason for hiding this comment

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

Was this added by mistake?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes

@@ -0,0 +1,7 @@
require 'test_helper'
Copy link
Member

Choose a reason for hiding this comment

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

These files (the empty tests) don't really serve any purpose, we can do without them for the moment.

@@ -34,4 +33,14 @@ def destroy
def controller_permission
'external_variables'
end

def find_resource
Copy link
Member

Choose a reason for hiding this comment

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

This is defining both @lookup_key and @variable_lookup_key or @puppetclass_lookup_key. How about overriding resource_name so that it's always "lookup_key"?

@unorthodoxgeek
Copy link
Member Author

@elobato please re review - I think I've applied all changes you requested 😄

}

def lookup_key_id=(val)
::ActiveSupport::Deprecation.warn('lookup_key_id= is deprecated, please use puppetclass_lookup_key_id= instead.')
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Foreman::Deprecation

end

def lookup_key_id=(val)
Foreman::Deprecation.deprecation_warning("1.12", "lookup_key_id= is deprecated, please use puppetclass_lookup_key_id= instead.")
Copy link
Member

Choose a reason for hiding this comment

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

does this effect api v1? should we create a setter for it there?

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't affect v1, will simply show the warning. you want to rename the parameter so v1 will keep on working after deprecation?

Copy link
Member

Choose a reason for hiding this comment

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

We can add a setter/getter on API v1 as Ohad said when the deprecation is removed, adding it now is kind of pointless I think

Copy link
Member Author

Choose a reason for hiding this comment

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

holy molly! Daniel agreed with me!
image

@@ -232,12 +206,6 @@ def load_yaml_or_json(value)
end
end

def ensure_type
if puppetclass_id.present? and is_param?
self.errors.add(:base, _('Global variable or class Parameter, not both'))
Copy link
Member

Choose a reason for hiding this comment

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

This error was not only confusing but I think it only shows up in the logs, not the UI on the develop branch now. Great to see it going away.

@dLobatog
Copy link
Member

dLobatog commented Sep 2, 2015

👍 with me, let's give this a grace period of one day due to the huge size of changes. I'll also take more time to play with it tomorrow and see if I missed anything. Thanks @orrabin & @unorthodoxgeek

.includes(:param_classes)
.paginate(:page => params[:page])
@lookup_keys = resource_base.search_for(params[:search], :order => params[:order]).includes(:puppetclass)
.paginate(:page => params[:page])
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: identation looks off? maybe keep the additional methods per line as it was before.

@dLobatog
Copy link
Member

dLobatog commented Sep 2, 2015

@orrabin @unorthodoxgeek Needs rebasing now, sorry!

@lookup_keys = resource_base.search_for(params[:search], :order => params[:order])
.paginate(:page => params[:page])
.includes(:param_classes)
@puppetclass_authorizer = Authorizer.new(User.current, :collection => @lookup_keys.map(&:puppetclass_id).compact.uniq)
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: use pluck instead of map?

@orrabin
Copy link
Member

orrabin commented Sep 2, 2015

@elobato rebased and changed map to pluck in lookup_key_controller and puppetclass_lookup_key_controller

@dLobatog
Copy link
Member

dLobatog commented Sep 3, 2015

Alright, grace period ended. I gave it a last round of review & tested it again, feels fairly solid. I'm guessing it'll contain some unforeseen bug, but we have plenty of time before 1.10 to iron out the issues.
Merging in 3..2..1.. 💣

@dLobatog
Copy link
Member

dLobatog commented Sep 3, 2015

@unorthodoxgeek @orrabin The manual should contain updated versions of Parametrized Classes and Smart Variables to reflect the changes.

@dLobatog
Copy link
Member

dLobatog commented Sep 3, 2015

Merged as ff7ae22, thanks @unorthodoxgeek!

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