Debian Codegraph @

pkg/crc/config/secret_config.go

raw symbols SCIP
1 package configscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/
2
3 import (
4 "errorsscip-go gomod github.com/golang/go/src go1.20 errors/"
5 "fmtscip-go gomod github.com/golang/go/src go1.20 fmt/"
6
7 "github.com/crc-org/crc/v2/pkg/crc/loggingscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/logging`/"
8 "github.com/spf13/castscip-go gomod github.com/spf13/cast v1.6.0 `github.com/spf13/cast`/"
9 "github.com/zalando/go-keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/"
10 )
11
12 const secretServiceNamescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/secretServiceName. = "crc"
13
14 var ErrSecretsNotAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/ErrSecretsNotAccessible. = errorsscip-go gomod github.com/golang/go/src go1.20 errors/.Newscip-go gomod github.com/golang/go/src go1.20 errors/New().("secret store is not accessible")
15
16 type Secretscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/Secret# string
17
18 func (s Secretscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/Secret#) Stringscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/Secret#String().() string {
19 return string(s)
20 }
21
22 type SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage# struct {
23 secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService. string
24 storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible. bool
25 }
26
27 func NewSecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/NewSecretStorage().() *SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage# {
28 return &SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#{
29 secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService.: secretServiceNamescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/secretServiceName.,
30 storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible.: keyringAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/keyringAccessible().(),
31 }
32 }
33
34 func (c *SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#) Getscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#Get().(key string) interface{} {
35 if !c.storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible. {
36 return nil
37 }
38 secret, err := keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.Getscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/Get().(c.secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService., key)
39 if errorsscip-go gomod github.com/golang/go/src go1.20 errors/.Isscip-go gomod github.com/golang/go/src go1.20 errors/Is().(err, keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.ErrNotFoundscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/ErrNotFound.) {
40 return nil
41 }
42 return secret
43 }
44
45 func (c *SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#) Setscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#Set().(key string, value interface{}) error {
46 if !c.storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible. {
47 return ErrSecretsNotAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/ErrSecretsNotAccessible.
48 }
49 secret, err := castscip-go gomod github.com/spf13/cast v1.6.0 `github.com/spf13/cast`/.ToStringEscip-go gomod github.com/spf13/cast v1.6.0 `github.com/spf13/cast`/ToStringE().(value)
50 if err != nil {
51 return fmtscip-go gomod github.com/golang/go/src go1.20 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.20 fmt/Errorf().("Failed to cast secret value to string: %w", err)
52 }
53 return keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.Setscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/Set().(c.secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService., key, secret)
54 }
55
56 func (c *SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#) Unsetscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#Unset().(key string) error {
57 if !c.storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible. {
58 return ErrSecretsNotAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/ErrSecretsNotAccessible.
59 }
60 err := keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.Deletescip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/Delete().(c.secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService., key)
61 if errorsscip-go gomod github.com/golang/go/src go1.20 errors/.Isscip-go gomod github.com/golang/go/src go1.20 errors/Is().(err, keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.ErrNotFoundscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/ErrNotFound.) {
62 return nil
63 }
64 return err
65 }
66
67 func keyringAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/keyringAccessible().() bool {
68 err := keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.Setscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/Set().("crc-test", "foo", "bar")
69 if err == nil {
70 _ = keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.Deletescip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/Delete().("crc-test", "foo")
71 return true
72 }
73 loggingscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/logging`/.Debugfscip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/logging`/Debugf().("Keyring is not accessible: %v", err)
74 return false
75 }
76
77 func NewEmptyInMemorySecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/NewEmptyInMemorySecretStorage().() *SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage# {
78 keyringscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/.MockInitscip-go gomod github.com/zalando/go-keyring v0.2.4 `github.com/zalando/go-keyring`/MockInit().()
79 return &SecretStoragescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#{
80 secretServicescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#secretService.: secretServiceNamescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/secretServiceName.,
81 storeAccessiblescip-go gomod github.com/crc-org/crc/v2 . `github.com/crc-org/crc/v2/pkg/crc/config`/SecretStorage#storeAccessible.: true,
82 }
83 }