mirror of
https://github.com/cloudflare/redoctober.git
synced 2026-08-31 21:27:14 +00:00
Fix uses being a string and breaking tests
This commit is contained in:
+3
-3
@@ -116,7 +116,7 @@ type OrderRequest struct {
|
||||
Name string
|
||||
Password string
|
||||
Duration string
|
||||
Uses string
|
||||
Uses int
|
||||
Data []byte
|
||||
Labels []string
|
||||
}
|
||||
@@ -757,7 +757,7 @@ func Order(jsonIn []byte) (out []byte, err error) {
|
||||
err = errors.New("Duration required when placing an order.")
|
||||
jsonStatusError(err)
|
||||
}
|
||||
if o.Uses == "" || o.Uses == "0" {
|
||||
if o.Uses == 0 {
|
||||
err = errors.New("Number of required uses necessary when placing an order.")
|
||||
jsonStatusError(err)
|
||||
}
|
||||
@@ -785,7 +785,7 @@ func Order(jsonIn []byte) (out []byte, err error) {
|
||||
altOwners := records.GetAltNamesFromName(orders.AlternateName, owners)
|
||||
|
||||
// Let everyone on hipchat know there is a new order.
|
||||
orders.NotifyNewOrder(o.Name, o.Duration, o.Uses, orderNum, o.Labels, altOwners)
|
||||
orders.NotifyNewOrder(o.Name, o.Duration, orderNum, o.Labels, o.Uses, altOwners)
|
||||
if err != nil {
|
||||
return jsonStatusError(err)
|
||||
}
|
||||
|
||||
+4
-3
@@ -5,13 +5,14 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/cloudflare/redoctober/hipchat"
|
||||
)
|
||||
|
||||
const (
|
||||
NewOrder = "%s has created an order for the label %s. requesting %s delegations for %s"
|
||||
NewOrder = "%s has created an order for the label %s. requesting %d delegations for %s"
|
||||
NewOrderLink = "@%s - https://%s?%s"
|
||||
OrderFulfilled = "%s has had order %s fulfilled."
|
||||
NewDelegation = "%s has delegated the label %s to %s (per order %s) for %s"
|
||||
@@ -77,7 +78,7 @@ func NewOrderer(hipchatClient hipchat.HipchatClient) (o Orderer) {
|
||||
func notify(o *Orderer, msg, color string) {
|
||||
o.Hipchat.Notify(msg, color)
|
||||
}
|
||||
func (o *Orderer) NotifyNewOrder(name, duration, uses, orderNum string, labels []string, owners map[string]string) {
|
||||
func (o *Orderer) NotifyNewOrder(name, duration, orderNum string, labels []string, uses int, owners map[string]string) {
|
||||
labelList := ""
|
||||
for i, label := range labels {
|
||||
if i == 0 {
|
||||
@@ -95,7 +96,7 @@ func (o *Orderer) NotifyNewOrder(name, duration, uses, orderNum string, labels [
|
||||
"delegator": {owner},
|
||||
"label": {labelList},
|
||||
"duration": {duration},
|
||||
"uses": {uses},
|
||||
"uses": {strconv.Itoa(uses)},
|
||||
"ordernum": {orderNum},
|
||||
"delegatee": {name},
|
||||
}.Encode()
|
||||
|
||||
Reference in New Issue
Block a user