constellation/internal/deploy/ssh/proto.go

45 lines
892 B
Go
Raw Normal View History

package ssh
import (
2022-06-21 15:59:12 +00:00
"github.com/edgelesssys/constellation/coordinator/initproto"
)
// FromProtoSlice converts a SSH UserKey definition from pubproto to the Go flavor.
2022-06-21 15:59:12 +00:00
func FromProtoSlice(input []*initproto.SSHUserKey) []UserKey {
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 15:59:12 +00:00
func ToProtoSlice(input []*UserKey) []*initproto.SSHUserKey {
if input == nil {
return nil
}
2022-06-21 15:59:12 +00:00
output := make([]*initproto.SSHUserKey, 0)
for _, pair := range input {
2022-06-21 15:59:12 +00:00
singlePair := initproto.SSHUserKey{
Username: pair.Username,
PublicKey: pair.PublicKey,
}
output = append(output, &singlePair)
}
return output
}