mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
Linting (#1996)
This commit is contained in:
@ -24,9 +24,7 @@ func generateFeatureMatrix() error {
|
|||||||
func markdownTable(matrix *FeatureMatrix) (string, error) {
|
func markdownTable(matrix *FeatureMatrix) (string, error) {
|
||||||
var tableHeaders []string
|
var tableHeaders []string
|
||||||
tableHeaders = append(tableHeaders, "Provider name")
|
tableHeaders = append(tableHeaders, "Provider name")
|
||||||
for _, featureName := range matrix.Features {
|
tableHeaders = append(tableHeaders, matrix.Features...)
|
||||||
tableHeaders = append(tableHeaders, featureName)
|
|
||||||
}
|
|
||||||
|
|
||||||
var tableData [][]string
|
var tableData [][]string
|
||||||
for _, providerName := range allProviderNames() {
|
for _, providerName := range allProviderNames() {
|
||||||
@ -58,9 +56,9 @@ func featureEmoji(
|
|||||||
return "❔"
|
return "❔"
|
||||||
}
|
}
|
||||||
|
|
||||||
if featureMap[featureName].HasFeature == true {
|
if featureMap[featureName].HasFeature {
|
||||||
return "✅"
|
return "✅"
|
||||||
} else if featureMap[featureName].Unimplemented == true {
|
} else if featureMap[featureName].Unimplemented {
|
||||||
return "❔"
|
return "❔"
|
||||||
}
|
}
|
||||||
return "❌"
|
return "❌"
|
||||||
@ -69,7 +67,7 @@ func featureEmoji(
|
|||||||
func matrixData() *FeatureMatrix {
|
func matrixData() *FeatureMatrix {
|
||||||
const (
|
const (
|
||||||
OfficialSupport = "Official Support"
|
OfficialSupport = "Official Support"
|
||||||
ProviderDnsProvider = "DNS Provider"
|
ProviderDNSProvider = "DNS Provider"
|
||||||
ProviderRegistrar = "Registrar"
|
ProviderRegistrar = "Registrar"
|
||||||
DomainModifierAlias = "ALIAS"
|
DomainModifierAlias = "ALIAS"
|
||||||
DomainModifierDnssec = "AUTODNSSEC"
|
DomainModifierDnssec = "AUTODNSSEC"
|
||||||
@ -91,7 +89,7 @@ func matrixData() *FeatureMatrix {
|
|||||||
Providers: map[string]FeatureMap{},
|
Providers: map[string]FeatureMap{},
|
||||||
Features: []string{
|
Features: []string{
|
||||||
OfficialSupport,
|
OfficialSupport,
|
||||||
ProviderDnsProvider,
|
ProviderDNSProvider,
|
||||||
ProviderRegistrar,
|
ProviderRegistrar,
|
||||||
DomainModifierAlias,
|
DomainModifierAlias,
|
||||||
DomainModifierDnssec,
|
DomainModifierDnssec,
|
||||||
@ -152,7 +150,7 @@ func matrixData() *FeatureMatrix {
|
|||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
featureMap.SetSimple(
|
featureMap.SetSimple(
|
||||||
ProviderDnsProvider,
|
ProviderDNSProvider,
|
||||||
false,
|
false,
|
||||||
func() bool { return providers.DNSProviderTypes[providerName].Initializer != nil },
|
func() bool { return providers.DNSProviderTypes[providerName].Initializer != nil },
|
||||||
)
|
)
|
||||||
|
@ -155,6 +155,7 @@ func generateFunctionTypes() (string, error) {
|
|||||||
return content, nil
|
return content, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function is a struct the stores information about functions.
|
||||||
type Function struct {
|
type Function struct {
|
||||||
Name string
|
Name string
|
||||||
Params []Param
|
Params []Param
|
||||||
@ -164,6 +165,7 @@ type Function struct {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Param is a struct that stores a parameter.
|
||||||
type Param struct {
|
type Param struct {
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
@ -193,9 +195,8 @@ func (f Function) formatParams() string {
|
|||||||
}
|
}
|
||||||
if f.ObjectParam {
|
if f.ObjectParam {
|
||||||
return "opts: { " + strings.Join(params, "; ") + " }"
|
return "opts: { " + strings.Join(params, "; ") + " }"
|
||||||
} else {
|
|
||||||
return strings.Join(params, ", ")
|
|
||||||
}
|
}
|
||||||
|
return strings.Join(params, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f Function) docs() string {
|
func (f Function) docs() string {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "embed"
|
_ "embed" // Required by go:embed
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
versionInfo "github.com/StackExchange/dnscontrol/v3/pkg/version"
|
versionInfo "github.com/StackExchange/dnscontrol/v3/pkg/version"
|
||||||
@ -40,6 +40,7 @@ func (args *TypesArgs) flags() []cli.Flag {
|
|||||||
//go:embed types/dnscontrol.d.ts
|
//go:embed types/dnscontrol.d.ts
|
||||||
var dtsContent string
|
var dtsContent string
|
||||||
|
|
||||||
|
// WriteTypes creates the types file.
|
||||||
func WriteTypes(args TypesArgs) error {
|
func WriteTypes(args TypesArgs) error {
|
||||||
file, err := os.Create(args.DTSFile)
|
file, err := os.Create(args.DTSFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -252,8 +252,6 @@ func filterBy(s []targetConfig, m map[string]*targetConfig) []targetConfig {
|
|||||||
// copy and increment index
|
// copy and increment index
|
||||||
s[i] = x
|
s[i] = x
|
||||||
i++
|
i++
|
||||||
} else {
|
|
||||||
//fmt.Printf("DEBUG: comp %q YES\n", x.compareable)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // Prevent memory leak by erasing truncated values
|
// // Prevent memory leak by erasing truncated values
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package diff2
|
package diff2
|
||||||
|
|
||||||
// Return the highest valid index for an array. The equiv of len(s)-1, but with
|
// highest returns the highest valid index for an array. The equiv of len(s)-1, but with
|
||||||
// less likelihood that you'll commit an off-by-one error.
|
// less likelihood that you'll commit an off-by-one error.
|
||||||
func highest[S ~[]T, T any](s S) int {
|
func highest[S ~[]T, T any](s S) int {
|
||||||
return len(s) - 1
|
return len(s) - 1
|
||||||
|
@ -105,6 +105,8 @@ func (z *ZoneGenData) Less(i, j int) bool {
|
|||||||
return a.String() < b.String()
|
return a.String() < b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LabelLess provides a "Less" function for two labels as needed for sorting. It
|
||||||
|
// sorts labels in prefix order, to make output pretty.
|
||||||
func LabelLess(a, b string) bool {
|
func LabelLess(a, b string) bool {
|
||||||
// Compare two zone labels for the purpose of sorting the RRs in a Zone.
|
// Compare two zone labels for the purpose of sorting the RRs in a Zone.
|
||||||
|
|
||||||
|
@ -208,9 +208,8 @@ func (c *hednsProvider) GetDomainCorrections(dc *models.DomainConfig) ([]*models
|
|||||||
// Fallback to legacy mode if diff2 is not enabled, remove when diff1 is deprecated.
|
// Fallback to legacy mode if diff2 is not enabled, remove when diff1 is deprecated.
|
||||||
if !diff2.EnableDiff2 {
|
if !diff2.EnableDiff2 {
|
||||||
return c.getDiff1DomainCorrections(dc, zoneID, prunedRecords)
|
return c.getDiff1DomainCorrections(dc, zoneID, prunedRecords)
|
||||||
} else {
|
|
||||||
return c.getDiff2DomainCorrections(dc, zoneID, prunedRecords)
|
|
||||||
}
|
}
|
||||||
|
return c.getDiff2DomainCorrections(dc, zoneID, prunedRecords)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *hednsProvider) getDiff1DomainCorrections(dc *models.DomainConfig, zoneID uint64, records models.Records) ([]*models.Correction, error) {
|
func (c *hednsProvider) getDiff1DomainCorrections(dc *models.DomainConfig, zoneID uint64, records models.Records) ([]*models.Correction, error) {
|
||||||
|
Reference in New Issue
Block a user