Added additional logging

This commit is contained in:
Marcus Noble 2020-05-02 13:03:39 +01:00
parent 36cd74f70f
commit 27e5034d99
2 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,6 @@ func (op *Client) GetSecret(vault, secretID string) (*Secret, error) {
if err != nil {
return nil, err
}
item := response{}
if err := json.Unmarshal(res, &item); err != nil {
return nil, err

View File

@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"log"
"os"
"os/user"
"time"
@ -38,19 +39,21 @@ func main() {
}
for {
log.Println("[DEBUG] Syncing secrets")
list, err := clientset.CoreV1().Secrets(apiv1.NamespaceAll).List(context.Background(), metav1.ListOptions{})
if err != nil {
panic(err)
}
for _, s := range list.Items {
if passwordID, exists := s.ObjectMeta.Annotations[idAnnotation]; exists {
log.Printf("[INFO] Syncing secret %s with 1Password secret %s\n", s.GetName(), passwordID)
keys := parseAnnotations(s.ObjectMeta.Annotations)
vault := keys["vault"]
item, err := opClient.GetSecret(vault, passwordID)
if err != nil {
fmt.Println("[ERROR] Could not get secret", err)
log.Println("[ERROR] Could not get secret", err)
continue
}
@ -69,7 +72,7 @@ func main() {
}
if _, err := clientset.CoreV1().Secrets(s.GetNamespace()).Update(context.Background(), &s, metav1.UpdateOptions{}); err != nil {
fmt.Println("[ERROR] Could not update secret value", err)
log.Println("[ERROR] Could not update secret value", err)
continue
}
}