1
0
mirror of https://github.com/rancher/os.git synced 2025-07-04 02:26:13 +00:00

Sort SSH keys from metadata so that diff functions will be consistent

This commit is contained in:
Darren Shepherd 2016-01-18 22:15:51 -07:00
parent b7bbad4072
commit 618cd741d8

View File

@ -4,6 +4,7 @@ import (
"io/ioutil"
"os"
"path"
"sort"
"strings"
log "github.com/Sirupsen/logrus"
@ -109,13 +110,23 @@ func mergeMetadata(cc *CloudConfig, md datasource.Metadata) *CloudConfig {
out.Hostname = md.Hostname
}
}
for _, key := range md.SSHPublicKeys {
// Sort SSH keys by key name
keys := []string{}
for k := range md.SSHPublicKeys {
keys = append(keys, k)
}
sort.Sort(sort.StringSlice(keys))
for _, k := range keys {
if !dirty {
out = &(*cc)
dirty = true
}
out.SSHAuthorizedKeys = append(out.SSHAuthorizedKeys, key)
out.SSHAuthorizedKeys = append(out.SSHAuthorizedKeys, md.SSHPublicKeys[k])
}
return out
}