Skip to content

Commit 27cb668

Browse files
committed
Merge pull request #251 from moul/bump-gotty-client
Improvements
2 parents 7f7e4da + 2f6f5f8 commit 27cb668

File tree

20 files changed

+106
-61
lines changed

20 files changed

+106
-61
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,12 @@ packages:
132132

133133
golint:
134134
@go get github.com/golang/lint/golint
135-
@for dir in */; do golint $$dir; done
135+
@for dir in $(shell go list ./... | grep -v /vendor/); do golint $$dir; done
136+
137+
138+
gocyclo:
139+
go get github.com/fzipp/gocyclo
140+
gocyclo -over 15 $(shell find . -name "*.go" -not -name "*test.go" | grep -v /vendor/)
136141

137142

138143
party:

pkg/api/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,22 +639,26 @@ type ScalewayTokensDefinition struct {
639639
Token ScalewayTokenDefinition `json:"token"`
640640
}
641641

642+
// ScalewayContainerData represents a Scaleway container data (S3)
642643
type ScalewayContainerData struct {
643644
LastModified string `json:"last_modified"`
644645
Name string `json:"name"`
645646
Size string `json:"size"`
646647
}
647648

649+
// ScalewayGetContainerDatas represents a list of Scaleway containers data (S3)
648650
type ScalewayGetContainerDatas struct {
649651
Container []ScalewayContainerData `json:"container"`
650652
}
651653

654+
// ScalewayContainer represents a Scaleway container (S3)
652655
type ScalewayContainer struct {
653656
ScalewayOrganizationDefinition `json:"organization"`
654657
Name string `json:"name"`
655658
Size string `json:"size"`
656659
}
657660

661+
// ScalewayGetContainers represents a list of Scaleway containers (S3)
658662
type ScalewayGetContainers struct {
659663
Containers []ScalewayContainer `json:"containers"`
660664
}
@@ -742,6 +746,7 @@ type ScalewayUserdatas struct {
742746
UserData []string `json:"user_data"`
743747
}
744748

749+
// ScalewayQuota represents a map of quota (name, value)
745750
type ScalewayQuota map[string]int
746751

747752
// ScalewayGetQuotas represents the response of GET /organizations/{orga_id}/quotas

pkg/api/helpers.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,14 @@ func InspectIdentifiers(api *ScalewayAPI, ci chan ScalewayResolvedIdentifier, cj
284284
close(cj)
285285
}
286286

