Merge lp:~mterry/snappy/set-sudo-15.04 into lp:~snappy-dev/snappy/15.04-deprecated

Proposed by Michael Terry
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 454
Merged at revision: 455
Proposed branch: lp:~mterry/snappy/set-sudo-15.04
Merge into: lp:~snappy-dev/snappy/15.04-deprecated
Diff against target: 67 lines (+10/-7)
2 files modified
cmd/snappy/cmd_set.go (+7/-0)
cmd/snappy/main.go (+3/-7)
To merge this branch: bzr merge lp:~mterry/snappy/set-sudo-15.04
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+263920@code.launchpad.net

Commit message

Add an are-we-root-check/mutex-lock to the set command and make the message nicer.

This is a backport of r528 from trunk.

Description of the change

Add an are-we-root-check/mutex-lock to the set command and make the message nicer.

This is a backport of r528 from trunk.

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

The attempt to merge lp:~mterry/snappy/set-sudo-15.04 into lp:snappy/15.04 failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update code.google.com/p/go.crypto failed; trying to fetch newer version
update github.com/blakesmith/ar failed; trying to fetch newer version
code.google.com/p/go.crypto now at 69e2a90ed92d03812364aeb947b7068dc42e561e
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/blakesmith/ar now at c9a977dd0cc1392b023382c7bfa5a22af8d3b730
update github.com/jessevdk/go-flags failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/juju/loggo failed; trying to fetch newer version
github.com/jessevdk/go-flags now at 15347ef417a300349807983f15af9e65cd2e1b3a
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/juju/loggo now at 4c7cbce140ca070eeb59a28f4bf9507e511711f9
update gopkg.in/yaml.v2 failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update launchpad.net/gocheck failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
launchpad.net/gocheck now at <email address hidden>
Building

# we always run in a fresh dir in tarmac
export GOPATH=$(mktemp -d)
trap 'rm -rf "$GOPATH"' EXIT

# this is a hack, but not sure tarmac is golang friendly
mkdir -p $GOPATH/src/launchpad.net/snappy
cp -a . $GOPATH/src/launchpad.net/snappy/
cd $GOPATH/src/launchpad.net/snappy

./run-checks

if which goctest >/dev/null; then
    goctest="goctest"
else
    goctest="go test"
fi

echo Checking formatting
fmt=$(gofmt -l .)

if [ -n "$fmt" ]; then
    echo "Formatting wrong in following files"
    echo $fmt
    exit 1
fi

echo Installing godeps
go get launchpad.net/godeps
export PATH=$PATH:$GOPATH/bin

echo Install golint
go get github.com/golang/lint/golint
export PATH=$PATH:$GOPATH/bin

echo Obtaining dependencies
godeps -u dependencies.tsv

echo Building
go build -v launchpad.net/snappy/...
github.com/blakesmith/ar
github.com/juju/loggo
code.google.com/p/go.crypto/ssh/terminal
launchpad.net/snappy/logger
launchpad.net/snappy/helpers
github.com/jessevdk/go-flags
launchpad.net/snappy/priv
github.com/cheggaaa/pb
launchpad.net/snappy/progress
launchpad.net/snappy/clickdeb
github.com/mvo5/goconfigparser
gopkg.in/yaml.v2
launchpad.net/snappy/policy
launchpad.net/snappy/release
launchpad.net/snappy/systemd
launchpad.net/snappy/coreconfig
launchpad.net/snappy/partition
launchpad.net/snappy/snappy
launchpad.net/snappy/cmd/snappy
# launchpad.net/snappy/cmd/snappy
cmd/snappy/cmd_set.go:51: undefined: withMutex

lp:~mterry/snappy/set-sudo-15.04 updated
454. By Michael Terry

Avoid use of non-existant withMutex

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/snappy/cmd_set.go'
--- cmd/snappy/cmd_set.go 2015-04-30 16:56:15 +0000
+++ cmd/snappy/cmd_set.go 2015-07-06 18:46:45 +0000
@@ -21,6 +21,7 @@
21 "fmt"21 "fmt"
22 "strings"22 "strings"
2323
24 "launchpad.net/snappy/priv"
24 "launchpad.net/snappy/progress"25 "launchpad.net/snappy/progress"
25 "launchpad.net/snappy/snappy"26 "launchpad.net/snappy/snappy"
26)27)
@@ -46,6 +47,12 @@
46}47}
4748
48func (x *cmdSet) Execute(args []string) (err error) {49func (x *cmdSet) Execute(args []string) (err error) {
50 privMutex := priv.New()
51 if err := privMutex.TryLock(); err != nil {
52 return err
53 }
54 defer privMutex.Unlock()
55
49 return set(args)56 return set(args)
50}57}
5158
5259
=== modified file 'cmd/snappy/main.go'
--- cmd/snappy/main.go 2015-03-26 13:02:07 +0000
+++ cmd/snappy/main.go 2015-07-06 18:46:45 +0000
@@ -18,28 +18,23 @@
18package main18package main
1919
20import (20import (
21 "errors"
22 "fmt"21 "fmt"
23 "os"22 "os"
2423
24 "launchpad.net/snappy/logger"
25 "launchpad.net/snappy/priv"25 "launchpad.net/snappy/priv"
26 "launchpad.net/snappy/snappy"26 "launchpad.net/snappy/snappy"
2727
28 "launchpad.net/snappy/logger"
29
30 "github.com/jessevdk/go-flags"28 "github.com/jessevdk/go-flags"
31)29)
3230
33// fixed errors the command can return
34var ErrRequiresRoot = errors.New("command requires sudo (root)")
35
36type options struct {31type options struct {
37 // No global options yet32 // No global options yet
38}33}
3934
40var optionsData options35var optionsData options
4136
42var parser = flags.NewParser(&optionsData, flags.Default)37var parser = flags.NewParser(&optionsData, flags.HelpFlag|flags.PassDoubleDash)
4338
44func init() {39func init() {
45 err := logger.ActivateLogger()40 err := logger.ActivateLogger()
@@ -55,6 +50,7 @@
55 // the CLI user.50 // the CLI user.
56 err = snappy.ErrNeedRoot51 err = snappy.ErrNeedRoot
57 }52 }
53 fmt.Fprintln(os.Stderr, err)
58 os.Exit(1)54 os.Exit(1)
59 }55 }
60}56}

Subscribers

People subscribed via source and target branches