Skip to content

Commit 2925ff9

Browse files
Skarlsomichelvocks
authored andcommitted
Adding linter to circle CI. (#176)
* Adding linter to circle CI. * Force linting with exit status. * Appeased the new linter checker. * Ups.
1 parent 56d9c03 commit 2925ff9

File tree

6 files changed

+43
-22
lines changed

6 files changed

+43
-22
lines changed

.circleci/config.yml

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
version: 2
22

33
jobs:
4+
linter:
5+
working_directory: /go/src/github.com/gaia-pipeline/gaia
6+
docker:
7+
- image: circleci/golang:1.11.4
8+
environment:
9+
GO111MODULE: "on"
10+
steps:
11+
- checkout
12+
- run:
13+
name: Install linter
14+
command: |
15+
go get -u golang.org/x/lint/golint
16+
- run:
17+
name: Run linter
18+
command: |
19+
make lint
420
test_and_coverage:
521
working_directory: /go/src/github.com/gaia-pipeline/gaia
622
docker:
@@ -76,6 +92,7 @@ workflows:
7692
version: 2
7793
test_and_compile:
7894
jobs:
95+
- linter
7996
- test_and_coverage
8097
- acceptance_tests
8198
- compile

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ deploy-kube:
4949

5050
kube-ingress-lb:
5151
kubectl apply -R -f ${HELM_DIR}/_system
52+
53+
lint:
54+
golint -set_exit_status ./...

gaia.go

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ type Config struct {
249249
}
250250
}
251251

