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

Commit

Permalink
adapt to remote state
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Aug 13, 2020
1 parent 8f4823b commit b323d5b
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/bitte/cli/terraform.cr
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,19 @@ module Bitte
define_argument realm : String, default: "core", required: true

def run
with_workspace "#{cluster}_#{realm}" do
with_workspace realm do
sh! "nix", "build",
"#{flake}#clusters.#{cluster}.tf.#{realm}.output",
"-o", "config.tf.json"
"-o", "config.tf.json.ln"

sh! "terraform", "plan", "-out", plan_file
File.readlink("config.tf.json.ln")
FileUtils.cp(File.readlink("config.tf.json.ln"), "config.tf.json")
FileUtils.rm("config.tf.json.ln")

wait_for_user

sh! "terraform", "apply", plan_file
sh! "terraform", "apply"
end
end

def wait_for_user
log.info { "applying the plan in 20 seconds!" }
log.info { "Press return to apply immediately, Ctrl-C to cancel" }

STDIN.read_timeout = 20
STDIN.gets
rescue IO::TimeoutError
end

def plan_file
"#{cluster}.#{realm}.plan"
end

def realm : String
arguments.realm
end
Expand Down

0 comments on commit b323d5b

Please sign in to comment.