Created
March 27, 2018 13:12
-
-
Save deed02392/91095356a69fad0a64fbf9e291efd18f to your computer and use it in GitHub Desktop.
main.go
This file contains hidden or 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
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