Skip to content

Commit 06f903f

Browse files
author
Matthew Fisher
committed
Merge pull request #54 from bacongobbler/deisctl-fixes
minor bugfixes
2 parents ead1fcd + 725ae0d commit 06f903f

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ setup-gotools:
2323
go get -v github.com/golang/lint/golint
2424

2525
test-style:
26-
go vet -x ./...
27-
-golint *.go client/ cmd/ config/ constant/ hooks/ lock/ systemd/ units/ update/ utils/
26+
go vet ./...
27+
-golint *.go client/*.go cmd/*.go config/*.go constant/*.go lock/*.go update/*.go utils/*.go
2828

2929
test: test-style
3030
godep go test -v -cover ./...

client/destroy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import (
99

1010
// Destroy units for a given target
1111
func (c *FleetClient) Destroy(target string) (err error) {
12+
// check if the unit exists
13+
if _, err := c.Units(target); err != nil {
14+
return err
15+
}
1216
component, num, err := splitTarget(target)
1317
if err != nil {
1418
return

client/unit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ func (c *FleetClient) Units(target string) (units []string, err error) {
4040
units = append(units, u.Name)
4141
}
4242
}
43+
if len(units) == 0 {
44+
err = fmt.Errorf("could not find unit: %s", target)
45+
}
4346
return
4447
}
4548

deisctl.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,8 @@ Options:
7070
--tunnel=<host> establish an SSH tunnel for communication with fleet and etcd [default: ]
7171
--request-timeout=<secs> amount of time to allow a single request before considering it failed. [default: 3.0]
7272
`
73-
// special handling for version
74-
if len(os.Args) == 2 && os.Args[1] == "--version" {
75-
fmt.Println(Version)
76-
os.Exit(0)
77-
}
7873
// parse command-line arguments
79-
args, err := docopt.Parse(usage, nil, true, "", true)
74+
args, err := docopt.Parse(usage, nil, true, Version, true)
8075
if err != nil {
8176
exit(err, 2)
8277
}

0 commit comments

Comments
 (0)