Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the env check #499

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/kamal/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ def print_runtime
def mutating
return yield if KAMAL.holding_lock?

KAMAL.config.ensure_env_available

run_hook "pre-connect"

ensure_run_directory
Expand Down
7 changes: 0 additions & 7 deletions lib/kamal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,6 @@ def valid?
ensure_destination_if_required && ensure_required_keys_present && ensure_valid_kamal_version
end

# Will raise KeyError if any secret ENVs are missing
def ensure_env_available
roles.collect(&:env_file).each(&:to_s)

true
end

def to_h
{
roles: role_names,
Expand Down
14 changes: 11 additions & 3 deletions test/cli/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ class CliMainTest < CliTestCase
end

test "deploy with missing secrets" do
assert_raises(KeyError) do
run_command("deploy", config_file: "deploy_with_secrets")
end
invoke_options = { "config_file" => "test/fixtures/deploy_with_secrets.yml", "version" => "999", "skip_hooks" => false }

Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:registry:login", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:build:deliver", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:traefik:boot", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:healthcheck:perform", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:app:stale_containers", [], invoke_options.merge(stop: true))
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:app:boot", [], invoke_options)
Kamal::Cli::Main.any_instance.expects(:invoke).with("kamal:cli:prune:all", [], invoke_options)

run_command("deploy", config_file: "deploy_with_secrets")
end

test "redeploy" do
Expand Down
8 changes: 0 additions & 8 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal "healthcheck-app", @config.healthcheck_service
end

test "env with missing secret" do
assert_raises(KeyError) do
config = Kamal::Configuration.new(@deploy.tap { |c| c.merge!({
env: { "secret" => [ "PASSWORD" ] }
}) }).ensure_env_available
end
end

test "valid config" do
assert @config.valid?
assert @config_with_roles.valid?
Expand Down
5 changes: 5 additions & 0 deletions test/integration/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class MainTest < IntegrationTest
kamal :envify
assert_local_env_file "SECRET_TOKEN=1234"
assert_remote_env_file "SECRET_TOKEN=1234\nCLEAR_TOKEN=4321"
remove_local_env_file

first_version = latest_app_version

Expand Down Expand Up @@ -64,6 +65,10 @@ def assert_local_env_file(contents)
assert_equal contents, deployer_exec("cat .env", capture: true)
end

def remove_local_env_file
deployer_exec("rm .env")
end

def assert_remote_env_file(contents)
assert_equal contents, docker_compose("exec vm1 cat /root/.kamal/env/roles/app-web.env", capture: true)
end
Expand Down
Loading