@@ -89,23 +89,16 @@ type Agent struct {
89
89
}
90
90
91
91
type FullEntryCache struct {
92
- aliases map [spiffeID ][]aliasEntry
93
- entries map [spiffeID ][]* types.Entry
92
+ aliases map [string ][]aliasEntry
93
+ entries map [string ][]* types.Entry
94
94
}
95
95
96
96
type selectorSet map [Selector ]struct {}
97
- type seenSet map [spiffeID ]struct {}
97
+ type seenSet map [string ]struct {}
98
98
type stringSet map [string ]struct {}
99
99
100
- type spiffeID struct {
101
- // TrustDomain is the trust domain of the SPIFFE ID.
102
- TrustDomain string
103
- // Path is the path of the SPIFFE ID.
104
- Path string
105
- }
106
-
107
100
type aliasEntry struct {
108
- id spiffeID
101
+ id string
109
102
entry * types.Entry
110
103
}
111
104
@@ -118,14 +111,14 @@ func Build(ctx context.Context, entryIter EntryIterator, agentIter AgentIterator
118
111
}
119
112
bysel := make (map [Selector ][]aliasInfo )
120
113
121
- entries := make (map [spiffeID ][]* types.Entry )
114
+ entries := make (map [string ][]* types.Entry )
122
115
for entryIter .Next (ctx ) {
123
116
entry := entryIter .Entry ()
124
- parentID := spiffeIDFromProto ( entry .ParentId )
125
- if parentID .Path == "/spire/server" {
117
+ parentID := entry .ParentId . Path
118
+ if entry . ParentId .Path == "/spire/server" {
126
119
alias := aliasInfo {
127
120
aliasEntry : aliasEntry {
128
- id : spiffeIDFromProto ( entry .SpiffeId ) ,
121
+ id : entry .SpiffeId . Path ,
129
122
entry : entry ,
130
123
},
131
124
selectors : selectorSetFromProto (entry .Selectors ),
@@ -144,10 +137,10 @@ func Build(ctx context.Context, entryIter EntryIterator, agentIter AgentIterator
144
137
aliasSeen := allocStringSet ()
145
138
defer freeStringSet (aliasSeen )
146
139
147
- aliases := make (map [spiffeID ][]aliasEntry )
140
+ aliases := make (map [string ][]aliasEntry )
148
141
for agentIter .Next (ctx ) {
149
142
agent := agentIter .Agent ()
150
- agentID := spiffeIDFromID ( agent .ID )
143
+ agentID := agent .ID . Path ( )
151
144
agentSelectors := selectorSetFromProto (agent .Selectors )
152
145
// track which aliases we've evaluated so far to make sure we don't
153
146
// add one twice.
@@ -179,7 +172,7 @@ func (c *FullEntryCache) LookupAuthorizedEntries(agentID spiffeid.ID, requestedE
179
172
defer freeSeenSet (seen )
180
173
181
174
foundEntries := make (map [string ]api.ReadOnlyEntry )
182
- c .crawl (spiffeIDFromID ( agentID ), seen , func (entry * types.Entry ) {
175
+ c .crawl (agentID . Path ( ), seen , func (entry * types.Entry ) {
183
176
if _ , ok := requestedEntries [entry .Id ]; ok {
184
177
foundEntries [entry .Id ] = api .NewReadOnlyEntry (entry )
185
178
}
@@ -194,43 +187,29 @@ func (c *FullEntryCache) GetAuthorizedEntries(agentID spiffeid.ID) []api.ReadOnl
194
187
defer freeSeenSet (seen )
195
188
196
189
foundEntries := []api.ReadOnlyEntry {}
197
- c .crawl (spiffeIDFromID ( agentID ), seen , func (entry * types.Entry ) {
190
+ c .crawl (agentID . Path ( ), seen , func (entry * types.Entry ) {
198
191
foundEntries = append (foundEntries , api .NewReadOnlyEntry (entry ))
199
192
})
200
193
201
194
return foundEntries
202
195
}
203
196
204
- func (c * FullEntryCache ) crawl (parentID spiffeID , seen map [spiffeID ]struct {}, visit func (* types.Entry )) {
197
+ func (c * FullEntryCache ) crawl (parentID string , seen map [string ]struct {}, visit func (* types.Entry )) {
205
198
if _ , ok := seen [parentID ]; ok {
206
199
return
207
200
}
208
201
seen [parentID ] = struct {}{}
209
202
210
203
for _ , entry := range c .entries [parentID ] {
211
204
visit (entry )
212
- c .crawl (spiffeIDFromProto ( entry .SpiffeId ) , seen , visit )
205
+ c .crawl (entry .SpiffeId . Path , seen , visit )
213
206
}
214
207
215
208
for _ , alias := range c .aliases [parentID ] {
216
209
c .crawl (alias .id , seen , visit )
217
210
}
218
211
}
219
212
220
- func spiffeIDFromID (id spiffeid.ID ) spiffeID {
221
- return spiffeID {
222
- TrustDomain : id .TrustDomain ().Name (),
223
- Path : id .Path (),
224
- }
225
- }
226
-
227
- func spiffeIDFromProto (id * types.SPIFFEID ) spiffeID {
228
- return spiffeID {
229
- TrustDomain : id .TrustDomain ,
230
- Path : id .Path ,
231
- }
232
- }
233
-
234
213
func selectorSetFromProto (selectors []* types.Selector ) selectorSet {
235
214
set := make (selectorSet , len (selectors ))
236
215
for _ , selector := range selectors {
0 commit comments