58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
// private repo workaround
|
|
// Will use this file and remove same content from main.go when github repo is made public
|
|
|
|
package dns
|
|
|
|
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
|
|
}
|
|
|
|
/*
|
|
// quote quotes the provide value
|
|
func quote(value string) string {
|
|
return fmt.Sprintf("\"%s\"", value)
|
|
}
|
|
|
|
// findRRSet searches through te list of rrsets for a matching entry
|
|
// based on type and name.
|
|
func findRRSet(rrsets []sthome.RRset, rrtype sthome.RRType, name string) *sthome.RRset {
|
|
for _, rrset := range rrsets {
|
|
if (rrset.Type != nil && *rrset.Type == sthome.RRTypeTXT) &&
|
|
(rrset.Name != nil && *rrset.Name == name) {
|
|
return &rrset
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
// findRecord locates the record entry with the matching content.
|
|
func findRecord(records []sthome.Record, content string) (int, bool) {
|
|
for indx, record := range records {
|
|
if record.Content != nil && *record.Content == content {
|
|
return indx, true
|
|
}
|
|
}
|
|
|
|
return -1, false
|
|
}
|
|
*/
|
|
// end of private repo workaround
|