Skip to content

Commit

Permalink
refactor(raw) NewFromRaw*() should take a TTL (#3350)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlimoncelli authored Jan 10, 2025
1 parent 313271c commit c9ca2f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions integrationTest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,8 @@ func makeRec2(typ string) *models.RecordConfig {
}

func a(name string, a string) *models.RecordConfig {
rc := makeRec2("A")
if err := models.FromRaw(rc, "**current-domain**", "A", []string{name, a}, nil); err != nil {
rc, err := models.NewFromRawA([]string{name, a}, nil, "**current-domain**", 300)
if err != nil {
panic(err)
}
return rc
Expand Down
4 changes: 2 additions & 2 deletions models/cloudflare_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type CFSINGLEREDIRECT struct {
SRDisplay string `dns:"skip" json:"sr_display,omitempty"` // How is this displayed to the user (SetTarget) for CF_SINGLE_REDIRECT
}

func NewFromRawCFSINGLEREDIRECT(rawfields []string, meta map[string]string, origin string) (*RecordConfig, error) {
rc := &RecordConfig{}
func NewFromRawCFSINGLEREDIRECT(rawfields []string, meta map[string]string, origin string, ttl uint32) (*RecordConfig, error) {
rc := &RecordConfig{TTL: ttl}
if err := PopulateFromRawCFSINGLEREDIRECT(rc, rawfields, meta, origin); err != nil {
return nil, err
}
Expand Down
12 changes: 6 additions & 6 deletions models/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ type A struct {
}

// NewFromRawA creates a new RecordConfig of type A from rawfields, meta, and origin.
func NewFromRawA(rawfields []string, meta map[string]string, origin string) (*RecordConfig, error) {
rc := &RecordConfig{}
func NewFromRawA(rawfields []string, meta map[string]string, origin string, ttl uint32) (*RecordConfig, error) {
rc := &RecordConfig{TTL: ttl}
if err := PopulateFromRawA(rc, rawfields, meta, origin); err != nil {
return nil, err
}
Expand Down Expand Up @@ -136,8 +136,8 @@ type MX struct {
}

// NewFromRawMX creates a new RecordConfig of type MX from rawfields, meta, and origin.
func NewFromRawMX(rawfields []string, meta map[string]string, origin string) (*RecordConfig, error) {
rc := &RecordConfig{}
func NewFromRawMX(rawfields []string, meta map[string]string, origin string, ttl uint32) (*RecordConfig, error) {
rc := &RecordConfig{TTL: ttl}
if err := PopulateFromRawMX(rc, rawfields, meta, origin); err != nil {
return nil, err
}
Expand Down Expand Up @@ -246,8 +246,8 @@ type SRV struct {
}

// NewFromRawSRV creates a new RecordConfig of type SRV from rawfields, meta, and origin.
func NewFromRawSRV(rawfields []string, meta map[string]string, origin string) (*RecordConfig, error) {
rc := &RecordConfig{}
func NewFromRawSRV(rawfields []string, meta map[string]string, origin string, ttl uint32) (*RecordConfig, error) {
rc := &RecordConfig{TTL: ttl}
if err := PopulateFromRawSRV(rc, rawfields, meta, origin); err != nil {
return nil, err
}
Expand Down

0 comments on commit c9ca2f6

Please sign in to comment.