Skip to content

Commit

Permalink
Merge pull request #944 from basecamp/single-secrets-instance
Browse files Browse the repository at this point in the history
Ensure we don't load the secrets more than once
  • Loading branch information
djmb authored Sep 17, 2024
2 parents 190dbd1 + f183419 commit bd54c74
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/kamal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ def initialize(raw_config, destination: nil, version: nil, validate: true)

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)
Expand All @@ -63,8 +65,6 @@ def initialize(raw_config, destination: nil, version: nil, validate: true)
@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
Expand Down Expand Up @@ -259,10 +259,6 @@ def to_h
}.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
Expand Down

0 comments on commit bd54c74

Please sign in to comment.