mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +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:
@ -28,7 +28,7 @@ func (s SSHKeys) Normalize() SSHKeys {
|
||||
if len(s) == 0 {
|
||||
return nil
|
||||
}
|
||||
return removeDupes(s)
|
||||
return removeSSHDupes(s)
|
||||
}
|
||||
|
||||
func (s SSHKeys) ToPB() []*controllerapi.SSH {
|
||||
@ -131,3 +131,17 @@ func IsGitSSH(repo string) bool {
|
||||
}
|
||||
return url.Scheme == gitutil.SSHProtocol
|
||||
}
|
||||
|
||||
func removeSSHDupes(s []*SSH) []*SSH {
|
||||
var res []*SSH
|
||||
m := map[string]int{}
|
||||
for _, ssh := range s {
|
||||
if i, ok := m[ssh.ID]; ok {
|
||||
res[i] = ssh
|
||||
} else {
|
||||
m[ssh.ID] = len(res)
|
||||
res = append(res, ssh)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
Reference in New Issue
Block a user