|
1 | 1 | package models
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "encoding" |
5 |
| - "fmt" |
6 |
| - "net/url" |
7 |
| - |
8 |
| - commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config" |
9 |
| -) |
10 |
| - |
11 |
| -const redacted = "xxxxx" |
12 |
| - |
13 |
| -var ( |
14 |
| - _ fmt.Stringer = (*Secret)(nil) |
15 |
| - _ encoding.TextMarshaler = (*Secret)(nil) |
| 4 | + "github.com/smartcontractkit/chainlink-common/pkg/config" |
16 | 5 | )
|
17 | 6 |
|
18 | 7 | // Secret is a string that formats and encodes redacted, as "xxxxx".
|
19 |
| -// |
20 |
| -// Use Value to get the actual secret. |
21 |
| -type Secret string |
22 |
| - |
23 |
| -func NewSecret(s string) *Secret { return (*Secret)(&s) } |
24 |
| - |
25 |
| -func (s Secret) String() string { return redacted } |
26 |
| - |
27 |
| -func (s Secret) GoString() string { return redacted } |
| 8 | +// Deprecated |
| 9 | +type Secret = config.SecretString |
28 | 10 |
|
29 |
| -func (s Secret) MarshalText() ([]byte, error) { return []byte(redacted), nil } |
30 |
| - |
31 |
| -var ( |
32 |
| - _ fmt.Stringer = (*SecretURL)(nil) |
33 |
| - _ encoding.TextMarshaler = (*SecretURL)(nil) |
34 |
| - _ encoding.TextUnmarshaler = (*SecretURL)(nil) |
35 |
| -) |
| 11 | +// Deprecated |
| 12 | +func NewSecret(s string) *Secret { return config.NewSecretString(s) } |
36 | 13 |
|
37 | 14 | // SecretURL is a URL that formats and encodes redacted, as "xxxxx".
|
38 |
| -type SecretURL commonconfig.URL |
39 |
| - |
40 |
| -func NewSecretURL(u *commonconfig.URL) *SecretURL { return (*SecretURL)(u) } |
41 |
| - |
42 |
| -func MustSecretURL(u string) *SecretURL { return NewSecretURL(commonconfig.MustParseURL(u)) } |
43 |
| - |
44 |
| -func (s *SecretURL) String() string { return redacted } |
45 |
| - |
46 |
| -func (s *SecretURL) GoString() string { return redacted } |
47 |
| - |
48 |
| -func (s *SecretURL) URL() *url.URL { return (*commonconfig.URL)(s).URL() } |
| 15 | +// Deprecated |
| 16 | +type SecretURL = config.SecretURL |
49 | 17 |
|
50 |
| -func (s *SecretURL) MarshalText() ([]byte, error) { return []byte(redacted), nil } |
| 18 | +// Deprecated |
| 19 | +func NewSecretURL(u *config.URL) *config.SecretURL { return (*config.SecretURL)(u) } |
51 | 20 |
|
52 |
| -func (s *SecretURL) UnmarshalText(text []byte) error { |
53 |
| - if err := (*commonconfig.URL)(s).UnmarshalText(text); err != nil { |
54 |
| - //opt: if errors.Is(url.Error), just redact the err.URL field? |
55 |
| - return fmt.Errorf("failed to parse url: %s", redacted) |
56 |
| - } |
57 |
| - return nil |
| 21 | +// Deprecated |
| 22 | +func MustSecretURL(u string) *config.SecretURL { |
| 23 | + return NewSecretURL(config.MustParseURL(u)) |
58 | 24 | }
|
0 commit comments