Skip to content

Commit dda26c0

Browse files
committed
Remove name normalization (let the API handle it and avoid implicit changes)
1 parent bb429a9 commit dda26c0

4 files changed

Lines changed: 3 additions & 19 deletions

File tree

api/client.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (c *Client) GetDeviceByID(did int) (*Device, error) {
8989
}
9090

9191
func (c *Client) GetDeviceByName(name string) (*Device, error) {
92-
return c.getdevice(fmt.Sprintf(c.deviceURL, NormalizeName(name)))
92+
return c.getdevice(fmt.Sprintf(c.deviceURL, name))
9393
}
9494

9595
func (c *Client) GetDeviceByIP(ip net.IP) (*Device, error) {
@@ -208,9 +208,6 @@ func (c *Client) CreateDeviceAndSite(siteDevCreate *SiteAndDeviceCreate) (*Devic
208208

209209
createUrl := c.API.String() + "/deviceAndSite"
210210

211-
// Remove chars which result in 500
212-
siteDevCreate.Device.NormalizeName()
213-
214211
body, err := json.Marshal(siteDevCreate)
215212
if err != nil {
216213
return nil, err
@@ -244,9 +241,6 @@ func (c *Client) CreateDevice(create *DeviceCreate) (*Device, error) {
244241
return nil, fmt.Errorf("Missing IP for device")
245242
}
246243

247-
// Remove chars which result in 500
248-
create.NormalizeName()
249-
250244
body, err := json.Marshal(map[string]*DeviceCreate{
251245
"device": create,
252246
})

api/funcs.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,8 @@ package api
33
import (
44
"fmt"
55
"net"
6-
"strings"
76
)
87

9-
// NormalizeName is a helper for normalization of the devices name into an acceptable format for the Kentik API device
10-
// endpoints.
11-
func NormalizeName(name string) string {
12-
return strings.Replace(name, ".", "_", -1)
13-
}
14-
158
func GetInterfaceUpdates(nif *net.Interface) (map[string]InterfaceUpdate, error) {
169
addrs, err := interfaceAddrs(nif)
1710
if err != nil {

api/types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,3 @@ func (c Column) MarshalFlag() (string, error) {
159159
b, err := json.Marshal(c)
160160
return string(b), err
161161
}
162-
163-
func (c *DeviceCreate) NormalizeName() {
164-
c.Name = NormalizeName(c.Name)
165-
}

cmd/server/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/jessevdk/go-flags"
9+
910
"github.com/kentik/libkflow/api"
1011
"github.com/kentik/libkflow/api/test"
1112
)
@@ -36,7 +37,7 @@ func main() {
3637
Token: "token",
3738
CompanyID: 1,
3839
DeviceID: 1,
39-
DeviceName: api.NormalizeName("dev1"),
40+
DeviceName: "dev1",
4041
DeviceIP: "127.0.0.1",
4142
Sample: 1,
4243
MaxFPS: 4000,

0 commit comments

Comments
 (0)