Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Extended terraforming to create EFS terraform resource. #283

Merged
merged 17 commits into from
Nov 16, 2016

Conversation

notjames
Copy link
Contributor

@notjames notjames commented Nov 3, 2016

No description provided.


def tfstate
efsystems.inject({}) do |resources, efs|
attributes = {
Copy link
Owner

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,
Copy link
Owner

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

@coveralls
Copy link

coveralls commented Nov 3, 2016

Coverage Status

Coverage decreased (-0.4%) to 99.566% when pulling cedc5d5 on notjames:efs into bd8bb53 on dtan4:master.

end

def tfstate
efsystems.inject({}){|resources, efs| resources}
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Space missing to the left of {.
  • Space between { and | missing.
  • Name inject block params |a, e|. :ref
  • Unused block argument - efs. If it's necessary, use _ or _efs as an argument name to indicate that it won't be used. :ref
  • Space missing inside }.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.662% when pulling 4d8fad3 on notjames:efs into bd8bb53 on dtan4:master.

1 similar comment
@coveralls
Copy link

coveralls commented Nov 3, 2016

Coverage Status

Coverage decreased (-0.3%) to 99.662% when pulling 4d8fad3 on notjames:efs into bd8bb53 on dtan4:master.

end

def tfstate
efsystems.inject({}) { |resources, _efs| resources }
Copy link
Owner

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

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Nov 3, 2016

Coverage Status

Coverage decreased (-0.3%) to 99.662% when pulling 5f75427 on notjames:efs into bd8bb53 on dtan4:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 99.662% when pulling 5f75427 on notjames:efs into bd8bb53 on dtan4:master.

@coveralls
Copy link

coveralls commented Nov 3, 2016

Coverage Status

Coverage decreased (-0.3%) to 99.71% when pulling 905ecdd on notjames:efs into bd8bb53 on dtan4:master.

def tfstate
idx = -1

efsystems.inject({}) do |resources, efs|
Copy link
Owner

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
{
Copy link
Owner

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},
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Space inside { missing. :ref
  • Space inside } missing. :ref

end

let(:efs_description_1) do
{
Copy link
Owner

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},
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Space inside { missing. :ref
  • Space inside } missing. :ref

end

before do
client.stub_responses(:describe_file_systems, file_systems: [ efs_description_0, efs_description_1 ])
Copy link
Owner

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" => {
Copy link
Owner

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.

@coveralls
Copy link

coveralls commented Nov 4, 2016

Coverage Status

Coverage decreased (-49.4%) to 50.562% when pulling 25b4f79 on notjames:efs into bd8bb53 on dtan4:master.

@coveralls
Copy link

coveralls commented Nov 4, 2016

Coverage Status

Coverage decreased (-49.4%) to 50.562% when pulling 1919cc0 on notjames:efs into bd8bb53 on dtan4:master.

"deposed" => [],
"provider" => "aws",
},
"aws_efs_file_system.efs.1" => {
Copy link
Owner

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.

Copy link
Contributor Author

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.

@coveralls
Copy link

coveralls commented Nov 4, 2016

Coverage Status

Coverage decreased (-49.4%) to 50.562% when pulling a5d6490 on notjames:efs into bd8bb53 on dtan4:master.

@@ -6,4 +6,5 @@
/doc/
/pkg/
/spec/reports/
*.sw?
Copy link
Owner

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.

Copy link
Contributor Author

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!

Copy link
Contributor Author

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.

Copy link
Owner

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.

Copy link
Contributor Author

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
Copy link
Owner

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}"] = {

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.


private

def efsystems
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

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
Copy link
Owner

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix

Copy link
Contributor Author

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
Copy link
Owner

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@dtan4
Copy link
Owner

dtan4 commented Nov 5, 2016

Resource name must not contain period (.), so efs.#{idx} is invalid for resource name.

Errors:

  * aws_efs_file_system.efs.0: : invalid or unknown key: file_system_id
  * aws_efs_file_system.efs.0: efs.0: resource name can only contain letters, numbers, dashes, and underscores.

How about using other UNIQUE value, e.g. file_system_id?

@dtan4
Copy link
Owner

dtan4 commented Nov 5, 2016

Sorry for late review 🙇

@notjames
Copy link
Contributor Author

notjames commented Nov 6, 2016

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)|
Copy link
Owner

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
  • Unused block argument - idx. If it's necessary, use _ or _idx as an argument name to indicate that it won't be used. :ref

"tags.Name" => efs.name,
}

resources['%s' % [efs.file_system_id]] = {
Copy link
Owner

Choose a reason for hiding this comment

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

[rubocop]

  • Favor format over String#%. :ref

@coveralls
Copy link

coveralls commented Nov 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 96433f0 on notjames:efs into bd8bb53 on dtan4:master.

"tags.Name" => efs.name,
}

resources[format('%s',efs.file_system_id)] = {
Copy link
Owner

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)|
Copy link
Owner

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

@coveralls
Copy link

coveralls commented Nov 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling c33d1f5 on notjames:efs into bd8bb53 on dtan4:master.

@coveralls
Copy link

coveralls commented Nov 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 5a80a4d on notjames:efs into bd8bb53 on dtan4:master.

@coveralls
Copy link

coveralls commented Nov 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 45cb395 on notjames:efs into bd8bb53 on dtan4:master.

@coveralls
Copy link

coveralls commented Nov 7, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling 116fc47 on notjames:efs into bd8bb53 on dtan4:master.

Copy link
Contributor Author

@notjames notjames left a 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" => {
Copy link
Owner

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

Copy link
Contributor Author

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)] = {
Copy link
Owner

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...

Copy link
Contributor Author

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... :))

@coveralls
Copy link

coveralls commented Nov 11, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling aa50486 on notjames:efs into bd8bb53 on dtan4:master.

@dtan4
Copy link
Owner

dtan4 commented Nov 13, 2016

One last thing... please rename efs.rb and efs_spec.rb to efs_file_system.rb and efs_file_system_spec.rb. Mostly in Ruby, class name and file name should be matched.

@notjames
Copy link
Contributor Author

Will do it tonight and push the change.

@coveralls
Copy link

coveralls commented Nov 14, 2016

Coverage Status

Coverage remained the same at 100.0% when pulling d3183b9 on notjames:efs into bd8bb53 on dtan4:master.

@dtan4
Copy link
Owner

dtan4 commented Nov 16, 2016

LGTM 👍 Thanks ❗️

@dtan4 dtan4 merged commit d78824c into dtan4:master Nov 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants