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

Add a common validate_credentials API and method for getting all provider create params #19120

Merged
merged 1 commit into from
Sep 4, 2019

Conversation

agrare
Copy link
Member

@agrare agrare commented Aug 8, 2019

This changes validate_credentials_task from calling raw_connect with
different args for every provider to call a common validate_credentials
method that will be implemented for each provider.

It also adds a top-level method for retrieving each provider's
json-schema create params so that the UI can use data-driven-forms and
build the validate_credentials_task args generically rather than having
to have a case for each provider.

Related: ManageIQ/manageiq-providers-amazon#551

#18818

@agrare agrare added the wip label Aug 8, 2019
@agrare agrare changed the title Add a common validate_credentials API and method for getting all provider create params [WIP] Add a common validate_credentials API and method for getting all provider create params Aug 8, 2019
@agrare
Copy link
Member Author

agrare commented Aug 8, 2019

cc @skateman @Hyperkid123

@agrare
Copy link
Member Author

agrare commented Aug 8, 2019

Sample output:

>> ExtManagementSystem.provider_create_params
=> {"ManageIQ::Providers::Amazon::CloudManager"=>{:title=>"Configure AWS", :fields=>[{:component=>"text-field", :name=>"role", :type=>"hidden", :initialValue=>"ec2"}, {:component=>"text-field", :name=>"region", :label=>"Region"}, {:component=>"text-field", :name=>"ec2_username", :label=>"Access Key"}, {:component=>"text-field", :name=>"ec2_password", :label=>"Secret Key", :type=>"password"}]}}

And the expected payload for AWS's validate_credentials method would look like:

{
  "region" => "",
  "endpoints" => {
    "ec2" => {
      "access_key" => "",
      "secret_access_key" => "",
    }
  }
}

app/models/ems_folder.rb Outdated Show resolved Hide resolved
@agrare agrare force-pushed the add_common_validate_credentials_api branch from 2d6f0cb to 99155de Compare August 19, 2019 17:35
@agrare agrare removed the wip label Aug 19, 2019
@agrare
Copy link
Member Author

agrare commented Aug 19, 2019

I'm going to drop the change to validate_credentials_task for now so that this can be merged without having to coordinate everything perfectly

@miq-bot
Copy link
Member

miq-bot commented Aug 19, 2019

Checked commit agrare@99155de with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@agrare agrare changed the title [WIP] Add a common validate_credentials API and method for getting all provider create params Add a common validate_credentials API and method for getting all provider create params Aug 19, 2019
@agrare
Copy link
Member Author

agrare commented Aug 19, 2019

@skateman
Copy link
Member

I'm okay with this, but could this be used for multiple auth types in a single form? Sometimes we have multiple tabs for providers where you can set different credentials for C&U or something else.

@Hyperkid123
Copy link

@skateman assuming the tab has same fields it can be used. We can add prefixes likes default, ssh etc. In the UI based on the tabs we know the form should contain. Alternatively we can add this definition here.

@Hyperkid123
Copy link

@agrare is there way to unify the field output names and the expected payload fo the validation endpoint? Frankly this does not really help us. Yes we know how many fields the validation needs but we still have to rename them (by hard coding it in UI) in order to match the expected structure in the validation endpoint.

Based on the expected validation input:

{
  "region" => "",
  "endpoints" => {
    "ec2" => {
      "access_key" => "",
      "secret_access_key" => "",
    }
  }
}

the field names should look like this:

region: "region",
ec2_username: "endpoints.ec2.access_key"
ec2_secret_access_key: "endpoints.ec2.secret_access_key"

@skateman
Copy link
Member

@Hyperkid123 the question was more towards the backend being able to handle it than the UI being able to render it...

@agrare
Copy link
Member Author

agrare commented Aug 20, 2019

Since this only has one I simplified it so not need the endpoints array, but if you'd rather keep it consistent then yeah I can go back to having multiple endpoints possible here

@skateman
Copy link
Member

@agrare this is not my call, depends on what @Hyperkid123 wants for other providers where we have multiple endpoints...

@Hyperkid123
Copy link

I would like to avoid having another switch cases based on provider type. I would rather have just one data structure we can just take and use it directly without additional changes everywhere.

@agrare
Copy link
Member Author

agrare commented Aug 20, 2019

@Hyperkid123 done

@Fryguy Fryguy merged commit af86aa6 into ManageIQ:master Sep 4, 2019
@Fryguy Fryguy added this to the Sprint 120 Ending Sep 16, 2019 milestone Sep 4, 2019
@agrare agrare deleted the add_common_validate_credentials_api branch September 4, 2019 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants