constellation/internal/deploy/ssh/proto.go

51 lines
979 B
Go
Raw Normal View History

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package ssh
import (
2022-09-21 07:47:57 -04:00
"github.com/edgelesssys/constellation/v2/bootstrapper/initproto"
)
// 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 {
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 {
if input == nil {
return nil
}
2022-06-21 11:59:12 -04:00
output := make([]*initproto.SSHUserKey, 0)
for _, pair := range input {
2022-06-21 11:59:12 -04:00
singlePair := initproto.SSHUserKey{
Username: pair.Username,
PublicKey: pair.PublicKey,
}
output = append(output, &singlePair)
}
return output
}