hashicorp / hashicorp/consul-template
Feature: get secret version factoring deletions
- Dominant language
- Go
- Stars
- 4.8k
- Forks
- 801
- Avg merge
- 4h 5m
- Merged PRs (30d)
- 6
Description
This is a feature request to be able to retrieve secrets factoring in deletions.
Currently the `secret` function retrieves the latest version, regardless of whether it's been deleted. I suspect that in most use cases, retrieving a deleted secret is not of much use. Therefore there should be a simple mechanism for retrieving the last non-deleted version of a secret.
Additionally, we have a use case where we need to retrieve the last N non-deleted versions. golang text templates are extremely limited, and performing this kind of logic is extremely cumbersome & difficult. It would be nice if there were a way to retrieve the Nth-from-last non-deleted version of a secret.
----
Note: If acceptable, I might be willing to implement this, just need to know what the interface should look like. I'm imagining a new function such as `secretVersion PATH NUM [IS_OFFSET] [EXCLUDE_DELETED]`, where the latter 2 args are boolean flags for toggling functionality. The `IS_OFFSET` would control whether `NUM` is a real version number, or an offset. A positive value would indicate offset from first value, and negative would indicate offset from last value. The `EXCLUDE_DELETED` flag would cause the offset functionality to skip deleted & destroyed versions, and the real-version functionality would throw an error.
Since we already have the `secret` function for obtaining the exact version, and while the interface of this function would be slightly cleaner, we could remove the `IS_OFFSET` parameter and always assume it's an offset.
Contributor guide
Research direction
Start at the existing `secret` template function and trace how it selects versions and handles deleted or destroyed entries. Define an interface for retrieving the last or Nth-from-last non-deleted version, then verify the behavior for exact versions, offsets, and deleted entries with the project's relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100