sshpoke/internal/server/driver/util/params.go

21 lines
442 B
Go
Raw Normal View History

2023-11-17 20:39:00 +03:00
package util
import (
"github.com/Neur0toxine/sshpoke/internal/config"
"github.com/mitchellh/mapstructure"
)
type ValidationAvailable interface {
Validate() error
}
func UnmarshalParams(params config.DriverParams, target ValidationAvailable) error {
if err := mapstructure.Decode(params, target); err != nil {
return err
}
if val, canValidate := target.(ValidationAvailable); canValidate {
return val.Validate()
}
return nil
}