Skip to content

Commit

Permalink
BUILD: Generate OWNERS files (StackExchange#2997)
Browse files Browse the repository at this point in the history
  • Loading branch information
cafferata authored Jul 10, 2024
1 parent cf49ec8 commit 8fa1a8d
Show file tree
Hide file tree
Showing 56 changed files with 311 additions and 80 deletions.
3 changes: 3 additions & 0 deletions build/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ func main() {
if err := generateFeatureMatrix(); err != nil {
log.Fatal(err)
}
if err := generateOwnersFile(); err != nil {
log.Fatal(err)
}
funcs, err := generateFunctionTypes()
if err != nil {
log.Fatal(err)
Expand Down
68 changes: 68 additions & 0 deletions build/generate/ownersFile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package main

import (
"github.com/StackExchange/dnscontrol/v4/providers"
"os"
"sort"
"strings"
)

func generateOwnersFile() error {
maintainers := providers.ProviderMaintainers
sortedProviderNames := getSortedProviderNames(maintainers)

var ownersData strings.Builder
for _, providerName := range sortedProviderNames {
providerMaintainer := maintainers[providerName]
if providerMaintainer == "NEEDS VOLUNTEER" {
ownersData.WriteString("# ")
}
ownersData.WriteString("providers/")
ownersData.WriteString(getProviderDirectory(providerName))
ownersData.WriteString(" ")
ownersData.WriteString(providerMaintainer)
ownersData.WriteString("\n")
}

file, err := os.Create("OWNERS")
if err != nil {
return err
}
defer file.Close()

_, err = file.WriteString(ownersData.String())
if err != nil {
return err
}

return nil
}

func getProviderDirectory(providerName string) string {
// Strip the underscores from the providerName constants
providerDirectory := strings.ToLower(
strings.ReplaceAll(
providerName, "_", "",
),
)

// These providers use a different directory name
if providerDirectory == "cloudflareapi" {
providerDirectory = "cloudflare"
}
if providerDirectory == "dnsoverhttps" {
providerDirectory = "doh"
}

return providerDirectory
}

func getSortedProviderNames(maintainers map[string]string) []string {
providerNameSorted := make([]string, 0, len(maintainers))
for providerNameKey := range maintainers {
providerNameSorted = append(providerNameSorted, providerNameKey)
}
sort.Strings(providerNameSorted)

return providerNameSorted
}
2 changes: 0 additions & 2 deletions documentation/writing-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ an automated way to test for this bug. The manual steps are here in
* Add the provider to the "Providers" list.
* Create `documentation/provider/PROVIDERNAME.md`:
* Use one of the other files in that directory as a base.
* Edit `OWNERS`:
* Add the directory name and your GitHub username.

{% hint style="success" %}
**Need feedback?** Submit a draft PR! It's a great way to get early feedback, ask about fixing
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/fatih/color"
)

//go:generate go run build/generate/generate.go build/generate/featureMatrix.go build/generate/functionTypes.go build/generate/dtsFile.go
//go:generate go run build/generate/generate.go build/generate/featureMatrix.go build/generate/functionTypes.go build/generate/dtsFile.go build/generate/ownersFile.go

// Version management. Goals:
// 1. Someone who just does "go get" has at least some information.
Expand Down
7 changes: 5 additions & 2 deletions providers/akamaiedgedns/akamaiEdgeDnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ type edgeDNSProvider struct {
}

func init() {
const providerName = "AKAMAIEDGEDNS"
const providerMaintainer = "@edglynes"
fns := providers.DspFuncs{
Initializer: newEdgeDNSDSP,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AKAMAIEDGEDNS", fns, features)
providers.RegisterCustomRecordType("AKAMAICDN", "AKAMAIEDGEDNS", "")
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterCustomRecordType("AKAMAICDN", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// DnsServiceProvider
Expand Down
5 changes: 4 additions & 1 deletion providers/autodns/autoDnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ type autoDNSProvider struct {
}

func init() {
const providerName = "AUTODNS"
const providerMaintainer = "@arnoschoon"
fns := providers.DspFuncs{
Initializer: New,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AUTODNS", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// New creates a new API handle.
Expand Down
5 changes: 4 additions & 1 deletion providers/axfrddns/axfrddnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,14 @@ func initAxfrDdns(config map[string]string, providermeta json.RawMessage) (provi
}

func init() {
const providerName = "AXFRDDNS"
const providerMaintainer = "@hnrgrgr"
fns := providers.DspFuncs{
Initializer: initAxfrDdns,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AXFRDDNS", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// Param is used to decode extra parameters sent to provider.
Expand Down
7 changes: 5 additions & 2 deletions providers/azuredns/azureDnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "AZURE_DNS"
const providerMaintainer = "@vatsalyagoel"
fns := providers.DspFuncs{
Initializer: newAzureDNSDsp,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AZURE_DNS", fns, features)
providers.RegisterCustomRecordType("AZURE_ALIAS", "AZURE_DNS", "")
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterCustomRecordType("AZURE_ALIAS", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func (a *azurednsProvider) getExistingZones() ([]*adns.Zone, error) {
Expand Down
7 changes: 5 additions & 2 deletions providers/azureprivatedns/azurePrivateDnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "AZURE_PRIVATE_DNS"
const providerMaintainer = "@matthewmgamble"
fns := providers.DspFuncs{
Initializer: newAzureDNSDsp,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("AZURE_PRIVATE_DNS", fns, features)
providers.RegisterCustomRecordType("AZURE_ALIAS", "AZURE_PRIVATE_DNS", "")
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterCustomRecordType("AZURE_ALIAS", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func (a *azurednsProvider) getExistingZones() ([]*adns.PrivateZone, error) {
Expand Down
5 changes: 4 additions & 1 deletion providers/bind/bindProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,14 @@ func initBind(config map[string]string, providermeta json.RawMessage) (providers
}

func init() {
const providerName = "BIND"
const providerMaintainer = "@tlimoncelli"
fns := providers.DspFuncs{
Initializer: initBind,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("BIND", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// SoaDefaults contains the parts of the default SOA settings.
Expand Down
5 changes: 4 additions & 1 deletion providers/bunnydns/bunnydnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ type bunnydnsProvider struct {
}

func init() {
const providerName = "BUNNY_DNS"
const providerMaintainer = "@ppmathis"
fns := providers.DspFuncs{
Initializer: newBunnydns,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("BUNNY_DNS", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func newBunnydns(settings map[string]string, _ json.RawMessage) (providers.DNSServiceProvider, error) {
Expand Down
11 changes: 7 additions & 4 deletions providers/cloudflare/cloudflareProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "CLOUDFLAREAPI"
const providerMaintainer = "@tresni"
fns := providers.DspFuncs{
Initializer: newCloudflare,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CLOUDFLAREAPI", fns, features)
providers.RegisterCustomRecordType("CF_REDIRECT", "CLOUDFLAREAPI", "")
providers.RegisterCustomRecordType("CF_TEMP_REDIRECT", "CLOUDFLAREAPI", "")
providers.RegisterCustomRecordType("CF_WORKER_ROUTE", "CLOUDFLAREAPI", "")
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterCustomRecordType("CF_REDIRECT", providerName, "")
providers.RegisterCustomRecordType("CF_TEMP_REDIRECT", providerName, "")
providers.RegisterCustomRecordType("CF_WORKER_ROUTE", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// cloudflareProvider is the handle for API calls.
Expand Down
7 changes: 5 additions & 2 deletions providers/cloudns/cloudnsProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,15 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "CLOUDNS"
const providerMaintainer = "@pragmaton"
fns := providers.DspFuncs{
Initializer: NewCloudns,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CLOUDNS", fns, features)
providers.RegisterCustomRecordType("CLOUDNS_WR", "CLOUDNS", "")
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterCustomRecordType("CLOUDNS_WR", providerName, "")
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// GetNameservers returns the nameservers for a domain.
Expand Down
7 changes: 5 additions & 2 deletions providers/cscglobal/cscglobalProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ func newProvider(m map[string]string) (*providerClient, error) {
}

func init() {
providers.RegisterRegistrarType("CSCGLOBAL", newReg)
const providerName = "CSCGLOBAL"
const providerMaintainer = "@mikenz"
providers.RegisterRegistrarType(providerName, newReg)

fns := providers.DspFuncs{
Initializer: newDsp,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("CSCGLOBAL", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}
5 changes: 4 additions & 1 deletion providers/desec/desecProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ var defaultNameServerNames = []string{
}

func init() {
const providerName = "DESEC"
const providerMaintainer = "@D3luxee"
fns := providers.DspFuncs{
Initializer: NewDeSec,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DESEC", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// GetNameservers returns the nameservers for a domain.
Expand Down
5 changes: 4 additions & 1 deletion providers/digitalocean/digitaloceanProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "DIGITALOCEAN"
const providerMaintainer = "@Deraen"
fns := providers.DspFuncs{
Initializer: NewDo,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DIGITALOCEAN", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// EnsureZoneExists creates a zone if it does not exist
Expand Down
7 changes: 5 additions & 2 deletions providers/dnsimple/dnsimpleProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ var features = providers.DocumentationNotes{
}

func init() {
providers.RegisterRegistrarType("DNSIMPLE", newReg)
const providerName = "DNSIMPLE"
const providerMaintainer = "@onlyhavecans"
providers.RegisterRegistrarType(providerName, newReg)
fns := providers.DspFuncs{
Initializer: newDsp,
RecordAuditor: AuditRecords,
}
providers.RegisterDomainServiceProviderType("DNSIMPLE", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

const stateRegistered = "registered"
Expand Down
5 changes: 4 additions & 1 deletion providers/dnsmadeeasy/dnsMadeEasyProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ var features = providers.DocumentationNotes{
}

func init() {
const providerName = "DNSMADEEASY"
const providerMaintainer = "@vojtad"
fns := providers.DspFuncs{
Initializer: New,
RecordAuditor: AuditRecords,
}

providers.RegisterDomainServiceProviderType("DNSMADEEASY", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// New creates a new API handle.
Expand Down
5 changes: 4 additions & 1 deletion providers/doh/dohProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ var features = providers.DocumentationNotes{
}

func init() {
providers.RegisterRegistrarType("DNSOVERHTTPS", newDNSOverHTTPS, features)
const providerName = "DNSOVERHTTPS"
const providerMaintainer = "@mikenz"
providers.RegisterRegistrarType(providerName, newDNSOverHTTPS, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func newDNSOverHTTPS(m map[string]string) (providers.Registrar, error) {
Expand Down
5 changes: 4 additions & 1 deletion providers/domainnameshop/domainnameshopProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ var features = providers.DocumentationNotes{
// Register with the dnscontrol system.
// This establishes the name (all caps), and the function to call to initialize it.
func init() {
const providerName = "DOMAINNAMESHOP"
const providerMaintainer = "@SimenBai"
fns := providers.DspFuncs{
Initializer: newDomainNameShopProvider,
RecordAuditor: AuditRecords,
}

providers.RegisterDomainServiceProviderType("DOMAINNAMESHOP", fns, features)
providers.RegisterDomainServiceProviderType(providerName, fns, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

// newDomainNameShopProvider creates a Domainnameshop specific DNS provider.
Expand Down
5 changes: 4 additions & 1 deletion providers/dynadot/dynadotProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ var features = providers.DocumentationNotes{
}

func init() {
providers.RegisterRegistrarType("DYNADOT", newDynadot, features)
const providerName = "DYNADOT"
const providerMaintainer = "@e-im"
providers.RegisterRegistrarType(providerName, newDynadot, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func newDynadot(m map[string]string) (providers.Registrar, error) {
Expand Down
5 changes: 4 additions & 1 deletion providers/easyname/easynameProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ var features = providers.DocumentationNotes{
}

func init() {
providers.RegisterRegistrarType("EASYNAME", newEasyname, features)
const providerName = "EASYNAME"
const providerMaintainer = "@tresni"
providers.RegisterRegistrarType(providerName, newEasyname, features)
providers.RegisterMaintainer(providerName, providerMaintainer)
}

func newEasyname(m map[string]string) (providers.Registrar, error) {
Expand Down
Loading

0 comments on commit 8fa1a8d

Please sign in to comment.