package pki

import (
	"git.paulbsd.com/paulbsd/pki/src/config"
	"github.com/go-acme/lego/v4/providers/dns/ovh"
)

// initProvider initialize DNS provider configuration
func initProvider(cfg *config.Config) (ovhprovider *ovh.DNSProvider, err error) {
	ovhconfig := ovh.NewDefaultConfig()

	ovhconfig.APIEndpoint = cfg.ACME.ProviderOptions["ovhendpoint"]
	ovhconfig.ApplicationKey = cfg.ACME.ProviderOptions["ovhak"]
	ovhconfig.ApplicationSecret = cfg.ACME.ProviderOptions["ovhas"]
	ovhconfig.ConsumerKey = cfg.ACME.ProviderOptions["ovhck"]

	ovhprovider, err = ovh.NewDNSProviderConfig(ovhconfig)

	return
}