287+
// ConfigCreateServer represents the options sent to CreateServer and defining a server
287288
type ConfigCreateServer struct {
288289
ImageName string
289290
Name string
290291
Bootscript string
291292
Env string
292293
AdditionalVolumes string
293-
DynamicIpRequired bool
294+
DynamicIPRequired bool
294295
IP string
295296
CommercialType string
296297
}
@@ -312,7 +313,7 @@ func CreateServer(api *ScalewayAPI, c *ConfigCreateServer) (string, error) {
312313
server.CommercialType = c.CommercialType
313314
server.Volumes = make(map[string]string)
314315

315-
server.DynamicIPRequired = &c.DynamicIpRequired
316+
server.DynamicIPRequired = &c.DynamicIPRequired
316317
if c.IP != "" {
317318
if anonuuid.IsUUID(c.IP) == nil {
318319
server.PublicIP = c.IP

pkg/cli/command.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (c *Command) GetContext(rawArgs []string) commands.CommandContext {
7676
return ctx
7777
}
7878

79+
// Streams returns command streams with default os streams if unset
7980
func (c *Command) Streams() *commands.Streams {
8081
if c.streams != nil {
8182
return c.streams

pkg/cli/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var (
2929
flSensitive = flag.Bool([]string{"-sensitive"}, false, "Show sensitive data in outputs, i.e. API Token/Organization")
3030
)
3131

32+
// Start is the entrypoint
3233
func Start(rawArgs []string, streams *commands.Streams) (int, error) {
3334
if streams == nil {
3435
streams = &commands.Streams{
@@ -135,7 +136,7 @@ func Start(rawArgs []string, streams *commands.Streams) (int, error) {
135136
}
136137
}
137138

138-
return 1, fmt.Errorf("scw: unknown subcommand %s\nRun 'scw help' for usage.", name)
139+
return 1, fmt.Errorf("scw: unknown subcommand %s\nRun 'scw help' for usage", name)
139140
}
140141

141142
// getScalewayAPI returns a ScalewayAPI using the user config file

pkg/cli/test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import (
77
)
88

99
var (
10-
scwcli string = "../../scw"
11-
publicCommands []string = []string{
10+
scwcli = "../../scw"
11+
publicCommands = []string{
1212
"help", "attach", "commit", "cp", "create",
1313
"events", "exec", "history", "images", "info",
1414
"inspect", "kill", "login", "logout", "logs",
1515
"port", "ps", "rename", "restart", "rm", "rmi",
1616
"run", "search", "start", "stop", "tag", "top",
1717
"version", "wait",
1818
}
19-
secretCommands []string = []string{
19+
secretCommands = []string{
2020
"_patch", "_completion", "_flush-cache", "_userdata", "_billing",
2121
}
22-
publicOptions []string = []string{
22+
publicOptions = []string{
2323
"-h, --help=false",
2424
"-D, --debug=false",
2525
"-V, --verbose=false",

pkg/cli/x_userdata.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@ func runUserdata(cmd *Command, args []string) error {
4242
}
4343

4444
ctx := cmd.GetContext(args)
45-
var Api *api.ScalewayAPI
45+
var API *api.ScalewayAPI
4646
var err error
4747
var serverID string
4848
if args[0] == "local" {
49-
Api, err = api.NewScalewayAPI("", "", "", "")
49+
API, err = api.NewScalewayAPI("", "", "", "")
5050
if err != nil {
5151
return err
5252
}
53-
Api.EnableMetadataAPI()
53+
API.EnableMetadataAPI()
5454
} else {
5555
if ctx.API == nil {
5656
return fmt.Errorf("You need to login first: 'scw login'")
5757
}
5858
serverID = ctx.API.GetServerID(args[0])
59-
Api = ctx.API
59+
API = ctx.API
6060
}
6161

6262
switch len(args) {
6363
case 1:
6464
// List userdata
65-
res, err := Api.GetUserdatas(serverID)
65+
res, err := API.GetUserdatas(serverID)
6666
if err != nil {
6767
return err
6868
}
@@ -75,7 +75,7 @@ func runUserdata(cmd *Command, args []string) error {
7575
switch len(parts) {
7676
case 1:
7777
// Get userdatas
78-
res, err := Api.GetUserdata(serverID, key)
78+
res, err := API.GetUserdata(serverID, key)
7979
if err != nil {
8080
return err
8181
}
@@ -93,14 +93,14 @@ func runUserdata(cmd *Command, args []string) error {
9393
} else {
9494
data = []byte(value)
9595
}
96-
err := Api.PatchUserdata(serverID, key, data)
96+
err := API.PatchUserdata(serverID, key, data)
9797
if err != nil {
9898
return err
9999
}
100100
fmt.Fprintln(ctx.Stdout, key)
101101
} else {
102102
// Delete userdata
103-
err := Api.DeleteUserdata(serverID, key)
103+
err := API.DeleteUserdata(serverID, key)
104104
if err != nil {
105105
return err
106106
}

pkg/commands/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func RunCreate(ctx CommandContext, args CreateArgs) error {
3939
Bootscript: args.Bootscript,
4040
Env: env,
4141
AdditionalVolumes: volume,
42-
DynamicIpRequired: args.IP == "",
42+
DynamicIPRequired: args.IP == "",
4343
IP: args.IP,
4444
})
4545
if err != nil {

pkg/commands/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func Run(ctx CommandContext, args RunArgs) error {
119119
Bootscript: args.Bootscript,
120120
Env: env,
121121
AdditionalVolumes: volume,
122-
DynamicIpRequired: args.Gateway == "",
122+
DynamicIPRequired: args.Gateway == "",
123123
IP: args.IP,
124124
})
125125
if err != nil {

pkg/commands/test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func getScopedCtx(sessionCtx *CommandContext) (*CommandContext, *bytes.Buffer, *
3333
return &newCtx, &stdout, &stderr
3434
}
3535

36+
// RealAPIContext returns a CommandContext with a configured API
3637
func RealAPIContext() *CommandContext {
3738
config, err := config.GetConfig()
3839
if err != nil {

0 commit comments

Comments
 (0)