Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial check-in #3340

Closed
wants to merge 115 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
66ca9c8
first try: A-records non-generated
tlimoncelli Dec 26, 2024
748ba39
m
tlimoncelli Dec 26, 2024
3f0080f
yamlv3
tlimoncelli Dec 27, 2024
cc14956
sort
tlimoncelli Dec 27, 2024
8dcd0ae
fmtjson and sort records
tlimoncelli Dec 27, 2024
2e753eb
dnscontrol fmt
tlimoncelli Dec 27, 2024
cffde5c
updates
tlimoncelli Dec 27, 2024
cb48444
updates
tlimoncelli Dec 27, 2024
84f3184
Merge branch 'tlim_tlim_sortparse' into tlim_rdata3
tlimoncelli Dec 28, 2024
ba11a9e
js_test sorts records
tlimoncelli Dec 28, 2024
433109c
sort 020-complexRequire.json 028-dextend.json
tlimoncelli Dec 28, 2024
830b749
fix sorting bug
tlimoncelli Dec 28, 2024
c5ee3e9
add README
tlimoncelli Dec 28, 2024
667f079
more
tlimoncelli Dec 28, 2024
97d7ab0
more
tlimoncelli Dec 28, 2024
0d5eea8
Merge branch 'tlim_tlim_sortparse' into tlim_rdata3
tlimoncelli Dec 28, 2024
2c1c7ce
Fix 028-dextend.json (remove duplicate record)
tlimoncelli Dec 28, 2024
9b778ae
fix D_EXTEND and ENSURE_ABSENT
tlimoncelli Dec 28, 2024
9fb5371
fix D_EXTEND and ENSURE_ABSENT
tlimoncelli Dec 28, 2024
1a3709c
before i rename CLOUDFLAREAPI_SINGLE_REDIRECT
tlimoncelli Dec 28, 2024
c8a74f3
all unit tests pass
tlimoncelli Dec 28, 2024
7e678d1
order
tlimoncelli Dec 28, 2024
7179a19
code complete
tlimoncelli Dec 28, 2024
055b5e6
remove debug statements
tlimoncelli Dec 28, 2024
7f8d90b
fix DefaultTTL()
tlimoncelli Dec 28, 2024
8db1c76
remove generators
tlimoncelli Dec 28, 2024
a36749f
remove DefaultTTL from 029-dextendsub.js
tlimoncelli Dec 28, 2024
b4f3ea8
unit tests pass
tlimoncelli Dec 29, 2024
f65116d
Merge branch 'main' into tlim_rtype_20_sorttestresults
tlimoncelli Dec 29, 2024
6c36190
Merge branch 'tlim_rtype_20_sorttestresults' into tlim_rtype_60_main
tlimoncelli Dec 29, 2024
dd9ee05
Merge branch 'tlim_rtype_60_main' into tlim_rtype_60_main_onlystrings
tlimoncelli Dec 29, 2024
e5a32a3
wip!
tlimoncelli Dec 29, 2024
f0ec995
wip!
tlimoncelli Dec 29, 2024
fce8df4
attempting to handle legacy
tlimoncelli Jan 1, 2025
d72f408
Merge branch 'main' into tlim_rtype_20_sorttestresults
tlimoncelli Jan 1, 2025
8e5c660
fixup!
tlimoncelli Jan 2, 2025
85c0165
all tests pass
tlimoncelli Jan 3, 2025
8649cfa
Merge branch 'main' into tlim_rtype_20_sorttestresults
tlimoncelli Jan 3, 2025
2335010
Merge branch 'tlim_rtype_20_sorttestresults' into tlim_rtype_60_main_…
tlimoncelli Jan 3, 2025
7ce2af7
rename cfsingleredirect to cloudflaretypes
tlimoncelli Jan 3, 2025
2dce060
rename cfsingleredirect to cloudflaretypes
tlimoncelli Jan 3, 2025
678ad91
fmtjson package-lock.json
tlimoncelli Jan 3, 2025
7aa629d
fix 007-importTransformTTL.js
tlimoncelli Jan 3, 2025
38275a2
fix tests
tlimoncelli Jan 3, 2025
ab6eb6d
complexImports leave as is
tlimoncelli Jan 3, 2025
05f27ef
Merge branch 'tlim_rtype_20_sorttestresults' into tlim_rtype_60_main_…
tlimoncelli Jan 3, 2025
14cad23
parse_tests/006-transforms.json
tlimoncelli Jan 3, 2025
28cee18
Merge branch 'tlim_rtype_20_sorttestresults' into tlim_rtype_60_main_…
tlimoncelli Jan 3, 2025
37afaf8
format helers.js
tlimoncelli Jan 3, 2025
6cea984
Merge branch 'main' into tlim_rtype_61_main
tlimoncelli Jan 3, 2025
6188a63
CF works. Trying to get parse_tests working
tlimoncelli Jan 3, 2025
78dda9c
fix parse_test/001
tlimoncelli Jan 4, 2025
5c21801
Merge branch 'main' into tlim_rtype_61_main_cf
tlimoncelli Jan 4, 2025
20666d2
fix parse_tests with A records
tlimoncelli Jan 4, 2025
5cce744
Fix MX/SRV: models/t_*.go files and parse_tests
tlimoncelli Jan 4, 2025
4e5e901
ParseLabel3() should handle origin="" for legacy
tlimoncelli Jan 4, 2025
db1c268
parse_tests: Add more MX situations
tlimoncelli Jan 4, 2025
b45500e
parse_tests: Add more MX situations
tlimoncelli Jan 4, 2025
5f48a4a
Fix PopulateFromString
tlimoncelli Jan 4, 2025
c27a174
fix PopulateFromStringFunc
tlimoncelli Jan 4, 2025
917e39d
t_parse.go: Collapse PopulateFromString and PopulateFromStringFunc
tlimoncelli Jan 4, 2025
1330bac
fix integration tests. fix . check
tlimoncelli Jan 4, 2025
8aaf6de
fix comment
tlimoncelli Jan 4, 2025
e8474ed
wip!
tlimoncelli Jan 4, 2025
7e614bc
linting
tlimoncelli Jan 4, 2025
00be7be
CHORE: linting
tlimoncelli Jan 5, 2025
00eb12a
remaining warnings
tlimoncelli Jan 5, 2025
17db2f8
remove one panic()
tlimoncelli Jan 5, 2025
057491a
use --fix
tlimoncelli Jan 5, 2025
627b3a0
Merge branch 'tlim_linting202501' into tlim_rtype_61_main_cf_linted
tlimoncelli Jan 5, 2025
bb77751
fix ownership
tlimoncelli Jan 5, 2025
044cd99
fix ownership
tlimoncelli Jan 5, 2025
6bee25b
fix Printf
tlimoncelli Jan 5, 2025
ced0bbb
unlint pkg/spflib/flatten_test.go
tlimoncelli Jan 5, 2025
769b7c2
Merge branch 'tlim_linting202501' into tlim_rtype_61_main_cf_linted
tlimoncelli Jan 5, 2025
1e4c42c
m
tlimoncelli Jan 5, 2025
d76aee8
fix Less for Rtypes
tlimoncelli Jan 6, 2025
202e840
all but CF tranform
tlimoncelli Jan 6, 2025
6987eda
more tests. remove .SubDomain after use
tlimoncelli Jan 6, 2025
38f136f
fix NameFQDN bug
tlimoncelli Jan 6, 2025
a23639a
m
tlimoncelli Jan 6, 2025
d6c4034
fix manyA()
tlimoncelli Jan 6, 2025
3962fde
wip!
tlimoncelli Jan 6, 2025
0b026b6
Merge branch 'main' into tlim_linting202501
tlimoncelli Jan 6, 2025
44c779b
Remove gcore label stuff per @xddxdd
tlimoncelli Jan 6, 2025
23a8c0b
lint reserved words
tlimoncelli Jan 6, 2025
4d1e469
empty: use assert.Empty (testifylint)
tlimoncelli Jan 6, 2025
bab78ac
Merge branch 'main' into tlim_rtype_61_main_cf_linted
tlimoncelli Jan 7, 2025
0dc7e3b
Merge branch 'main' into tlim_rtype_61_main
tlimoncelli Jan 7, 2025
43e7056
Merge branch 'tlim_rtype_61_main' into tlim_rtype_61_main_cf
tlimoncelli Jan 7, 2025
e5882ae
broken tests
tlimoncelli Jan 7, 2025
71e246b
fmt
tlimoncelli Jan 7, 2025
6a0c899
m
tlimoncelli Jan 7, 2025
999d6df
wip!
tlimoncelli Jan 7, 2025
9151385
Merge branch 'main' into tlim_linting202501
tlimoncelli Jan 7, 2025
2d8bdbd
does this fix DO?
tlimoncelli Jan 7, 2025
416979a
fix TestParseLabel3
tlimoncelli Jan 7, 2025
4ba4324
remove debug statements
tlimoncelli Jan 7, 2025
e1942e3
Do not call rc.SetLabel3 with origin==""
tlimoncelli Jan 7, 2025
384357f
remove debugs
tlimoncelli Jan 7, 2025
3563102
Merge branch 'main' into tlim_rtype_61_main
tlimoncelli Jan 7, 2025
c335fe2
Merge branch 'tlim_rtype_61_main' into tlim_rtype_61_main_cf
tlimoncelli Jan 7, 2025
3d45469
Merge branch 'tlim_rtype_61_main_cf' into tlim_rtype_61_main_cf_compat
tlimoncelli Jan 7, 2025
babdd09
Merge branch 'tlim_rtype_61_main_cf_compat' into tlim_rtype_61_main_c…
tlimoncelli Jan 7, 2025
78f8baf
renames
tlimoncelli Jan 7, 2025
3167633
cleanups for cloudflare_*.go
tlimoncelli Jan 7, 2025
1b486c1
Merge branch 'main' into tlim_linting202501
tlimoncelli Jan 8, 2025
85c36b7
Merge branch 'main' into tlim_linting202501
tlimoncelli Jan 8, 2025
b2176a2
fix clear() and min predefined
tlimoncelli Jan 8, 2025
2e64b66
Merge branch 'main' into tlim_rtype_61_main
tlimoncelli Jan 8, 2025
4cf95cf
Merge branch 'tlim_rtype_61_main' into tlim_rtype_61_main_cf
tlimoncelli Jan 8, 2025
f1bb94e
Merge branch 'tlim_rtype_61_main_cf' into tlim_rtype_61_main_cf_compat
tlimoncelli Jan 8, 2025
f75d97a
Merge branch 'tlim_rtype_61_main_cf_compat' into tlim_rtype_61_main_c…
tlimoncelli Jan 8, 2025
b1a591f
Merge branch 'tlim_linting202501' into tlim_rtype_61_main_cf_linted
tlimoncelli Jan 8, 2025
6af796f
remove debug statement
tlimoncelli Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build/generate/dtsFile.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,5 @@ func generateDTSFile(funcs string) error {
fileContent += strings.TrimRight(line, " \t") + "\n"
}
fileContent = strings.TrimRight(fileContent, "\n")
os.WriteFile(join("commands", "types", "dnscontrol.d.ts"), []byte(fileContent+"\n"), 0644)
return nil
return os.WriteFile(join("commands", "types", "dnscontrol.d.ts"), []byte(fileContent+"\n"), 0o644)
}
7 changes: 3 additions & 4 deletions build/generate/featureMatrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
func generateFeatureMatrix() error {
matrix := matrixData()
markdownTable, err := markdownTable(matrix)

if err != nil {
return err
}
Expand Down Expand Up @@ -45,7 +44,7 @@ func markdownTable(matrix *FeatureMatrix) (string, error) {
tableData = append(tableData, tableDataRow)
}

var markdownTable, err = markdown.NewTableFormatterBuilder().
markdownTable, err := markdown.NewTableFormatterBuilder().
Build(tableHeaders...).
Format(tableData)
if err != nil {
Expand Down Expand Up @@ -123,7 +122,7 @@ func matrixData() *FeatureMatrix {
DomainModifierDnskey,
DualHost,
CreateDomains,
//NoPurge,
// NoPurge,
GetZones,
},
}
Expand Down Expand Up @@ -346,7 +345,7 @@ func replaceInlineContent(
contentBytes = []byte(content)
contentBytes = append(contentBytes[:start], append(newContentBytes, contentBytes[end+len(endMarker):]...)...)

err = os.WriteFile(file, contentBytes, 0644)
err = os.WriteFile(file, contentBytes, 0o644)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions build/generate/functionTypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func readDocFile(fPath string) (map[string]interface{}, string, error) {
func parseFrontMatter(content string) (map[string]interface{}, string, error) {
delimiterIndices := delimiterRegex.FindAllStringIndex(content, 2)
if len(delimiterIndices) < 1 {
return nil, "", fmt.Errorf("failed to parse file. Remove it and try again")
return nil, "", errors.New("failed to parse file. Remove it and try again")
}
startIndex := delimiterIndices[0][0]
endIndex := delimiterIndices[1][0]
Expand Down Expand Up @@ -126,7 +126,6 @@ func generateFunctionTypes() (string, error) {
if err != nil {
println("Error parsing front matter in", fPath, "error: ", err.Error())
continue

}
if frontMatter["ts_ignore"] == true {
continue
Expand Down
3 changes: 2 additions & 1 deletion build/generate/ownersFile.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

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

"github.com/StackExchange/dnscontrol/v4/providers"
)

func generateOwnersFile() error {
Expand Down
5 changes: 2 additions & 3 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
"github.com/StackExchange/dnscontrol/v4/pkg/js"
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
"github.com/urfave/cli/v2"

"github.com/fatih/color"
"github.com/urfave/cli/v2"
)

// categories of commands
Expand Down Expand Up @@ -165,7 +164,7 @@ func GetDNSConfig(args GetDNSConfigArgs) (*models.DNSConfig, error) {
// convenient access patterns. Does everything we need to prepare for the validation phase, but
// cannot do anything that requires the credentials file yet.
func preloadProviders(cfg *models.DNSConfig) (*models.DNSConfig, error) {
//build name to type maps
// build name to type maps
cfg.RegistrarsByName = map[string]*models.RegistrarConfig{}
cfg.DNSProvidersByName = map[string]*models.DNSProviderConfig{}
for _, reg := range cfg.Registrars {
Expand Down
4 changes: 3 additions & 1 deletion commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ func shellCompletionCommand() *cli.Command {
BashComplete: func(ctx *cli.Context) {
for _, shell := range supportedShells {
if strings.HasPrefix(shell, ctx.Args().First()) {
ctx.App.Writer.Write([]byte(shell + "\n"))
if _, err := ctx.App.Writer.Write([]byte(shell + "\n")); err != nil {
panic(err)
}
}
}
},
Expand Down
9 changes: 4 additions & 5 deletions commands/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package commands
import (
"bytes"
"fmt"
"slices"
"strings"
"testing"
"text/template"

"github.com/google/go-cmp/cmp"

"github.com/urfave/cli/v2"
"golang.org/x/exp/slices"
)

type shellTestDataItem struct {
Expand Down Expand Up @@ -99,7 +98,7 @@ func TestShellCompletionCommand(t *testing.T) {
t.Fatal("expected error, but didn't get one")
}

want := fmt.Sprintf("unknown shell: %s", invalidShellTestDataItem.shellName)
want := "unknown shell: " + invalidShellTestDataItem.shellName
got := strings.TrimSpace(appErrWriterBuffer.String())
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -153,7 +152,7 @@ func TestShellCompletionCommand(t *testing.T) {
t.Fatal("expected error, but didn't get one")
}

want := fmt.Sprintf("unknown shell: %s", invalidShellTestDataItem.shellPath)
want := "unknown shell: " + invalidShellTestDataItem.shellPath
got := strings.TrimSpace(appErrWriterBuffer.String())
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("mismatch (-want +got):\n%s", diff)
Expand Down Expand Up @@ -230,7 +229,7 @@ func testHelperGetShellsAndCompletionScripts() ([]shellTestDataItem, error) {
shellsAndValues,
shellTestDataItem{
shellName: shellName,
shellPath: fmt.Sprintf("/bin/%s", shellName),
shellPath: "/bin/" + shellName,
completionScriptTemplate: t,
},
)
Expand Down
2 changes: 1 addition & 1 deletion commands/fmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func FmtFile(args FmtArgs) error {
if args.OutputFile == "" {
fmt.Print(beautified)
} else {
if err := os.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil {
if err := os.WriteFile(args.OutputFile, []byte(beautified), 0o744); err != nil {
return err
}
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
Expand Down
11 changes: 6 additions & 5 deletions commands/getCerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"encoding/json"
"errors"
"fmt"
"os"
"regexp"
Expand Down Expand Up @@ -129,10 +130,10 @@ func GetCerts(args GetCertsArgs) error {
fmt.Println(args.JSFile)
// check agree flag
if !args.AgreeTOS {
return fmt.Errorf("you must agree to the Let's Encrypt Terms of Service by using -agreeTOS")
return errors.New("you must agree to the Let's Encrypt Terms of Service by using -agreeTOS")
}
if args.Email == "" {
return fmt.Errorf("must provide email to use for Let's Encrypt registration")
return errors.New("must provide email to use for Let's Encrypt registration")
}

// load dns config
Expand All @@ -142,7 +143,7 @@ func GetCerts(args GetCertsArgs) error {
}
errs := normalize.ValidateAndNormalizeConfig(cfg)
if PrintValidationErrors(errs) {
return fmt.Errorf("exiting due to validation errors")
return errors.New("exiting due to validation errors")
}
providerConfigs, err := credsfile.LoadProviderConfigs(args.CredsFile)
if err != nil {
Expand Down Expand Up @@ -170,7 +171,7 @@ func GetCerts(args GetCertsArgs) error {
return err
}
if len(certList) == 0 {
return fmt.Errorf("must provide at least one certificate to issue in cert configuration")
return errors.New("must provide at least one certificate to issue in cert configuration")
}
if err = validateCertificateList(certList, cfg); err != nil {
return err
Expand Down Expand Up @@ -207,7 +208,7 @@ func GetCerts(args GetCertsArgs) error {
if manyerr == nil {
manyerr = err
} else {
manyerr = fmt.Errorf("%w; %v", manyerr, err)
manyerr = fmt.Errorf("%w; %w", manyerr, err)
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions commands/getZones.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var _ = cmd(catUtils, func() *cli.Command {
args.CredName = ctx.Args().Get(0)
arg1 := ctx.Args().Get(1)
args.ProviderName = arg1
// In v4.0, skip the first args.ZoneNames if it it equals "-".
// In v4.0, skip the first args.ZoneNames if it equals "-".
args.ZoneNames = ctx.Args().Slice()[2:]

if arg1 != "" && arg1 != "-" {
Expand Down Expand Up @@ -212,7 +212,6 @@ func GetZone(args GetZoneArgs) error {
dspVariableName := "DSP_" + strings.ToUpper(args.CredName)

if args.OutputFormat == "js" || args.OutputFormat == "djs" {

if args.ProviderName == "-" {
fmt.Fprintf(w, `var %s = NewDnsProvider("%s");`+"\n",
dspVariableName, args.CredName)
Expand All @@ -229,10 +228,11 @@ func GetZone(args GetZoneArgs) error {

z := prettyzone.PrettySort(recs, zoneName, 0, nil)
switch args.OutputFormat {

case "zone":
fmt.Fprintf(w, "$ORIGIN %s.\n", zoneName)
prettyzone.WriteZoneFileRC(w, z.Records, zoneName, uint32(args.DefaultTTL), nil)
if err := prettyzone.WriteZoneFileRC(w, z.Records, zoneName, uint32(args.DefaultTTL), nil); err != nil {
return err
}
fmt.Fprintln(w)

case "js", "djs":
Expand Down Expand Up @@ -281,7 +281,6 @@ func GetZone(args GetZoneArgs) error {

case "tsv":
for _, rec := range recs {

cfproxy := ""
if cp, ok := rec.Metadata["cloudflare_proxy"]; ok {
if cp == "true" {
Expand Down Expand Up @@ -315,7 +314,6 @@ func jsonQuoted(i string) string {
}

func formatDsl(rec *models.RecordConfig, defaultTTL uint32) string {

target := rec.GetTargetCombined()

ttl := uint32(0)
Expand Down
4 changes: 2 additions & 2 deletions commands/gz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func testFormat(t *testing.T, domain, format string) {
expectedFilename := fmt.Sprintf("test_data/%s.zone.%s", domain, format)
outputFiletmpl := fmt.Sprintf("%s.zone.%s.*.txt", domain, format)

outfile, err := os.CreateTemp("", outputFiletmpl)
outfile, err := os.CreateTemp(t.TempDir(), outputFiletmpl)
if err != nil {
log.Fatal(fmt.Errorf("gz can't TempFile %q: %w", outputFiletmpl, err))
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func testFormat(t *testing.T, domain, format string) {

if w, g := string(want), string(got); w != g {
// If the test fails, output a file showing "got"
err = os.WriteFile(expectedFilename+".ACTUAL", got, 0644)
err = os.WriteFile(expectedFilename+".ACTUAL", got, 0o644)
if err != nil {
log.Fatal(err)
}
Expand Down
Loading
Loading