Remove the envify command
Instead of using `kamal envify` to generate the .env file, we now assume that it will be in place for us. Options in place of `kamal envify`: 1. Pre-generate the .env file 2. Create the env file in the `.pre-init` hook 3. Log into a secret store/check you are logged in in the pre-init hook Then use .dotenv command and variable substitution to interpolate the secrets.
This commit is contained in:
@@ -8,7 +8,6 @@ class CliMainTest < CliTestCase
|
||||
invoke_options = { "config_file" => "test/fixtures/deploy_simple.yml", "version" => "999", "skip_hooks" => false }
|
||||
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:server:bootstrap", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:main:envify", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:env:push", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:boot", [ "all" ], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:deploy)
|
||||
@@ -24,7 +23,6 @@ class CliMainTest < CliTestCase
|
||||
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:server:bootstrap", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:env:push", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:main:envify", [], invoke_options)
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:accessory:boot", [ "all" ], invoke_options)
|
||||
# deploy
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:registry:login", [], invoke_options.merge(skip_local: true))
|
||||
@@ -62,7 +60,7 @@ class CliMainTest < CliTestCase
|
||||
hook_variables = { version: 999, service_version: "app@999", hosts: "1.1.1.1,1.1.1.2", command: "deploy" }
|
||||
|
||||
run_command("deploy", "--verbose").tap do |output|
|
||||
assert_match "Running /usr/bin/env .kamal/hooks/pre-init", output
|
||||
assert_match "Running the pre-init hook...", output
|
||||
assert_hook_ran "pre-connect", output, **hook_variables
|
||||
assert_match /Log into image registry/, output
|
||||
assert_match /Build and push app image/, output
|
||||
@@ -447,50 +445,6 @@ class CliMainTest < CliTestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "envify" do
|
||||
with_test_dotenv(".env.erb": "HELLO=<%= 'world' %>") do
|
||||
run_command("envify")
|
||||
assert_equal("HELLO=world", File.read(".kamal/.env"))
|
||||
end
|
||||
end
|
||||
|
||||
test "envify with blank line trimming" do
|
||||
file = <<~EOF
|
||||
HELLO=<%= 'world' %>
|
||||
<% if true -%>
|
||||
KEY=value
|
||||
<% end -%>
|
||||
EOF
|
||||
|
||||
with_test_dotenv(".env.erb": file) do
|
||||
run_command("envify")
|
||||
assert_equal("HELLO=world\nKEY=value\n", File.read(".kamal/.env"))
|
||||
end
|
||||
end
|
||||
|
||||
test "envify with destination" do
|
||||
with_test_dotenv(".env.world.erb": "HELLO=<%= 'world' %>") do
|
||||
run_command("envify", "-d", "world", config_file: "deploy_for_dest")
|
||||
assert_equal "HELLO=world", File.read(".kamal/.env.world")
|
||||
end
|
||||
end
|
||||
|
||||
test "envify with skip_push" do
|
||||
Pathname.any_instance.expects(:exist?).returns(true).times(2)
|
||||
File.expects(:read).with(".kamal/.env.erb").returns("HELLO=<%= 'world' %>")
|
||||
File.expects(:write).with(".kamal/.env", "HELLO=world", perm: 0600)
|
||||
|
||||
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:env:push").never
|
||||
run_command("envify", "--skip-push")
|
||||
end
|
||||
|
||||
test "envify with clean env" do
|
||||
with_test_dotenv(".env": "HELLO=already", ".env.erb": "HELLO=<%= ENV.fetch 'HELLO', 'never' %>") do
|
||||
run_command("envify", "--skip-push")
|
||||
assert_equal "HELLO=never", File.read(".kamal/.env")
|
||||
end
|
||||
end
|
||||
|
||||
test "remove with confirmation" do
|
||||
run_command("remove", "-y", config_file: "deploy_with_accessories").tap do |output|
|
||||
assert_match /docker container stop traefik/, output
|
||||
|
||||
@@ -2,8 +2,6 @@ require_relative "integration_test"
|
||||
|
||||
class AccessoryTest < IntegrationTest
|
||||
test "boot, stop, start, restart, logs, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :accessory, :boot, :busybox
|
||||
assert_accessory_running :busybox
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ require_relative "integration_test"
|
||||
|
||||
class AppTest < IntegrationTest
|
||||
test "stop, start, boot, logs, images, containers, exec, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :deploy
|
||||
|
||||
assert_app_is_up
|
||||
|
||||
@@ -4,8 +4,6 @@ class BrokenDeployTest < IntegrationTest
|
||||
test "deploying a bad image" do
|
||||
@app = "app_with_roles"
|
||||
|
||||
kamal :envify
|
||||
|
||||
first_version = latest_app_version
|
||||
|
||||
kamal :deploy
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
SECRET_TOKEN='1234 with "中文"'
|
||||
SECRET_TAG='TAGME'
|
||||
@@ -1 +0,0 @@
|
||||
SECRET_TOKEN='1234 with "中文"'
|
||||
@@ -2,8 +2,6 @@ require_relative "integration_test"
|
||||
|
||||
class LockTest < IntegrationTest
|
||||
test "acquire, release, status" do
|
||||
kamal :envify
|
||||
|
||||
kamal :lock, :acquire, "-m 'Integration Tests'"
|
||||
|
||||
status = kamal :lock, :status, capture: true
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require_relative "integration_test"
|
||||
|
||||
class MainTest < IntegrationTest
|
||||
test "envify, deploy, redeploy, rollback, details and audit" do
|
||||
kamal :envify
|
||||
test "env push, deploy, redeploy, rollback, details and audit" do
|
||||
kamal :env, :push
|
||||
assert_env_files
|
||||
remove_local_env_file
|
||||
|
||||
@@ -45,7 +45,7 @@ class MainTest < IntegrationTest
|
||||
test "app with roles" do
|
||||
@app = "app_with_roles"
|
||||
|
||||
kamal :envify
|
||||
kamal :env, :push
|
||||
|
||||
version = latest_app_version
|
||||
|
||||
@@ -65,7 +65,7 @@ class MainTest < IntegrationTest
|
||||
end
|
||||
|
||||
test "config" do
|
||||
config = YAML.load(kamal(:config, "-q", capture: true))
|
||||
config = YAML.load(kamal(:config, capture: true))
|
||||
version = latest_app_version
|
||||
|
||||
assert_equal [ "web" ], config[:roles]
|
||||
@@ -87,7 +87,7 @@ class MainTest < IntegrationTest
|
||||
kamal :remove, "-y"
|
||||
assert_no_images_or_containers
|
||||
|
||||
kamal :envify
|
||||
kamal :env, :push
|
||||
kamal :setup
|
||||
assert_images_and_containers
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ require_relative "integration_test"
|
||||
|
||||
class TraefikTest < IntegrationTest
|
||||
test "boot, reboot, stop, start, restart, logs, remove" do
|
||||
kamal :envify
|
||||
|
||||
kamal :traefik, :boot
|
||||
assert_traefik_running
|
||||
|
||||
|
||||
Reference in New Issue
Block a user