35 lines
550 B
Go
35 lines
550 B
Go
package ovh
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.maurice.fr/thomas/mailout/pkg/config"
|
|
ovhgo "github.com/ovh/go-ovh/ovh"
|
|
)
|
|
|
|
type OVHProvider struct {
|
|
Client *ovhgo.Client
|
|
}
|
|
|
|
func NewOVHProvider(cfg *config.Config) (*OVHProvider, error) {
|
|
config := cfg.Providers.OVH
|
|
|
|
if config == nil {
|
|
return nil, fmt.Errorf("no ovh configuration specified")
|
|
}
|
|
|
|
c, err := ovhgo.NewClient(
|
|
config.Endpoint,
|
|
config.ApplicationKey,
|
|
config.ApplicationSecret,
|
|
config.ConsumerKey,
|
|
)
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &OVHProvider{
|
|
Client: c,
|
|
}, nil
|
|
}
|