class ECSUtil::Commands::InitCommand
Public Instance Methods
run()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 4 def run check_dependencies init_password_file check_password_contents check_gitignore init_secrets init_terraform end
Private Instance Methods
check_dependencies()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 31 def check_dependencies step_info "Checking AWS CLI" if `which aws`.strip.empty? terminate("AWS CLI is not installed") end end
check_gitignore()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 55 def check_gitignore unless File.exists?(gitignore_path) step_info "Creating .gitignore file" FileUtils.touch(gitignore_path) end data = File.read(gitignore_path) return if data.include?("vaultpass") step_info "Adding vaultpass to .gitignore" data += "\nvaultpass" File.write(gitignore_path, data.strip + "\n") end
check_password_contents()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 49 def check_password_contents if File.read(password_path).strip.empty? terminate "Your vault password file is empty!" end end
create_password_file()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 44 def create_password_file step_info "Vault password file not found at #{password_path}, creating..." File.write(password_path, SecureRandom.hex(20)) end
gitignore_path()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 19 def gitignore_path @gitignore_path ||= File.join(Dir.pwd, ".gitignore") end
init_password_file()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 38 def init_password_file if !password_path || password_path && !File.exists?(password_path) create_password_file end end
init_secrets()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 69 def init_secrets step_info "Setting up secrets file at #{secrets_path}" FileUtils.mkdir_p(File.dirname(secrets_path)) if File.exists?(secrets_path) step_info "Secrets file already exists, skipping..." return end vault_write(secrets_path, config.secrets_vaultpass, "# This is your secrets file") end
init_terraform()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 82 def init_terraform step_info "Checking if Terraform is installed" if `which terraform`.strip.empty? step_info "Terraform is not found, skipping..." return end unless File.exists?(terraform_path) step_info "Setting up Terraform directory at #{terraform_path}" FileUtils.mkdir_p(terraform_path) end end
password_path()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 15 def password_path @password_path ||= config.secrets_vaultpass end
secrets_path()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 23 def secrets_path @secrets_path ||= File.join(Dir.pwd, "deploy", config.stage, "secrets") end
terraform_path()
click to toggle source
# File lib/ecsutil/commands/init.rb, line 27 def terraform_path @terraform_path ||= File.join(Dir.pwd, "terraform", config.stage) end