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

Commit

Permalink
Changes made to respect code review #283 (review)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Conner committed Nov 7, 2016
1 parent b6e8181 commit 96433f0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 20 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
/doc/
/pkg/
/spec/reports/
*.sw?
/tmp/
2 changes: 1 addition & 1 deletion lib/terraforming/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def eip

desc "efs", "EFS"
def efs
execute(Terraforming::Resource::EFS, options)
execute(Terraforming::Resource::EFSFileSystem, options)
end

desc "elb", "ELB"
Expand Down
14 changes: 4 additions & 10 deletions lib/terraforming/resource/efs.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# author: Jim Conner <snafu.x@gmail.com>
# Nov 2016
module Terraforming
module Resource
class EFS
class EFSFileSystem
include Terraforming::Util

def self.tf(client: Aws::EFS::Client.new)
Expand All @@ -22,11 +20,7 @@ def tf
end

def tfstate
idx = -1

efsystems.inject({}) do |resources, efs|
idx += 1

file_systems.each_with_index.inject({}) do |resources, (efs,idx)|
attributes = {
"creation_token" => efs.creation_token,
"id" => efs.file_system_id,
Expand All @@ -35,7 +29,7 @@ def tfstate
"tags.Name" => efs.name,
}

resources["aws_efs_file_system.efs.#{idx}"] = {
resources['%s' % [efs.file_system_id]] = {
"type" => "aws_efs_file_system",
"depends_on" => [],
"primary" => {
Expand All @@ -54,7 +48,7 @@ def tfstate

private

def efsystems
def file_systems
@client.describe_file_systems.data.file_systems.flatten
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/terraforming/template/tf/elastic_filesystem.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% efsystems.each_with_index do |efs, idx| -%>
resource "aws_efs_file_system" "efs.<%= idx %>" {
<% file_systems.each_with_index do |efs, idx| -%>
resource "aws_efs_file_system" "<%= efs.file_system_id %>" {
<% if efs.creation_token -%>
creation_token = "<%= efs.creation_token %>"
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/terraforming/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module Terraforming
end

describe "efs" do
let(:klass) { Terraforming::Resource::EFS }
let(:klass) { Terraforming::Resource::EFSFileSystem }
let(:command) { :efs }

it_behaves_like "CLI examples"
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/terraforming/resource/efs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Terraforming
module Resource
describe EFS do
describe EFSFileSystem do
let(:client) do
Aws::EFS::Client.new(stub_responses: true)
end
Expand Down Expand Up @@ -42,15 +42,15 @@ module Resource
describe ".tf" do
it "should generate tf" do
expect(described_class.tf(client: client)).to eq <<-EOS
resource "aws_efs_file_system" "efs.0" {
resource "aws_efs_file_system" "fs-0000abcd" {
creation_token = "console-1234abcd-1234-abcd-a123-d34db33f0000"
file_system_id = "fs-0000abcd"
performance_mode = "generalPurpose"
tags {
Name = "efs_name_0"
}
}
resource "aws_efs_file_system" "efs.1" {
resource "aws_efs_file_system" "fs-abcd1234" {
creation_token = "console-0000abcd-4321-dcba-a123-d34db33f0000"
file_system_id = "fs-abcd1234"
performance_mode = "generalPurpose"
Expand All @@ -65,7 +65,7 @@ module Resource
describe ".tfstate" do
it "should generate tfstate" do
expect(described_class.tfstate(client: client)).to eq({
"aws_efs_file_system.efs.0" => {
"fs-0000abcd" => {
"type" => "aws_efs_file_system",
"depends_on" => [],
"primary" => {
Expand All @@ -83,7 +83,7 @@ module Resource
"deposed" => [],
"provider" => "aws",
},
"aws_efs_file_system.efs.1" => {
"fs-abcd1234" => {
"type" => "aws_efs_file_system",
"depends_on" => [],
"primary" => {
Expand Down

0 comments on commit 96433f0

Please sign in to comment.