-
Notifications
You must be signed in to change notification settings - Fork 657
Extended terraforming to create EFS terraform resource. #283
Conversation
|
||
def tfstate | ||
efsystems.inject({}) do |resources, efs| | ||
attributes = { |
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.
[rubocop]
- Useless assignment to variable -
attributes
. :ref
def tfstate | ||
efsystems.inject({}) do |resources, efs| | ||
attributes = { | ||
"creationtoken" => efs.creationtoken, |
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.
[rubocop]
- Operator
=>
should be surrounded by a single space. :ref
end | ||
|
||
def tfstate | ||
efsystems.inject({}){|resources, efs| resources} |
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.
1 similar comment
end | ||
|
||
def tfstate | ||
efsystems.inject({}) { |resources, _efs| resources } |
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.
[rubocop]
- Name
inject
block params|a, e|
. :ref
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.
Not really understanding this req. Checking into it more.
1 similar comment
…d rspec tests. Test work on local dev env.
def tfstate | ||
idx = -1 | ||
|
||
efsystems.inject({}) do |resources, efs| |
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.
[rubocop]
- Unnecessary spacing detected.
end | ||
|
||
let(:efs_description_0) do | ||
{ |
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.
[rubocop]
- Use 2 (not 4) spaces for indentation. :ref
number_of_mount_targets: 3, | ||
owner_id: "999999999999", | ||
performance_mode: "generalPurpose", | ||
size_in_bytes: {value: 6144}, |
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.
end | ||
|
||
let(:efs_description_1) do | ||
{ |
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.
[rubocop]
- Use 2 (not 4) spaces for indentation. :ref
number_of_mount_targets: 3, | ||
owner_id: "999999999999", | ||
performance_mode: "generalPurpose", | ||
size_in_bytes: {value: 23481234}, |
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.
end | ||
|
||
before do | ||
client.stub_responses(:describe_file_systems, file_systems: [ efs_description_0, efs_description_1 ]) |
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.
[rubocop]
- Space inside square brackets detected. :ref
"deposed" => [], | ||
"provider" => "aws" | ||
}, | ||
"aws_efs_file_system.efs.1" => { |
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.
[rubocop]
- Align the elements of a hash literal if they span more than one line.
"deposed" => [], | ||
"provider" => "aws", | ||
}, | ||
"aws_efs_file_system.efs.1" => { |
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.
[rubocop]
- Align the elements of a hash literal if they span more than one line.
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.
This style request is not making a great deal of sense to me with respect to this data object referenced.
@@ -6,4 +6,5 @@ | |||
/doc/ | |||
/pkg/ | |||
/spec/reports/ | |||
*.sw? |
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.
Please do not include unnecessary change.
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.
This was a necessary change for my environment since I use vim to edit code and I frequently suspend my editor while testing which leaves swap files open. If you prefer I still not add this then sobeit.
Press not that all fixes to code from this code review will be fine on Monday when I get back to work.
Thank you dtan!
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.
Sorry. Autocorrect sucks.
"Press not" was meant to read please note. "Fine"should have been fixed.
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 you're using vim, I strongly recommend to create ~/.gitignore
and write the below.
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags
(generated by https://www.gitignore.io/api/vim)
This gitignore affects globally in your machine. You do not have to write this settings at each repository.
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.
fixed.
idx = -1 | ||
|
||
efsystems.inject({}) do |resources, efs| | ||
idx += 1 |
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.
How about this:
efsystems.each.with_index.inject({}) do |resources, (efs, idx)|
# ...
resources["aws_efs_file_system.efs.#{idx}"] = {
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.
Awesome! This is much nicer.
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.
fixed.
|
||
private | ||
|
||
def efsystems |
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.
efsystems
is not a good name. This should be file_systems
.
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.
Ok.
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.
fixed
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.
with respect to using an unique identifier, I originally used the file_system_id for the name. I was unclear on how that would work for the array in the case of multiple FSes. I'll use this advice for now and hopefully there will be no issues with it. All cards on the table: I'm still not a heavy user of terraform; or in other words, I'm just getting started with it. So, yeah.
# Nov 2016 | ||
module Terraforming | ||
module Resource | ||
class EFS |
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.
Please match Ruby class name to target Terraform resource name.
In this case, class name should be EFSFileSystem
.
REF
https://www.terraform.io/docs/providers/aws/r/efs_file_system.html
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.
Will fix
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.
fixed
@@ -0,0 +1,62 @@ | |||
# author: Jim Conner <snafu.x@gmail.com> | |||
# Nov 2016 |
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.
Please do not include unnecessary comments.
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.
Ok
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.
fixed
Resource name must not contain period (
How about using other UNIQUE value, e.g. |
Sorry for late review 🙇 |
No worries on late review. I'll fix these up and resubmit pull request. |
end | ||
|
||
def tfstate | ||
file_systems.each_with_index.inject({}) do |resources, (efs,idx)| |
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.
"tags.Name" => efs.name, | ||
} | ||
|
||
resources['%s' % [efs.file_system_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.
[rubocop]
- Favor
format
overString#%
. :ref
"tags.Name" => efs.name, | ||
} | ||
|
||
resources[format('%s',efs.file_system_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.
[rubocop]
- Space missing after comma. :ref
end | ||
|
||
def tfstate | ||
file_systems.each_with_index.inject({}) do |resources, (efs, idx)| |
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.
[rubocop]
- Unused block argument -
idx
. If it's necessary, use_
or_idx
as an argument name to indicate that it won't be used. :ref
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.
All of these have been fixed.
describe ".tfstate" do | ||
it "should generate tfstate" do | ||
expect(described_class.tfstate(client: client)).to eq({ | ||
"fs-0000abcd" => { |
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.
Is aws_efs-file-system.
prefix really unnecessary? Other resources has resource name prefix; e.g. https://github.com/notjames/terraforming/blob/master/spec/lib/terraforming/resource/ec2_spec.rb#L455
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.
see previous note. This is fixed now.
"tags.Name" => efs.name, | ||
} | ||
|
||
resources[format('%s', efs.file_system_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.
Please use string interpolation to inject a certain value in String literal.
Actually in this case, it seems that neither string interpolation or format
is required...
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.
Looks like I did in fact miss the aws_efs_file_system prefix in the resource name. Also changed to interpolation (a style that I personally hate, btw, but you're the owner, so... :))
One last thing... please rename |
Will do it tonight and push the change. |
… Ruby class names.
LGTM 👍 Thanks ❗️ |
No description provided.