File tree 3 files changed +30
-2
lines changed
packages/google-cloud-dns
3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -1003,13 +1003,17 @@ Zone.prototype.import = function(localPath, callback) {
1003
1003
}
1004
1004
1005
1005
var parsedZonefile = zonefile . parse ( file ) ;
1006
+ var defaultTTL = parsedZonefile . $ttl ;
1007
+ delete parsedZonefile . $ttl ;
1008
+
1006
1009
var recordTypes = Object . keys ( parsedZonefile ) ;
1007
1010
var recordsToCreate = [ ] ;
1008
1011
1009
1012
recordTypes . forEach ( function ( recordType ) {
1010
1013
var recordTypeSet = arrify ( parsedZonefile [ recordType ] ) ;
1011
1014
1012
1015
recordTypeSet . forEach ( function ( record ) {
1016
+ record . ttl = record . ttl || defaultTTL ;
1013
1017
recordsToCreate . push ( Record . fromZoneRecord_ ( self , recordType , record ) ) ;
1014
1018
} ) ;
1015
1019
} ) ;
Original file line number Diff line number Diff line change
1
+ $TTL 3600
1
2
{DNS_DOMAIN} 21600 IN SPF "v=spf1" "mx:{DNS_DOMAIN}" "-all"
2
- {DNS_DOMAIN} 21600 IN TXT "google-site-verification=xxxxxxxxxxxxYYYYYYXXX"
3
+ {DNS_DOMAIN} IN TXT "google-site-verification=xxxxxxxxxxxxYYYYYYXXX"
Original file line number Diff line number Diff line change @@ -804,9 +804,12 @@ describe('Zone', function() {
804
804
describe ( 'success' , function ( ) {
805
805
var recordType = 'ns' ;
806
806
var parsedZonefile = { } ;
807
- parsedZonefile [ recordType ] = { a : 'b' , c : 'd' } ;
808
807
809
808
beforeEach ( function ( ) {
809
+ parsedZonefile = {
810
+ [ recordType ] : { a : 'b' , c : 'd' } ,
811
+ } ;
812
+
810
813
parseOverride = function ( ) {
811
814
return parsedZonefile ;
812
815
} ;
@@ -834,6 +837,26 @@ describe('Zone', function() {
834
837
835
838
zone . import ( path , done ) ;
836
839
} ) ;
840
+
841
+ it ( 'should use the default ttl' , function ( done ) {
842
+ var defaultTTL = '90' ;
843
+
844
+ parsedZonefile . $ttl = defaultTTL ;
845
+ parsedZonefile [ recordType ] = { } ;
846
+ parsedZonefile . mx = { ttl : '180' } ;
847
+
848
+ zone . addRecords = function ( recordsToCreate ) {
849
+ var record1 = recordsToCreate [ 0 ] . calledWith_ [ 2 ] ;
850
+ assert . strictEqual ( record1 . ttl , defaultTTL ) ;
851
+
852
+ var record2 = recordsToCreate [ 1 ] . calledWith_ [ 2 ] ;
853
+ assert . strictEqual ( record2 . ttl , '180' ) ;
854
+
855
+ done ( ) ;
856
+ } ;
857
+
858
+ zone . import ( path , done ) ;
859
+ } ) ;
837
860
} ) ;
838
861
} ) ;
839
862
You can’t perform that action at this time.
0 commit comments