2023-11-17 20:39:00 +03:00
|
|
|
package driver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/Neur0toxine/sshpoke/internal/config"
|
2023-11-18 16:14:39 +03:00
|
|
|
"github.com/Neur0toxine/sshpoke/internal/server/driver/base"
|
2023-11-22 22:21:11 +03:00
|
|
|
"github.com/Neur0toxine/sshpoke/internal/server/driver/nil"
|
2023-11-17 20:39:00 +03:00
|
|
|
"github.com/Neur0toxine/sshpoke/internal/server/driver/plugin"
|
|
|
|
"github.com/Neur0toxine/sshpoke/internal/server/driver/ssh"
|
|
|
|
)
|
|
|
|
|
2023-11-18 16:14:39 +03:00
|
|
|
func New(ctx context.Context, name string, driver config.DriverType, params config.DriverParams) (base.Driver, error) {
|
2023-11-17 20:39:00 +03:00
|
|
|
switch driver {
|
|
|
|
case config.DriverSSH:
|
|
|
|
return ssh.New(ctx, name, params)
|
|
|
|
case config.DriverPlugin:
|
|
|
|
return plugin.New(ctx, name, params)
|
2023-11-22 22:21:11 +03:00
|
|
|
case config.DriverNil:
|
2023-11-17 20:39:00 +03:00
|
|
|
fallthrough
|
|
|
|
default:
|
2023-11-22 22:21:11 +03:00
|
|
|
return nil.New(ctx, name, params)
|
2023-11-17 20:39:00 +03:00
|
|
|
}
|
|
|
|
}
|