2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-05-16 11:32:00 -04:00
|
|
|
package ssh
|
|
|
|
|
|
|
|
import (
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
|
2022-05-16 11:32:00 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// FromProtoSlice converts a SSH UserKey definition from pubproto to the Go flavor.
|
2022-06-21 11:59:12 -04:00
|
|
|
func FromProtoSlice(input []*initproto.SSHUserKey) []UserKey {
|
2022-05-16 11:32:00 -04:00
|
|
|
if input == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
output := make([]UserKey, 0)
|
|
|
|
|
|
|
|
for _, pair := range input {
|
|
|
|
singlePair := UserKey{
|
|
|
|
Username: pair.Username,
|
|
|
|
PublicKey: pair.PublicKey,
|
|
|
|
}
|
|
|
|
|
|
|
|
output = append(output, singlePair)
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToProtoSlice converts a SSH UserKey definition from Go to pubproto flavor.
|
2022-06-21 11:59:12 -04:00
|
|
|
func ToProtoSlice(input []*UserKey) []*initproto.SSHUserKey {
|
2022-05-16 11:32:00 -04:00
|
|
|
if input == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-06-21 11:59:12 -04:00
|
|
|
output := make([]*initproto.SSHUserKey, 0)
|
2022-05-16 11:32:00 -04:00
|
|
|
for _, pair := range input {
|
2022-06-21 11:59:12 -04:00
|
|
|
singlePair := initproto.SSHUserKey{
|
2022-05-16 11:32:00 -04:00
|
|
|
Username: pair.Username,
|
|
|
|
PublicKey: pair.PublicKey,
|
|
|
|
}
|
|
|
|
|
|
|
|
output = append(output, &singlePair)
|
|
|
|
}
|
|
|
|
|
|
|
|
return output
|
|
|
|
}
|