7
7
"time"
8
8
9
9
"get.porter.sh/porter/pkg/cnab"
10
- "get.porter.sh/porter/pkg/encoding"
11
10
"get.porter.sh/porter/pkg/schema"
12
11
"get.porter.sh/porter/pkg/secrets"
13
12
"get.porter.sh/porter/pkg/tracing"
@@ -51,15 +50,16 @@ type CredentialSetSpec struct {
51
50
Labels map [string ]string `json:"labels,omitempty" yaml:"labels,omitempty" toml:"labels,omitempty"`
52
51
53
52
// Credentials is a list of credential resolution strategies.
54
- Credentials * CredentialSourceMap `json:"credentials" yaml:"credentials" toml:"credentials"`
53
+ Credentials CredentialSourceMap `json:"credentials" yaml:"credentials" toml:"credentials"`
55
54
}
56
55
57
- type CredentialSourceMap = encoding.ArrayMap [CredentialSource , NamedCredentialSource ]
58
-
59
- // TODO(generics)
56
+ type CredentialSourceMap = secrets.Map
60
57
type CredentialSource = secrets.ValueMapping
61
58
type NamedCredentialSource = secrets.NamedValueMapping
62
59
60
+ var MakeCredentialSourceMap = secrets .MakeMap
61
+ var NewCredentialSourceMap = secrets .NewMap
62
+
63
63
// CredentialSetStatus contains additional status metadata that has been set by Porter.
64
64
type CredentialSetStatus struct {
65
65
// Created timestamp.
@@ -69,8 +69,6 @@ type CredentialSetStatus struct {
69
69
Modified time.Time `json:"modified" yaml:"modified" toml:"modified"`
70
70
}
71
71
72
- var MakeCredentialSourceMap = encoding.MakeArrayMap [CredentialSource , NamedCredentialSource ]
73
-
74
72
// NewCredentialSet creates a new CredentialSet with the required fields initialized.
75
73
func NewCredentialSet (namespace string , name string ) CredentialSet {
76
74
now := time .Now ()
@@ -80,7 +78,7 @@ func NewCredentialSet(namespace string, name string) CredentialSet {
80
78
SchemaVersion : DefaultCredentialSetSchemaVersion ,
81
79
Name : name ,
82
80
Namespace : namespace ,
83
- Credentials : & CredentialSourceMap {} ,
81
+ Credentials : NewCredentialSourceMap () ,
84
82
},
85
83
Status : CredentialSetStatus {
86
84
Created : now ,
@@ -145,16 +143,17 @@ func (s CredentialSet) SetStrategy(key string, source secrets.Source) {
145
143
}
146
144
147
145
func (s CredentialSet ) Set (key string , source CredentialSource ) {
148
- if s .Credentials == nil {
149
- s .Credentials = & CredentialSourceMap {}
150
- }
151
146
s .Credentials .Set (key , source )
152
147
}
153
148
154
149
func (s CredentialSet ) Get (key string ) (CredentialSource , bool ) {
155
150
return s .Credentials .Get (key )
156
151
}
157
152
153
+ func (s CredentialSet ) Remove (key string ) {
154
+ s .Credentials .Remove (key )
155
+ }
156
+
158
157
func (s CredentialSet ) Len () int {
159
158
return s .Credentials .Len ()
160
159
}
0 commit comments