This repository has been archived by the owner on Dec 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat templater: Add 'pass' lookup function
This introduces support for looking up secret values in the 'pass' command line tool (https://www.passwordstore.org/). Values like passwords can be interpolated from pass and even more complex structures like certificates for Kubernetes Secrets can be retrieved and base64- encoded as necessary. Fixes #2
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// This file contains the implementation of a template function for retrieving variables from 'pass', the standard UNIX | ||
// password manager. | ||
package templater | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/polydawn/meep" | ||
) | ||
|
||
type PassError struct { | ||
meep.TraitAutodescribing | ||
meep.TraitCausable | ||
Output string | ||
} | ||
|
||
func GetFromPass(key string) (string, error) { | ||
fmt.Fprintf(os.Stderr, "Attempting to look up %s in pass\n", key) | ||
pass := exec.Command("pass", "show", key) | ||
|
||
output, err := pass.CombinedOutput() | ||
if err != nil { | ||
return "", meep.New( | ||
&PassError{Output: string(output)}, | ||
meep.Cause(err), | ||
) | ||
} | ||
|
||
return string(output), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters