mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-04-05 08:54:09 -04:00
chore(provider): do not re-check the owner is not empty
This commit is contained in:
@@ -18,7 +18,6 @@ var (
|
||||
ErrEmailNotValid = errors.New("email address is not valid")
|
||||
ErrGCPProjectNotSet = errors.New("GCP project is not set")
|
||||
ErrDomainNotValid = errors.New("domain is not valid")
|
||||
ErrOwnerNotSet = errors.New("owner is not set")
|
||||
ErrOwnerWildcard = errors.New(`owner cannot be "*"`)
|
||||
ErrIPv4KeyNotSet = errors.New("IPv4 key is not set")
|
||||
ErrIPv6KeyNotSet = errors.New("IPv6 key is not set")
|
||||
|
||||
@@ -37,7 +37,7 @@ func New(data json.RawMessage, domain, owner string,
|
||||
return nil, fmt.Errorf("json decoding provider specific settings: %w", err)
|
||||
}
|
||||
|
||||
err = validateSettings(domain, owner,
|
||||
err = validateSettings(domain,
|
||||
providerSpecificSettings.Username, providerSpecificSettings.Password)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("validating provider specific settings: %w", err)
|
||||
@@ -53,15 +53,13 @@ func New(data json.RawMessage, domain, owner string,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateSettings(domain, owner, username, password string) (err error) {
|
||||
func validateSettings(domain, username, password string) (err error) {
|
||||
err = utils.CheckDomain(domain)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %w", errors.ErrDomainNotValid, err)
|
||||
}
|
||||
|
||||
switch {
|
||||
case owner == "":
|
||||
return fmt.Errorf("%w", errors.ErrOwnerNotSet)
|
||||
case username == "":
|
||||
return fmt.Errorf("%w", errors.ErrUsernameNotSet)
|
||||
case password == "":
|
||||
|
||||
@@ -61,8 +61,6 @@ func validateSettings(domain, owner, token, secret string) (err error) {
|
||||
}
|
||||
|
||||
switch {
|
||||
case owner == "":
|
||||
return fmt.Errorf("%w", errors.ErrOwnerNotSet)
|
||||
case owner == "*":
|
||||
return fmt.Errorf("%w", errors.ErrOwnerWildcard)
|
||||
case token == "":
|
||||
|
||||
@@ -42,7 +42,7 @@ func New(data json.RawMessage, domain, owner string,
|
||||
return nil, fmt.Errorf("json decoding provider specific settings: %w", err)
|
||||
}
|
||||
|
||||
err = validateSettings(domain, owner,
|
||||
err = validateSettings(domain,
|
||||
providerSpecificSettings.Username, providerSpecificSettings.Password)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("validating provider specific settings: %w", err)
|
||||
@@ -58,7 +58,7 @@ func New(data json.RawMessage, domain, owner string,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateSettings(domain, owner, username, password string) (err error) {
|
||||
func validateSettings(domain, username, password string) (err error) {
|
||||
// TODO: update this switch to be as restrictive as possible
|
||||
// to fail early for the user. Use errors already defined
|
||||
// in the internal/provider/errors package, or add your own
|
||||
@@ -70,8 +70,6 @@ func validateSettings(domain, owner, username, password string) (err error) {
|
||||
}
|
||||
|
||||
switch {
|
||||
case owner == "":
|
||||
return fmt.Errorf("%w", errors.ErrOwnerNotSet)
|
||||
// TODO: does the provider support wildcard owners? If not, disallow * owners
|
||||
// case owner == "*":
|
||||
// return fmt.Errorf("%w", errors.ErrOwnerWildcard)
|
||||
|
||||
@@ -49,7 +49,7 @@ func New(data json.RawMessage, domain, owner string,
|
||||
ttl = *providerSpecificSettings.TTL
|
||||
}
|
||||
|
||||
err = validateSettings(domain, owner, providerSpecificSettings.AccessKey,
|
||||
err = validateSettings(domain, providerSpecificSettings.AccessKey,
|
||||
providerSpecificSettings.SecretKey, providerSpecificSettings.ZoneID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("validating provider specific settings: %w", err)
|
||||
@@ -79,15 +79,13 @@ func New(data json.RawMessage, domain, owner string,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateSettings(domain, owner, accessKey, secretKey, zoneID string) (err error) {
|
||||
func validateSettings(domain, accessKey, secretKey, zoneID string) (err error) {
|
||||
err = utils.CheckDomain(domain)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %w", errors.ErrDomainNotValid, err)
|
||||
}
|
||||
|
||||
switch {
|
||||
case owner == "":
|
||||
return fmt.Errorf("%w", errors.ErrOwnerNotSet)
|
||||
case accessKey == "":
|
||||
return fmt.Errorf("%w", errors.ErrAccessKeyNotSet)
|
||||
case secretKey == "":
|
||||
|
||||
Reference in New Issue
Block a user