252+
// StoreConfig defines config settings to be stored in DB.
252253
type StoreConfig struct {
253254
ID int
254255
Poll bool

plugin/grpc.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@ package plugin
33
import (
44
"context"
55

6-
"github.com/gaia-pipeline/protobuf"
6+
proto "github.com/gaia-pipeline/protobuf"
77
plugin "github.com/hashicorp/go-plugin"
88
"google.golang.org/grpc"
99
)
1010

11-
// PluginGRPC is the Gaia plugin interface used for communication
11+
// GaiaPlugin is the Gaia plugin interface used for communication
1212
// with the plugin.
13-
type PluginGRPC interface {
13+
type GaiaPlugin interface {
1414
GetJobs() (proto.Plugin_GetJobsClient, error)
1515
ExecuteJob(job *proto.Job) (*proto.JobResult, error)
1616
}
1717

18-
// GRPCClient represents gRPC client
19-
type GRPCClient struct {
18+
// GaiaPluginClient represents gRPC client
19+
type GaiaPluginClient struct {
2020
client proto.PluginClient
2121
}
2222

23-
// PluginGRPCImpl represents the plugin implementation on client side.
24-
type PluginGRPCImpl struct {
25-
Impl PluginGRPC
23+
// GaiaPluginImpl represents the plugin implementation on client side.
24+
type GaiaPluginImpl struct {
25+
Impl GaiaPlugin
2626

2727
plugin.NetRPCUnsupportedPlugin
2828
}
2929

3030
// GRPCServer is needed here to implement hashicorp
3131
// plugin.Plugin interface. Real implementation is
3232
// in the plugin(s).
33-
func (p *PluginGRPCImpl) GRPCServer(b *plugin.GRPCBroker, s *grpc.Server) error {
33+
func (p *GaiaPluginImpl) GRPCServer(b *plugin.GRPCBroker, s *grpc.Server) error {
3434
// Real implementation defined in plugin
3535
return nil
3636
}
3737

3838
// GRPCClient is the passing method for the gRPC client.
39-
func (p *PluginGRPCImpl) GRPCClient(context context.Context, b *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
40-
return &GRPCClient{client: proto.NewPluginClient(c)}, nil
39+
func (p *GaiaPluginImpl) GRPCClient(context context.Context, b *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error) {
40+
return &GaiaPluginClient{client: proto.NewPluginClient(c)}, nil
4141
}
4242

4343
// GetJobs requests all jobs from the plugin.
4444
// We get a stream of proto.Job back.
45-
func (m *GRPCClient) GetJobs() (proto.Plugin_GetJobsClient, error) {
45+
func (m *GaiaPluginClient) GetJobs() (proto.Plugin_GetJobsClient, error) {
4646
return m.client.GetJobs(context.Background(), &proto.Empty{})
4747
}
4848

4949
// ExecuteJob triggers the execution of the given job in the plugin.
50-
func (m *GRPCClient) ExecuteJob(job *proto.Job) (*proto.JobResult, error) {
50+
func (m *GaiaPluginClient) ExecuteJob(job *proto.Job) (*proto.JobResult, error) {
5151
return m.client.ExecuteJob(context.Background(), job)
5252
}

plugin/plugin.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var handshake = plugin.HandshakeConfig{
3434
}
3535

3636
var pluginMap = map[string]plugin.Plugin{
37-
pluginMapKey: &PluginGRPCImpl{},
37+
pluginMapKey: &GaiaPluginImpl{},
3838
}
3939

4040
// timeFormat is the logging time format.
@@ -50,7 +50,7 @@ type Plugin struct {
5050
clientProtocol plugin.ClientProtocol
5151

5252
// Interface to the connected plugin.
53-
pluginConn PluginGRPC
53+
pluginConn GaiaPlugin
5454

5555
// Log file where all output is stored.
5656
logFile *os.File
@@ -160,7 +160,7 @@ func (p *Plugin) Validate() error {
160160
}
161161

162162
// Convert plugin to interface
163-
if pC, ok := raw.(PluginGRPC); ok {
163+
if pC, ok := raw.(GaiaPlugin); ok {
164164
p.pluginConn = pC
165165
return nil
166166
}

plugin/plugin_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ func (c *fakeCAAPI) GetCACertPath() (string, string) { return "", "" }
2929

3030
type fakeClientProtocol struct{}
3131

32-
func (cp *fakeClientProtocol) Dispense(s string) (interface{}, error) { return &fakePluginGRPC{}, nil }
32+
func (cp *fakeClientProtocol) Dispense(s string) (interface{}, error) { return &fakeGaiaPlugin{}, nil }
3333
func (cp *fakeClientProtocol) Ping() error { return nil }
3434
func (cp *fakeClientProtocol) Close() error { return nil }
3535

36-
type fakePluginGRPC struct{}
36+
type fakeGaiaPlugin struct{}
3737

38-
func (p *fakePluginGRPC) GetJobs() (proto.Plugin_GetJobsClient, error) {
38+
func (p *fakeGaiaPlugin) GetJobs() (proto.Plugin_GetJobsClient, error) {
3939
return &fakeJobsClient{}, nil
4040
}
41-
func (p *fakePluginGRPC) ExecuteJob(job *proto.Job) (*proto.JobResult, error) {
41+
func (p *fakeGaiaPlugin) ExecuteJob(job *proto.Job) (*proto.JobResult, error) {
4242
return &proto.JobResult{}, nil
4343
}
4444

@@ -106,7 +106,7 @@ func TestExecute(t *testing.T) {
106106
Output: hclog.DefaultOutput,
107107
Name: "Gaia",
108108
})
109-
p := &Plugin{pluginConn: new(fakePluginGRPC)}
109+
p := &Plugin{pluginConn: new(fakeGaiaPlugin)}
110110
buf := new(bytes.Buffer)
111111
p.writer = bufio.NewWriter(buf)
112112
err := p.Execute(&gaia.Job{})
@@ -122,7 +122,7 @@ func TestGetJobs(t *testing.T) {
122122
Output: hclog.DefaultOutput,
123123
Name: "Gaia",
124124
})
125-
p := &Plugin{pluginConn: new(fakePluginGRPC)}
125+
p := &Plugin{pluginConn: new(fakeGaiaPlugin)}
126126
buf := new(bytes.Buffer)
127127
p.writer = bufio.NewWriter(buf)
128128
_, err := p.GetJobs()

0 commit comments

Comments
 (0)