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

Allow to accept multiple values for --security-group-ids and show deprecated message for comma seprated #439

Merged
merged 9 commits into from
Aug 26, 2016

Conversation

Vasu1105
Copy link

@Vasu1105 Vasu1105 commented Aug 2, 2016

No description provided.

end
end

context "when invalid input is given for --security-group-ids from knife.rb" do
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a reason not support this?

Copy link
Contributor

Choose a reason for hiding this comment

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

couldn't we just check if we were given an array?

Copy link
Author

@Vasu1105 Vasu1105 Aug 5, 2016

Choose a reason for hiding this comment

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

@btm We are expecting a input from user as 'x,y,z'. So we are expecting the input should be in same format. If we have to accept the input as an array too then we need to include that also in help description.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that from the CLI, I wouldn't add array support for the CLI. But using an array would be pretty natural from inside the knife.rb.

Copy link
Author

@Vasu1105 Vasu1105 Aug 6, 2016

Choose a reason for hiding this comment

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

@btm If we do that then we are expecting different input from cli and from knife.rb and its no where mentioned in documentation, so we tried to avoid this confusion for user and expecting same input format from cli and knife.rb

Copy link
Contributor

Choose a reason for hiding this comment

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

We should still allow a comma separated list in a string in the configuration file, and use the same code to parse it that we use when we take a comma separated list from the command line.

We should also allow an array in the configuration file. It is ruby, so the user is likely to try to use the array. We allow arrays in other places in the configuration files, like cookbook_path and ohai.disabled_plugins. We don't have to document it in the user documentation (although it wouldn't hurt). I'd expect a test like it "allows --security-group-ids set from an Array in knife.rb".

@btm
Copy link
Contributor

btm commented Aug 8, 2016

@Vasu1105 I talked to some chef maintainers, and we want to standardize on passing a CLI avalue multiple times by calling the argument multiple times instead of a comma separated list.

A) multiple values passed to the CLI is done by passing the flag multiple times
B). use an array in the configuration file

This is so we don't have to deal with parsing issues exactly like this.

Implementing A:

  1. Add support to pass -g multiple times like in https:/chef/chef/blob/master/lib/chef/knife/bootstrap.rb#L251-L260

  2. detect commas, tell people it's deprecated, and to pass -g multiple times instead

Implementing B:

  1. Add support for arrays

  2. detect a comma separated string, raise a warning telling people to switch to an array.

@Vasu1105
Copy link
Author

@btm working on required changes. Fixing specs is in progress.

@Vasu1105 Vasu1105 changed the title Allowed to accpet comma seprated values with spaces and Added validation for --secruity-group-ids Allow to accept multiple values for --security-group-ids and show deprecated message for comma seprated Aug 12, 2016
@Vasu1105
Copy link
Author

@btm I have created gist for ec2_server_create_spec since git is not showing the diff as it exceeding the number of line changes REF gist https://gist.github.com/Vasu1105/aba8bf2d883bfd51dd717c4598aff9ee.
I have used let and replaced most of the instance variable in specs because of which it showing lot of changes.

:long => "--security-group-ids 'X,Y,Z'",
:description => "The security group ids for this server; required when using VPC,Please provide values in format --security-group-ids 'X,Y,Z'",
:proc => Proc.new { |security_group_ids| security_group_ids.split(',') }
:short => "-g SECURITY_GROUP_IDS",
Copy link
Contributor

Choose a reason for hiding this comment

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

this should probable read -g SECURITY_GROUP_ID since it takes a single value.

@Vasu1105
Copy link
Author

@mwrock & @btm I have updated the changes and also updated the gist for spec file https://gist.github.com/Vasu1105/aba8bf2d883bfd51dd717c4598aff9ee. Please review

:long => "--security-group-ids 'X,Y,Z'",
:description => "The security group ids for this server; required when using VPC,Please provide values in format --security-group-ids 'X,Y,Z'",
:proc => Proc.new { |security_group_ids| security_group_ids.split(',') }
:long => "--security-group-ids IDS",
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd keep 'X,Y,Z' over IDS

@mwrock
Copy link
Member

mwrock commented Aug 24, 2016

👍

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.

5 participants