-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Debt: Consolidate mod processing in addRecordSRV/addRecord #157
Comments
I could take on this. I'm thinking of something like: var CNAME = recordBuilder({
type: 'CNAME',
}); which should take care of the (name, target) type. For special cases like SRV a hook could be added var SRV = recordBuilder({
type: 'SRV',
args: [
['name', _.isString], // second argument can be omitted/null if validation is not needed
['priority', _.isNumber],
['weight', _.isNumber],
['port', _.isNumber],
['target', _.isString],
],
transform: function(record, args, modifiers){
// record is {type: 'SRV', ttl:d.defaultTTL, meta:{}}
// with modifiers already applied
// args will be an object for parameters defined
record.name = args.name;
record.srvpriority = args.priority;
record.srvweight = args.srvweight;
record.srvport = args.srvport;
record.target = args.target;
return record;
},
// example of number modifier parsing (eg. in CAA)
modifierNumber: function(record, value){
record.caaflags |= value;
return record;
}
}); Record could implement Is there any use case that I missed? |
I was thinking even simpler. Have addRecord return an object, and SRV just adds some fields to it after it finishes. So addRecord does the common things, runs modifiers, etc. and SRV adds its own fields after. Sometimes the over functional style is good, but others it makes things odd. |
That still retain the special cases of number modifier parsing for CAA/MX. As addRecord will warn on unknown modifier, handling the number modifiers in the CAA function will also trigger the warning. |
* helpers.js: Refactor addRecord to recordBuilder * Fixed failing dns test * helpers.js: Fixed a typo in SRV handling * helpers.js: Move type to top level argument * Removed support for numeric modifiers * helpers.js: Added IMPORT_TRANSFORM ttl argument back
…e#163) * helpers.js: Refactor addRecord to recordBuilder * Fixed failing dns test * helpers.js: Fixed a typo in SRV handling * helpers.js: Move type to top level argument * Removed support for numeric modifiers * helpers.js: Added IMPORT_TRANSFORM ttl argument back
There is a lot of repeated code in addRecordSRV/addRecord. It should be collapsed into a helper function.
The text was updated successfully, but these errors were encountered: