Add a pre-init hook

The hook is run before the environment is loaded or the config is
parsed.

This makes it a bit of a special case - it doesn't have the usual
KAMAL_XYZ environment variables, as we haven't parsed the config.

The use case for this is to do auth checking or setup. So for example
we can confirm you are logged in to a secret manager, and then you
can directly call it to load your secrets in the .kamal/.env file
using .dotenv's
[command substitution](https://github.com/bkeepers/dotenv?tab=readme-ov-file#command-substitution).
This commit is contained in:
Donal McBreen
2024-07-30 16:49:22 +01:00
parent a8837d453c
commit cbb4c87035
12 changed files with 62 additions and 39 deletions

View File

@@ -26,6 +26,10 @@ end
class ActiveSupport::TestCase
include ActiveSupport::Testing::Stream
setup do
Kamal::Cli::Base.ran_pre_init_hook = false
end
private
def stdouted
capture(:stdout) { yield }.strip