Class: BB8::Commands::Terraform
- Inherits:
-
Object
- Object
- BB8::Commands::Terraform
- Defined in:
- lib/bb8/commands/terraform.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(environment, command, *arguments) ⇒ Terraform
constructor
A new instance of Terraform.
Constructor Details
#initialize(environment, command, *arguments) ⇒ Terraform
Returns a new instance of Terraform.
6 7 8 |
# File 'lib/bb8/commands/terraform.rb', line 6 def initialize(environment, command, *arguments) @environment, @command, @arguments = environment, command, arguments end |
Class Method Details
.call(environment, command, *arguments) ⇒ Object
2 3 4 |
# File 'lib/bb8/commands/terraform.rb', line 2 def self.call(environment, command, *arguments) new(environment, command, *arguments).call end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bb8/commands/terraform.rb', line 10 def call `git pull origin` Dir.chdir environment BB8::SetEncryptionKeys.call `cp ../common.tf common.tf` if File.exist?('../common.tf') Dir['*.enc'].each { |path| BB8::Decrypt.call path } system "terraform #{command} #{arguments.join(' ')}" Dir['*.tfvars'].each { |path| BB8::Encrypt.call path } Dir['*.tfstate'].each { |path| BB8::Encrypt.call path } Dir['*.tfstate.backup'].each { |path| BB8::Encrypt.call path } Dir.chdir '..' `git add .` `git commit -m "[bb8] Update Terraform files after running #{command}"` `git push origin` end |