Ensure we don't load the secrets more than once

Secrets were being created twice, which might require logging in twice.
This commit is contained in:
Donal McBreen
2024-09-17 14:21:43 +01:00
parent 190dbd1ea3
commit f183419f7a

View File

@@ -48,6 +48,8 @@ class Kamal::Configuration
validate! raw_config, example: validation_yml.symbolize_keys, context: "", with: Kamal::Configuration::Validator::Configuration
@secrets = Kamal::Secrets.new(destination: destination)
# Eager load config to validate it, these are first as they have dependencies later on
@servers = Servers.new(config: self)
@registry = Registry.new(config: self)
@@ -63,8 +65,6 @@ class Kamal::Configuration
@ssh = Ssh.new(config: self)
@sshkit = Sshkit.new(config: self)
@secrets = Kamal::Secrets.new(destination: destination)
ensure_destination_if_required
ensure_required_keys_present
ensure_valid_kamal_version
@@ -259,10 +259,6 @@ class Kamal::Configuration
}.compact
end
def secrets
@secrets ||= Kamal::Secrets.new(destination: destination)
end
private
# Will raise ArgumentError if any required config keys are missing
def ensure_destination_if_required