Skip to content

Commit

Permalink
cleanups: lint and errcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Apr 22, 2018
1 parent 3fab0cc commit 8d56189
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 78 deletions.
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

all:
go build `go list ./... | grep -v /vendor/`
mkdir -p bin
go build ./...
go build

docker: all
docker build -t cycoresystems/ari-proxy ./
docker push cycoresystems/ari-proxy

test:
go test `go list ./... | grep -v /vendor/`
go test ./...

lint:
gometalinter --disable=gotype --disable=errcheck ./... --skip internal --vendor
gometalinter --skip internal --vendor ./...

check: all lint test

Expand Down
18 changes: 12 additions & 6 deletions ci_release.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
#!/bin/bash

# Login to Docker
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# Only run if we are inside Travis-CI
if [ ! -e $CI ]; then
echo "Logging in to Docker..."
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

# Install goreleaser
go get -u github.com/goreleaser/goreleaser
# Install goreleaser
echo "Fetching goreleaser..."
go get -u github.com/goreleaser/goreleaser

# Create the release
echo "Creating release..."
goreleaser release
fi

# Create the release
goreleaser release
15 changes: 3 additions & 12 deletions server/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ func (s *Server) applicationData(ctx context.Context, reply string, req *proxy.R
return
}

err = s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Application: data,
},
})
if err != nil {
s.Log.Warn("failed to publish applicationData response", "error", err)
}
}

func (s *Server) applicationList(ctx context.Context, reply string, req *proxy.Request) {
Expand All @@ -32,12 +29,9 @@ func (s *Server) applicationList(ctx context.Context, reply string, req *proxy.R
return
}

err = s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
if err != nil {
s.Log.Warn("failed to publish applicationList response", "error", err)
}
}

func (s *Server) applicationGet(ctx context.Context, reply string, req *proxy.Request) {
Expand All @@ -47,12 +41,9 @@ func (s *Server) applicationGet(ctx context.Context, reply string, req *proxy.Re
return
}

err = s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key,
})
if err != nil {
s.Log.Warn("failed to publish applicationGet response", "error", err)
}
}

func parseEventSource(src string) (string, string, error) {
Expand Down
4 changes: 2 additions & 2 deletions server/asterisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (s *Server) asteriskInfo(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Asterisk: data,
},
Expand All @@ -27,7 +27,7 @@ func (s *Server) asteriskVariableGet(ctx context.Context, reply string, req *pro
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Variable: val,
},
Expand Down
18 changes: 9 additions & 9 deletions server/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (s *Server) bridgeCreate(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -51,7 +51,7 @@ func (s *Server) bridgeStageCreate(ctx context.Context, reply string, req *proxy
s.Dialog.Bind(req.Key.Dialog, "bridge", req.Key.ID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: bh.Key(),
})
}
Expand All @@ -63,7 +63,7 @@ func (s *Server) bridgeData(ctx context.Context, reply string, req *proxy.Reques
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Bridge: bd,
},
Expand Down Expand Up @@ -96,7 +96,7 @@ func (s *Server) bridgeGet(ctx context.Context, reply string, req *proxy.Request
s.Dialog.Bind(req.Key.Dialog, "bridge", req.Key.ID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
Expand All @@ -108,7 +108,7 @@ func (s *Server) bridgeList(ctx context.Context, reply string, req *proxy.Reques
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
}
Expand All @@ -127,7 +127,7 @@ func (s *Server) bridgePlay(ctx context.Context, reply string, req *proxy.Reques
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: ph.Key(),
})
}
Expand All @@ -149,7 +149,7 @@ func (s *Server) bridgeStagePlay(ctx context.Context, reply string, req *proxy.R
s.Dialog.Bind(req.Key.Dialog, "playback", req.BridgePlay.PlaybackID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: s.ari.Playback().Get(ari.NewKey(ari.PlaybackKey, req.BridgePlay.PlaybackID)).Key(),
})
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func (s *Server) bridgeRecord(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -198,7 +198,7 @@ func (s *Server) bridgeStageRecord(ctx context.Context, reply string, req *proxy
s.Dialog.Bind(req.Key.Dialog, "recording", req.BridgeRecord.Name)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key.New(ari.LiveRecordingKey, req.BridgeRecord.Name),
})
}
Expand Down
26 changes: 13 additions & 13 deletions server/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *Server) channelCreate(ctx context.Context, reply string, req *proxy.Req
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -63,7 +63,7 @@ func (s *Server) channelData(ctx context.Context, reply string, req *proxy.Reque
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Channel: d,
},
Expand All @@ -77,7 +77,7 @@ func (s *Server) channelGet(ctx context.Context, reply string, req *proxy.Reques
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (s *Server) channelList(ctx context.Context, reply string, req *proxy.Reque
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func (s *Server) channelOriginate(ctx context.Context, reply string, req *proxy.
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -153,7 +153,7 @@ func (s *Server) channelStageOriginate(ctx context.Context, reply string, req *p
s.Dialog.Bind(req.Key.Dialog, "channel", req.Key.ID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key().New(ari.ChannelKey, req.ChannelOriginate.OriginateRequest.ChannelID),
})
}
Expand All @@ -180,7 +180,7 @@ func (s *Server) channelPlay(ctx context.Context, reply string, req *proxy.Reque
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: ph.Key(),
})
}
Expand All @@ -202,7 +202,7 @@ func (s *Server) channelStagePlay(ctx context.Context, reply string, req *proxy.
s.Dialog.Bind(req.Key.Dialog, "playback", req.ChannelPlay.PlaybackID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: s.ari.Playback().Get(ari.NewKey(ari.PlaybackKey, req.ChannelPlay.PlaybackID)).Key(),
})
}
Expand All @@ -223,7 +223,7 @@ func (s *Server) channelRecord(ctx context.Context, reply string, req *proxy.Req
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -244,7 +244,7 @@ func (s *Server) channelStageRecord(ctx context.Context, reply string, req *prox
s.Dialog.Bind(req.Key.Dialog, "recording", req.ChannelRecord.Name)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key.New(ari.LiveRecordingKey, req.ChannelRecord.Name),
})
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s *Server) channelSnoop(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: h.Key(),
})
}
Expand All @@ -296,7 +296,7 @@ func (s *Server) channelStageSnoop(ctx context.Context, reply string, req *proxy
s.Dialog.Bind(req.Key.Dialog, "channel", req.ChannelSnoop.SnoopID)
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: s.ari.Channel().Get(ari.NewKey(ari.ChannelKey, req.ChannelSnoop.SnoopID)).Key(),
})

