cert-manager-webhook-sthome/sthome/utils.go

29 lines
743 B
Go

// private repo workaround
// Will use this file and remove same content from main.go when github repo is made public
package sthome
import (
"encoding/json"
"fmt"
extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)
// loadConfig is a small helper function that decodes JSON configuration into
// the typed config struct.
func loadConfig(cfgJSON *extapi.JSON) (localDNSProviderConfig, error) {
cfg := localDNSProviderConfig{}
// handle the 'base case' where no configuration has been provided
if cfgJSON == nil {
return cfg, nil
}
if err := json.Unmarshal(cfgJSON.Raw, &cfg); err != nil {
return cfg, fmt.Errorf("error decoding solver config: %v", err)
}
return cfg, nil
}
// end of private repo workaround