mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
correctly remove duplicated secrets and ssh keys
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@ -27,7 +27,7 @@ func (s Secrets) Normalize() Secrets {
|
||||
if len(s) == 0 {
|
||||
return nil
|
||||
}
|
||||
return removeDupes(s)
|
||||
return removeSecretDupes(s)
|
||||
}
|
||||
|
||||
func (s Secrets) ToPB() []*controllerapi.Secret {
|
||||
@ -155,3 +155,17 @@ func parseSecret(value string) (*controllerapi.Secret, error) {
|
||||
}
|
||||
return s.ToPB(), nil
|
||||
}
|
||||
|
||||
func removeSecretDupes(s []*Secret) []*Secret {
|
||||
var res []*Secret
|
||||
m := map[string]int{}
|
||||
for _, sec := range s {
|
||||
if i, ok := m[sec.ID]; ok {
|
||||
res[i] = sec
|
||||
} else {
|
||||
m[sec.ID] = len(res)
|
||||
res = append(res, sec)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
Reference in New Issue
Block a user