Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zzaakiirr committed Oct 23, 2024
1 parent ef05b0c commit 98b0682
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions lib/command/terraform/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def generate_provider_configs(terraform_app_dir)

def generate_required_providers(terraform_app_dir)
required_cpln_provider = TerraformConfig::RequiredProvider.new(
"cpln",
name: "cpln",
org: config.org,
source: "controlplane-com/cpln",
version: "~> 1.0"
)
Expand All @@ -57,7 +58,7 @@ def generate_required_providers(terraform_app_dir)
end

def generate_providers(terraform_app_dir)
cpln_provider = TerraformConfig::Provider.new("cpln", org: config.org)
cpln_provider = TerraformConfig::Provider.new(name: "cpln", org: config.org)
File.write(terraform_app_dir.join("providers.tf"), cpln_provider.to_tf)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/core/terraform_config/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module TerraformConfig
class Provider < Base
attr_reader :name, :options

def initialize(name, **options)
def initialize(name:, **options)
super()

@name = name
Expand Down
7 changes: 4 additions & 3 deletions lib/core/terraform_config/required_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@

module TerraformConfig
class RequiredProvider < Base
attr_reader :name, :options
attr_reader :name, :org, :options

def initialize(name, **options)
def initialize(name:, org:, **options)
super()

@name = name
@org = org
@options = options
end

def to_tf
block :terraform do
block :cloud do
argument :organization, "PLACEHOLDER"
argument :organization, org
end

block :required_providers do
Expand Down
2 changes: 1 addition & 1 deletion spec/core/terraform_config/provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "spec_helper"

describe TerraformConfig::Provider do
let(:config) { described_class.new(name, **options) }
let(:config) { described_class.new(name: name, **options) }

describe "#to_tf" do
subject(:generated) { config.to_tf }
Expand Down
5 changes: 3 additions & 2 deletions spec/core/terraform_config/required_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
require "spec_helper"

describe TerraformConfig::RequiredProvider do
let(:config) { described_class.new(name, **options) }
let(:config) { described_class.new(name: name, org: org, **options) }

describe "#to_tf" do
subject(:generated) { config.to_tf }

context "when provider is cpln" do
let(:name) { "cpln" }
let(:org) { "test-org" }
let(:options) { { source: "controlplane-com/cpln", version: "~> 1.0" } }

it "generates correct config" do
expect(generated).to eq(
<<~EXPECTED
terraform {
cloud {
organization = "PLACEHOLDER"
organization = "test-org"
}
required_providers {
cpln = {
Expand Down

0 comments on commit 98b0682

Please sign in to comment.