Skip to content

Commit

Permalink
Merge pull request #13 from djotaku/v5-movetov2lib
Browse files Browse the repository at this point in the history
V5.0.0 Moving the version 2 of the API library
  • Loading branch information
djotaku authored Jul 20, 2024
2 parents b8e4663 + 23e3e62 commit d41822c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.21.12

require (
github.com/adrg/xdg v0.5.0
github.com/djotaku/dreamhostapi v1.2.4
github.com/djotaku/dreamhostapi/v2 v2.0.2
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand Down
51 changes: 35 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,25 +1,44 @@
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E=
github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY=
github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/djotaku/dreamhostapi v1.2.2 h1:CCXk39xXvR8Wm9PjOQc/qRW5SqE0kRrN7a6LmFSoe44=
github.com/djotaku/dreamhostapi v1.2.2/go.mod h1:3r0LLlLoEiVsyo6xN5dZX2+unBHJ0GeW9cXhGOuEOSQ=
github.com/djotaku/dreamhostapi v1.2.4 h1:dFFebf9VW8C7C1fcLAf3GJ+GDQZ2ALsi6OqOOtAYMEw=
github.com/djotaku/dreamhostapi v1.2.4/go.mod h1:xNPCrN5gs/cMsO0wwQ+jRwnsztWYwFRsyauowTKAHd8=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.4 h1:8NSJ4rCCU1il/JFtIaXWbjG2COgoti6TJEn3FJ0kY7w=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.4/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.5 h1:CAnSZgnN9Pl2HlVX/eU2cRJL8eerfAR1OInoccmoabQ=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.5/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.6 h1:yazH6yMWlR11EGw7O7nyp+lsKN/fbz/rLlQL0Us7nRw=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.6/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.7 h1:swbLScV4/9giIi00OG0GmfPll9+0yv+QiGaybe3gepw=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.7/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.8 h1:wfOAP9tGVJUgytj6uM8kjH7AN7jbGC4d+oqpinDgMO4=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.8/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.9 h1:+6/u8i0sRlj7RgCrtG6Bisb6Q9r8ieO6NNDxha/f7kk=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.9/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.10 h1:da4RLKTZX3cgDb5KbcDa/jo9eL/Dq+xS9pndrIrYR6E=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.10/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.11 h1:3NnEiCzF6ET9YS2JxtIv5Uzu8Vt2jeGstspkxcM8dfg=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.11/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.12 h1:XrqfF8pIh64cZ+rJpR7TIzLObxBQZZbiE/kr1gJv0SE=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.12/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.13 h1:D7m4q1EGd3EMHXIbPTm9djns6HBFuS7wBa7OPGqSeF8=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.13/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.14 h1:sQG+335uPAG2YxK6R5jZWGwslpdvTsFFMw6HqKxvVKY=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.14/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.15 h1:1A+Pa+2wZswIjunbJ3RSteTebPkPbhd/2St5iVqUJWQ=
github.com/djotaku/dreamhostapi/v2 v2.0.0-alpha.15/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.0 h1:+Z6ZVHC2CvH6qGEWMI1ArXqQ3h8M41eCLU4rGBYt6tk=
github.com/djotaku/dreamhostapi/v2 v2.0.0/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.1 h1:B8UiwikZfG7iNpc0fzGAvTPSoDdm3eqc82jrtDJTtdo=
github.com/djotaku/dreamhostapi/v2 v2.0.1/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/djotaku/dreamhostapi/v2 v2.0.2 h1:ozSjYaKNfpSDIjFr0XaSJ6lO08Z1RfkcLgUyUgpiqaU=
github.com/djotaku/dreamhostapi/v2 v2.0.2/go.mod h1:icgMPv6E+ik5A8NNbH45VePcenvKn3wSjepEroH9wYU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
20 changes: 7 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"

"github.com/adrg/xdg"
"github.com/djotaku/dreamhostapi"
"github.com/djotaku/dreamhostapi/v2"
"gopkg.in/natefinch/lumberjack.v2"
)

Expand Down Expand Up @@ -110,17 +110,10 @@ func main() {
conditionalLog(logMessage, *verbose)
log.Fatal(logMessage)
}
var records dreamhostapi.DnsRecordsJSON
err = json.Unmarshal([]byte(dnsRecords), &records)
if err != nil {
errorString := fmt.Sprintf("Unable to unmashal the JSON from Dreamhost. err is: %n", err)
conditionalLog(errorString, *verbose)
fileLogger.Fatal(errorString)
}

currentDNSValues := make(map[string]string)
for _, record := range records.Data {
currentDNSValues[record["record"]] = record["value"]
for _, record := range dnsRecords.Data {
currentDNSValues[record.Record] = record.Value
}

successMessage := "The following domains successfully updated: "
Expand All @@ -133,11 +126,12 @@ func main() {
logString := fmt.Sprintf("%s has an IP of %s. (If no value listed, this is a new domain.) Will attempt to change to %s (or add in the new domain)", myDomain, currentDNSValues[myDomain], newIPAddress)
fileLogger.Printf(logString)
conditionalLog(logString, *verbose)
addResult, deleteResult, err := dreamhostapi.UpdateDNSRecord(myDomain, currentDNSValues[myDomain], newIPAddress, settings.ApiKey)
updateResults := fmt.Sprintf("addResult: %s, deleteResult: %s", addResult, deleteResult)
addResult, deleteResult, err := dreamhostapi.UpdateDNSRecord(myDomain, currentDNSValues[myDomain], newIPAddress, settings.ApiKey, "")
updateResults := fmt.Sprintf("%s: addResult: %s, deleteResult: %s", myDomain, addResult.Result, deleteResult.Result)
conditionalLog(updateResults, *verbose)
fileLogger.Printf(updateResults)
if err != nil {
logMessage := fmt.Sprintf("An error occurred during DNS update. Add result: %s (did not ocurr if blank). Delete result: %s (did not occur if blank). Error: %s", addResult, deleteResult, err)
logMessage := fmt.Sprintf("An error occurred during DNS update. Add result: %s. Delete result: %s. Error: %s", addResult.Result, deleteResult.Result, err)
conditionalLog(logMessage, *verbose)
log.Println(logMessage)
} else {
Expand Down

0 comments on commit d41822c

Please sign in to comment.