Skip to content

Update backend formatting and add --format flag#530

Open
amoses12 wants to merge 1 commit intomasterfrom
austin/mount-format-flag
Open

Update backend formatting and add --format flag#530
amoses12 wants to merge 1 commit intomasterfrom
austin/mount-format-flag

Conversation

@amoses12
Copy link
Copy Markdown
Contributor

@amoses12 amoses12 commented Apr 9, 2026

This PR adds a new --format flag and adds information about the deprecation of the existing --mount-format flag. It also moves all of our formatting to the backend for parity across commands and features.

@amoses12 amoses12 requested a review from a team as a code owner April 9, 2026 18:07
Comment on lines +296 to +309
useBackendFormatting := shouldMountFile && mountAPIFormat != models.JSON && mountFormat != models.TemplateMountFormat
if useBackendFormatting {
var apiError http.Error
_, _, formattedBytes, apiError := http.DownloadSecrets(localConfig.APIHost.Value, utils.GetBool(localConfig.VerifyTLS.Value, true), localConfig.Token.Value, localConfig.EnclaveProject.Value, localConfig.EnclaveConfig.Value, mountAPIFormat, nameTransformer, "", dynamicSecretsTTL, secretsToInclude)
if !apiError.IsNil() {
utils.HandleError(apiError.Unwrap(), apiError.Message)
}
mountOptions.FormattedBytes = formattedBytes
secrets = map[string]string{}
fromCache = false
} else {
// For JSON and template formats, use the standard FetchSecrets path with caching
secrets, fromCache = controllers.FetchSecrets(localConfig, enableCache, fallbackOpts, metadataPath, nameTransformer, dynamicSecretsTTL, format, secretsToInclude)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking: It is pretty unfortunate that we're introducing a regression in functionality here, where now mounting to an env file (or other formats) can no longer use the fallback file or cache. I was hoping that we'd unwind some of the internals of FetchSecrets, it really should just return a raw byte array, since it accepts format as an argument. All FetchSecrets does with it internally is some validations before writing the fallback file, I'm not convinced those are necessary.

If we're not going to do the work to keep the same level of functionality, we still should not be passing around an empty map and putting the raw bytes somewhere else, that's super hacky. At the very least, secrets here should be a byte array, ValidateSecrets can be moved closer to FetchSecrets, and PrepareSecrets should accept a byte array.

Finally, we should get rid of all of the dead code. SecretsToBytes can be removed entirely. secrets_mount.go can also be removed entirely (though the template option will need to be accommodated elsewhere. we should not introduce a breaking change, but this is not a "real" format, it's json piped through a user-defined local template file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants