Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
It's easy to misconfigure Kamal secrets, secret helpers, and environment variables. This is especially true for i) users who are new to Kamal, ii) users who may not have noticed the changes to secrets between Kamal 1 and 2, and iii) users like myself who are using Kamal inside Docker and/or in remote environments.
To see how often people have challenges related to secrets, consider the number of issues opened about them. For example, #970, #1001, #1108, and discussion 977. Secrets are simple yet easy to get wrong!
We should make it easier for users to get back on track when secrets are misconfigured. This PR makes it easier.
Pain point
Currently, if secret values are blank, there is no warning.
A common special case is when
KAMAL_REGISTRY_PASSWORD
is not set, as easily happens if the user is trying to get Kamal to work in, say, a GitHub Action. This causeskamal setup
andkamal deploy
to emit the following output. (This example is from #970.)It's hard to understand the root cause there.
Proposed change
Kamal::Secrets
should show a warning whenever it loads an empty value.Kamal::Configuration::Registry
should raise a helpful exception instead of showing that Docker argument error.New behaviour introduced by this PR
Any time
Kamal::Secrets::[]
fetches a blank value, it displays a warning and tips, as shown in the next cases where a blank value is fetched byKamal::Configuration::Registry
.If a blank registry password comes from an unset environment variable, the user sees the warning and tips, and a
Kamal::ConfigurationError
is raised. (Similar if the env var is set to the empty string.)Other comments
It's true that
Kamal::Configuration::Registry
validates the presence of the password key, but it does not detect when that key is replaced with an empty value.I'm happy to make any change to this PR, just let me know. Thanks for contributing to Kamal!