Expand Down Expand Up @@ -339,7 +339,7 @@ func (s *Server) channelVariableGet(ctx context.Context, reply string, req *prox
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Variable: val,
},
Expand Down
2 changes: 1 addition & 1 deletion server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (s *Server) asteriskConfigData(ctx context.Context, reply string, req *prox
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Config: data,
},
Expand Down
6 changes: 3 additions & 3 deletions server/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (s *Server) deviceStateData(ctx context.Context, reply string, req *proxy.R
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
DeviceState: data,
},
Expand All @@ -27,7 +27,7 @@ func (s *Server) deviceStateGet(ctx context.Context, reply string, req *proxy.Re
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
Expand All @@ -43,7 +43,7 @@ func (s *Server) deviceStateList(ctx context.Context, reply string, req *proxy.R
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
}
Expand Down
8 changes: 4 additions & 4 deletions server/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (s *Server) endpointData(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Data: &proxy.EntityData{
Endpoint: data,
},
Expand All @@ -27,7 +27,7 @@ func (s *Server) endpointGet(ctx context.Context, reply string, req *proxy.Reque
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Key: data.Key,
})
}
Expand All @@ -39,7 +39,7 @@ func (s *Server) endpointList(ctx context.Context, reply string, req *proxy.Requ
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
}
Expand All @@ -51,7 +51,7 @@ func (s *Server) endpointListByTech(ctx context.Context, reply string, req *prox
return
}

s.nats.Publish(reply, &proxy.Response{
s.publish(reply, &proxy.Response{
Keys: list,
})
}
4 changes: 2 additions & 2 deletions server/liveRecording.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (s *Server) recordingLiveData(ctx context.Context, reply string, req *proxy
return
}

s.nats.Publish(reply, proxy.Response{
s.publish(reply, proxy.Response{
Data: &proxy.EntityData{
LiveRecording: data,
},
Expand All @@ -27,7 +27,7 @@ func (s *Server) recordingLiveGet(ctx context.Context, reply string, req *proxy.
return
}

s.nats.Publish(reply, proxy.Response{
s.publish(reply, proxy.Response{
Key: data.Key,
})
}
Expand Down
Loading

0 comments on commit 8d56189

Please sign in to comment.