@@ -45,7 +45,7 @@ var zoneReloadCmd = &cobra.Command{
4545 os .Exit (1 )
4646 }
4747
48- resp , err := SendCommandNG (api , tdns.CommandPost {
48+ resp , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
4949 Command : "zone" ,
5050 SubCommand : "reload" ,
5151 Zone : dns .Fqdn (tdns .Globals .Zonename ),
@@ -74,11 +74,11 @@ var zoneNsecCmd = &cobra.Command{
7474
7575var zoneSignCmd = & cobra.Command {
7676 Use : "sign" ,
77- Short : "Send an zone sign command to tdnsd" ,
77+ Short : "Send a zone sign command to tdnsd" ,
7878 Run : func (cmd * cobra.Command , args []string ) {
7979 PrepArgs ("childzone" )
8080
81- cr , err := SendCommandNG (api , tdns.CommandPost {
81+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
8282 Command : "zone" ,
8383 SubCommand : "sign-zone" ,
8484 Zone : tdns .Globals .Zonename ,
@@ -99,13 +99,40 @@ var zoneSignCmd = &cobra.Command{
9999 },
100100}
101101
102+ var zoneWriteCmd = & cobra.Command {
103+ Use : "write" ,
104+ Short : "Send a zone write command to tdnsd" ,
105+ Run : func (cmd * cobra.Command , args []string ) {
106+ PrepArgs ("childzone" )
107+
108+ cr , err := SendCommandNG (tdns .Globals .Api , tdns.CommandPost {
109+ Command : "zone" ,
110+ SubCommand : "write-zone" ,
111+ Zone : tdns .Globals .Zonename ,
112+ Force : force ,
113+ })
114+ if err != nil {
115+ fmt .Printf ("Error: %s\n " , err .Error ())
116+ os .Exit (1 )
117+ }
118+ if cr .Error {
119+ fmt .Printf ("Error from tdnsd: %s\n " , cr .ErrorMsg )
120+ os .Exit (1 )
121+ }
122+
123+ if cr .Msg != "" {
124+ fmt .Printf ("%s\n " , cr .Msg )
125+ }
126+ },
127+ }
128+
102129var zoneNsecGenerateCmd = & cobra.Command {
103130 Use : "generate" ,
104131 Short : "Send an NSEC generate command to tdnsd" ,
105132 Run : func (cmd * cobra.Command , args []string ) {
106133 PrepArgs ("childzone" )
107134
108- cr , err := SendCommandNG (api , tdns.CommandPost {
135+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
109136 Command : "zone" ,
110137 SubCommand : "generate-nsec" ,
111138 Zone : tdns .Globals .Zonename ,
@@ -132,7 +159,7 @@ var zoneNsecShowCmd = &cobra.Command{
132159 Run : func (cmd * cobra.Command , args []string ) {
133160 PrepArgs ("childzone" )
134161
135- cr , err := SendCommandNG (api , tdns.CommandPost {
162+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
136163 Command : "zone" ,
137164 SubCommand : "show-nsec-chain" ,
138165 Zone : tdns .Globals .Zonename ,
@@ -163,7 +190,7 @@ var zoneFreezeCmd = &cobra.Command{
163190 Run : func (cmd * cobra.Command , args []string ) {
164191 PrepArgs ("childzone" )
165192
166- cr , err := SendCommandNG (api , tdns.CommandPost {
193+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
167194 Command : "zone" ,
168195 SubCommand : "freeze" ,
169196 Zone : tdns .Globals .Zonename ,
@@ -190,7 +217,7 @@ var zoneThawCmd = &cobra.Command{
190217 Run : func (cmd * cobra.Command , args []string ) {
191218 PrepArgs ("childzone" )
192219
193- cr , err := SendCommandNG (api , tdns.CommandPost {
220+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
194221 Command : "zone" ,
195222 SubCommand : "thaw" ,
196223 Zone : tdns .Globals .Zonename ,
@@ -223,7 +250,7 @@ var zoneListCmd = &cobra.Command{
223250 Short : "Send an zone list command to tdnsd" ,
224251 Run : func (cmd * cobra.Command , args []string ) {
225252
226- cr , err := SendCommandNG (api , tdns.CommandPost {
253+ cr , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
227254 Command : "list-zones" ,
228255 })
229256 if err != nil {
@@ -298,7 +325,7 @@ var zoneSerialBbumpNGCmd = &cobra.Command{
298325 Run : func (cmd * cobra.Command , args []string ) {
299326 PrepArgs ("childzone" )
300327
301- resp , err := SendCommandNG (api , tdns.CommandPost {
328+ resp , err := SendCommandNG (tdns . Globals . Api , tdns.CommandPost {
302329 Command : "bump" ,
303330 Zone : tdns .Globals .Zonename ,
304331 })
@@ -340,7 +367,7 @@ var debugRRsetCmd = &cobra.Command{
340367 os .Exit (1 )
341368 }
342369
343- dr := SendDebug (api , tdns.DebugPost {
370+ dr := SendDebug (tdns . Globals . Api , tdns.DebugPost {
344371 Command : "rrset" ,
345372 Zone : dns .Fqdn (tdns .Globals .Zonename ),
346373 Qname : dns .Fqdn (debugQname ),
@@ -368,7 +395,7 @@ var debugLAVCmd = &cobra.Command{
368395 os .Exit (1 )
369396 }
370397
371- dr := SendDebug (api , tdns.DebugPost {
398+ dr := SendDebug (tdns . Globals . Api , tdns.DebugPost {
372399 Command : "lav" ,
373400 Qname : dns .Fqdn (debugQname ),
374401 Qtype : qtype ,
@@ -383,7 +410,7 @@ var debugShowTACmd = &cobra.Command{
383410 Short : "Request tdnsd to return known trust anchors" ,
384411 Run : func (cmd * cobra.Command , args []string ) {
385412
386- dr := SendDebug (api , tdns.DebugPost {
413+ dr := SendDebug (tdns . Globals . Api , tdns.DebugPost {
387414 Command : "show-ta" ,
388415 Verbose : true ,
389416 })
@@ -417,17 +444,17 @@ func init() {
417444 rootCmd .AddCommand (stopCmd , debugCmd , zoneCmd )
418445
419446 zoneCmd .AddCommand (zoneListCmd , zoneNsecCmd , zoneSignCmd , zoneReloadCmd , zoneSerialBumpCmd , zoneSerialBbumpNGCmd )
420- zoneCmd .AddCommand (zoneFreezeCmd , zoneThawCmd )
447+ zoneCmd .AddCommand (zoneWriteCmd , zoneFreezeCmd , zoneThawCmd )
421448
422449 debugCmd .AddCommand (debugRRsetCmd , debugLAVCmd , debugShowTACmd )
423450 zoneNsecCmd .AddCommand (zoneNsecGenerateCmd , zoneNsecShowCmd )
424451
425452 debugCmd .PersistentFlags ().StringVarP (& debugQname , "qname" , "" , "" , "qname of rrset to examine" )
426453 debugCmd .PersistentFlags ().StringVarP (& debugQtype , "qtype" , "" , "" , "qtype of rrset to examine" )
427- zoneReloadCmd . Flags ().BoolVarP (& force , "force" , "F" , false , "force reloading, ignoring SOA serial " )
454+ zoneCmd . PersistentFlags ().BoolVarP (& force , "force" , "F" , false , "force operation " )
428455
429456 zoneListCmd .Flags ().BoolVarP (& showhdr , "headers" , "H" , false , "Show column headers" )
430- zoneListCmd .Flags ().BoolVarP (& showfile , "file" , "F " , false , "Show zone input file" )
457+ zoneListCmd .Flags ().BoolVarP (& showfile , "file" , "f " , false , "Show zone input file" )
431458 zoneListCmd .Flags ().BoolVarP (& shownotify , "notify" , "N" , false , "Show zone downstream notify addresses" )
432459 zoneListCmd .Flags ().BoolVarP (& showprimary , "primary" , "P" , false , "Show zone primary nameserver" )
433460 // ddnsCmd.PersistentFlags().StringVarP(&Globals.Sig0Keyfile, "keyfile", "k", "", "name of file with private SIG(0) key")
@@ -445,7 +472,7 @@ func SendCommand(cmd, zone string) (string, error) {
445472 bytebuf := new (bytes.Buffer )
446473 json .NewEncoder (bytebuf ).Encode (data )
447474
448- status , buf , err := api .Post ("/command" , bytebuf .Bytes ())
475+ status , buf , err := tdns . Globals . Api .Post ("/command" , bytebuf .Bytes ())
449476 if err != nil {
450477
451478 return "" , fmt .Errorf ("error from api post: %v" , err )
@@ -468,7 +495,7 @@ func SendCommand(cmd, zone string) (string, error) {
468495 return cr .Msg , nil
469496}
470497
471- func SendCommandNG (api * tdns.Api , data tdns.CommandPost ) (tdns.CommandResponse , error ) {
498+ func SendCommandNG (api * tdns.ApiClient , data tdns.CommandPost ) (tdns.CommandResponse , error ) {
472499 var cr tdns.CommandResponse
473500 bytebuf := new (bytes.Buffer )
474501 json .NewEncoder (bytebuf ).Encode (data )
@@ -494,7 +521,7 @@ func SendCommandNG(api *tdns.Api, data tdns.CommandPost) (tdns.CommandResponse,
494521 return cr , nil
495522}
496523
497- func SendDebug (api * tdns.Api , data tdns.DebugPost ) tdns.DebugResponse {
524+ func SendDebug (api * tdns.ApiClient , data tdns.DebugPost ) tdns.DebugResponse {
498525
499526 bytebuf := new (bytes.Buffer )
500527 json .NewEncoder (bytebuf ).Encode (data )
0 commit comments