ADD comment from cli to add to req
This commit is contained in:
parent
186739b902
commit
4a0d499f2a
@ -21,6 +21,7 @@ var (
|
||||
helpMsg string
|
||||
provider string
|
||||
rID string
|
||||
comment string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -40,7 +41,8 @@ func init() {
|
||||
flag.StringVar(&provider, "pv", "cf", "Dns records provider")
|
||||
flag.StringVar(&rID, "rid", "", "Select record id (shorthand)")
|
||||
flag.StringVar(&rID, "record-id", "", "Select record id")
|
||||
|
||||
flag.StringVar(&comment, "comment", "", "comment")
|
||||
flag.StringVar(&comment, "c", "", "comment operation")
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -89,7 +91,7 @@ func main() {
|
||||
fmt.Println(zid)
|
||||
panic(err)
|
||||
}
|
||||
app.Operation(operation, name, tipe, ip, proxied, rID)
|
||||
app.Operation(operation, name, tipe, ip, rID, comment, proxied)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +129,7 @@ func (app *Application) Create(rBody cf.RequestBody) (res *cf.DetailsResult, err
|
||||
|
||||
// Overwrite
|
||||
func (app *Application) Overwrite(re *cf.Result, rBody *cf.RequestBody) {
|
||||
rBody.Comment = "Overwrite from app cli tool"
|
||||
rBody.Comment = rBody.Comment + " Overwrite from app cli tool"
|
||||
res, err := app.client.Overwrite(*rBody, re.ID)
|
||||
if err != nil {
|
||||
app.log.Error("[Overwrite]", "error", err)
|
||||
@ -150,7 +150,7 @@ func (app Application) Delete(re *cf.Result) {
|
||||
|
||||
// Operation
|
||||
// expose required
|
||||
func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied bool, rID string) {
|
||||
func (app *Application) Operation(op string, name, tipo, ipSTR,rID, comment string, proxied bool) {
|
||||
var (
|
||||
res *checker.Response
|
||||
err error
|
||||
@ -205,7 +205,7 @@ func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied b
|
||||
if dn == "*" {
|
||||
for _, rec := range app.zoneRecords {
|
||||
if rec.Content != app.publicIP.String() {
|
||||
rBody = app.GenerateReqBody(rec.Name, res.Type, app.publicIP.String(), proxied)
|
||||
rBody = app.GenerateReqBody(rec.Name, res.Type, app.publicIP.String(), comment, proxied)
|
||||
app.Update(&rec, *rBody)
|
||||
} else {
|
||||
app.log.Info("same ip for", "record", rec.Name, "DstIP", rec.Content, "NewIP", app.publicIP)
|
||||
@ -216,7 +216,7 @@ func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied b
|
||||
}
|
||||
} else {
|
||||
if rs.Content != app.publicIP.String() {
|
||||
rBody = app.GenerateReqBody(name, res.Type, app.publicIP.String(), proxied)
|
||||
rBody = app.GenerateReqBody(name, res.Type, app.publicIP.String(),comment, proxied)
|
||||
app.Update(rs, *rBody)
|
||||
} else {
|
||||
app.log.Error("same ip on dns record")
|
||||
@ -228,7 +228,7 @@ func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied b
|
||||
panic("name cant be empty for op create")
|
||||
}
|
||||
fmt.Printf("domain name: %s", dn)
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(), proxied)
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(),comment, proxied)
|
||||
app.Create(*rBody)
|
||||
case "delete":
|
||||
if name == "" {
|
||||
@ -248,7 +248,7 @@ func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied b
|
||||
|
||||
app.log.Error(fmt.Sprintf("could not find record: %s -> %s", name, dn), "operation", "overwrite")
|
||||
} else {
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(), proxied)
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(), comment, proxied)
|
||||
app.Overwrite(rs, rBody)
|
||||
}
|
||||
case "details":
|
||||
@ -257,7 +257,7 @@ func (app *Application) Operation(op string, name, tipo, ipSTR string, proxied b
|
||||
}
|
||||
|
||||
if rs != nil {
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(), proxied)
|
||||
rBody = app.GenerateReqBody(dn, tipo, app.publicIP.String(), comment, proxied)
|
||||
app.Details(rs.ID)
|
||||
}
|
||||
|
||||
@ -293,8 +293,9 @@ func (app *Application) SelectNameAndType(name, tipo string) (rec *cf.Result, er
|
||||
}
|
||||
}
|
||||
|
||||
func (app *Application) GenerateReqBody(name, tipo, ipSTR string, proxied bool) (rBody *cf.RequestBody) {
|
||||
func (app *Application) GenerateReqBody(name, tipo, ipSTR, comment string, proxied bool) (rBody *cf.RequestBody) {
|
||||
rBody = &cf.RequestBody{}
|
||||
rBody.Comment = comment
|
||||
rBody.DomainName = name
|
||||
rBody.Type = tipo
|
||||
rBody.Content = ipSTR
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user