Skip to content

Instantly share code, notes, and snippets.

@deed02392
Created Mar 27, 2018
Embed
What would you like to do?
main.go
package main
import "go.mozilla.org/sops/decrypt"
import "fmt"
import "bytes"
import "bufio"
import "strings"
import "log"
//import "go.mozilla.org/sops/vendor/github.com/sirupsen/logrus"
//import "go.mozilla.org/sops/logging"
func main() {
//logging.SetLevel(logrus.WarnLevel)
cleartext, err := decrypt.File("test.yaml", "yaml")
if err != nil {
log.Printf("Unable to decrypt creds: %s", err)
}
reader := bytes.NewReader(cleartext)
scanner := bufio.NewScanner(reader)
username := ""
password := ""
for scanner.Scan() {
split := strings.Split(scanner.Text(), ": ")
key := split[0]
val := split[1]
switch key {
case "user":
username = val
case "pass":
password = val
}
}
fmt.Println(username)
fmt.Println(password)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment