This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add domainFilter to dns provider config
Add option to add CONFIG to dns provider secret
- Loading branch information
Showing
5 changed files
with
131 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package dns | ||
|
||
import "strings" | ||
|
||
// ZoneIDFilter holds a list of zone ids to filter by | ||
type ZoneIDFilter struct { | ||
ZoneIDs []string | ||
} | ||
|
||
// NewZoneIDFilter returns a new ZoneIDFilter given a list of zone ids | ||
func NewZoneIDFilter(zoneIDs []string) ZoneIDFilter { | ||
return ZoneIDFilter{zoneIDs} | ||
} | ||
|
||
// Match checks whether a zone matches one of the provided zone ids | ||
func (f ZoneIDFilter) Match(zoneID string) bool { | ||
// An empty filter includes all zones. | ||
if len(f.ZoneIDs) == 0 { | ||
return true | ||
} | ||
|
||
for _, id := range f.ZoneIDs { | ||
if strings.HasSuffix(zoneID, id) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
// IsConfigured returns true if DomainFilter is configured, false otherwise | ||
func (f ZoneIDFilter) IsConfigured() bool { | ||
if len(f.ZoneIDs) == 1 { | ||
return f.ZoneIDs[0] != "" | ||
} | ||
return len(f.ZoneIDs) > 0 | ||
} | ||
|
||
// DomainFilter holds a list of domains to filter by | ||
type DomainFilter struct { | ||
DomainNames []string | ||
} | ||
|
||
// NewDomainFilter returns a new DomainFilter given a list of domain names | ||
func NewDomainFilter(domainNames []string) DomainFilter { | ||
return DomainFilter{domainNames} | ||
} | ||
|
||
// Match checks whether a zone matches one of the provided domains | ||
func (f DomainFilter) Match(domainName string) bool { | ||
// An empty filter includes all zones. | ||
if len(f.DomainNames) == 0 { | ||
return true | ||
} | ||
|
||
for _, id := range f.DomainNames { | ||
if strings.HasSuffix(domainName, id) { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
// IsConfigured returns true if DomainFilter is configured, false otherwise | ||
func (f DomainFilter) IsConfigured() bool { | ||
if len(f.DomainNames) == 1 { | ||
return f.DomainNames[0] != "" | ||
} | ||
return len(f.DomainNames) > 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.