Added additional logging
This commit is contained in:
parent
36cd74f70f
commit
27e5034d99
@ -77,7 +77,6 @@ func (op *Client) GetSecret(vault, secretID string) (*Secret, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
item := response{}
|
item := response{}
|
||||||
if err := json.Unmarshal(res, &item); err != nil {
|
if err := json.Unmarshal(res, &item); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
7
main.go
7
main.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"time"
|
"time"
|
||||||
@ -38,19 +39,21 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
log.Println("[DEBUG] Syncing secrets")
|
||||||
list, err := clientset.CoreV1().Secrets(apiv1.NamespaceAll).List(context.Background(), metav1.ListOptions{})
|
list, err := clientset.CoreV1().Secrets(apiv1.NamespaceAll).List(context.Background(), metav1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
for _, s := range list.Items {
|
for _, s := range list.Items {
|
||||||
if passwordID, exists := s.ObjectMeta.Annotations[idAnnotation]; exists {
|
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)
|
keys := parseAnnotations(s.ObjectMeta.Annotations)
|
||||||
|
|
||||||
vault := keys["vault"]
|
vault := keys["vault"]
|
||||||
|
|
||||||
item, err := opClient.GetSecret(vault, passwordID)
|
item, err := opClient.GetSecret(vault, passwordID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("[ERROR] Could not get secret", err)
|
log.Println("[ERROR] Could not get secret", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +72,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := clientset.CoreV1().Secrets(s.GetNamespace()).Update(context.Background(), &s, metav1.UpdateOptions{}); err != nil {
|
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
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user