-
Notifications
You must be signed in to change notification settings - Fork 92
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 #32081 - Add provider specific inputs #569
Conversation
Not sure if mimicking template input is the best, I am open to suggestions. |
Simpliest IMHO would be just render provider specific template and let providers define the fields. Then we probably could just have an hash of values on provider and no extra model. |
71453ab
to
f5e66ed
Compare
Provider inputs can now be submitted via API as regular template inputs. |
f5e66ed
to
f2a3e0d
Compare
Is that a good thing? How do I as a user know which are job inputs and which are execution specific? If I understand this correctly, as a user I'd in hammer do something like inputs="command=mc,tags=a,b,c"?. Which also brings a question of how many levels of commas would actually work. |
I thought we wanted that so that user does not have to distinguish between what is template input and what is provider input. I am not sure how hammer handles inputs now, buy I expect we would be able to take escaped values such as Or should I revert to having provider inputs separately? |
Perhaps I wasn't clear much then. I think we should distinguish, since (template) inputs are inputs for the job while provider inputs modify the actual engine execution. They should be on the same level as other execution attributes, e.g. effective user, concurrency level. As discussed online, perhaps the best place would be in provider specific subset (we have ssh and ansible today) where we have the effective user right now. |
f2a3e0d
to
69a390d
Compare
99f70bf
to
dcd27d4
Compare
Adds inputs that will be displayed for each template of a specified provider.
dcd27d4
to
c9dafa9
Compare
All green now. |
@job_invocation_params = job_invocation_params | ||
end | ||
|
||
def permit_provider_inputs(invocation_params) | ||
providers = RemoteExecutionProvider.providers.values.reject { |provider| !provider.respond_to?(:provider_input_namespace) || provider.provider_input_namespace.empty? } | ||
providers.map { |provider| invocation_params.dig(*provider.provider_input_namespace)&.permit! } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permit!
modifies the parameters in-place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, inspired by what job_invocation_params does. Do you have a different approach in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we just do this for the side effect then we could each
instead of map
since we discard the result anway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with each
.
@@ -35,6 +35,10 @@ def humanized_name | |||
self.name | |||
end | |||
|
|||
def provider_input_namespace | |||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the name of the method I'd expect a single value, such as a symbol or a string. Why is it an array? Are elements of the array components of the namespace or can a provider have multiple input namespaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am making it more complicated than it needs to be, changed.
d68afb5
to
a364ffb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some general questions.
@@ -0,0 +1,10 @@ | |||
class AddProviderInputs < ActiveRecord::Migration[6.0] | |||
def change | |||
create_table :template_invocation_provider_input_values do |t| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we want to simplify the table name? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think at least invocation_provider_input_values
🤔 but no hard feelings aganst this name.
class AddProviderInputs < ActiveRecord::Migration[6.0] | ||
def change | ||
create_table :template_invocation_provider_input_values do |t| | ||
t.references :template_invocation, :null => false, :index => { :name => 'idx_templ_inv_provider_input_values_on_templ_inv_id' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we naming the index? why not just index: true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because autogenerated index name is too long and it crashes the migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would simplier name of the table help ? 🤔
@@ -74,6 +74,14 @@ | |||
<% end %> | |||
|
|||
<div class="advanced hidden"> | |||
<%= job_template_fields.fields_for :provider_input_values do |provider_input_fields| %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more straight forward if we would have the namespaces here as well?
Just an idea, I don't insist, but seems like it 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it would add another level of nesting into the form so I am a bit hesitant to call it straightforward, but I can certainly add it if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, I'm ok both ways, I just don't like going totally different path API vs UI, but this is minor difference for a good reason, so I can live with that 👍
I changed the table name, the generated index is still too long so I need to supply a shorter name. |
812be55
to
fda4280
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to test with ansible, but code LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what black magic removes the namespace in hammer and makes it directly --tags
but I guess it is ok and that's onlything I found 🤷
@adamruzicka anything against merging this?
Nope, I'm fine with it, let's get it in. |
Thank you @xprazak2 & @ezr-ondrej ! |
Adds inputs that will be displayed for each template
of a specified provider.