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
1=== modified file 'cmd/snappy/cmd_set.go'
2--- cmd/snappy/cmd_set.go 2015-04-30 16:56:15 +0000
3+++ cmd/snappy/cmd_set.go 2015-07-06 18:46:45 +0000
4@@ -21,6 +21,7 @@
5 "fmt"
6 "strings"
7
8+ "launchpad.net/snappy/priv"
9 "launchpad.net/snappy/progress"
10 "launchpad.net/snappy/snappy"
11 )
12@@ -46,6 +47,12 @@
13 }
14
15 func (x *cmdSet) Execute(args []string) (err error) {
16+ privMutex := priv.New()
17+ if err := privMutex.TryLock(); err != nil {
18+ return err
19+ }
20+ defer privMutex.Unlock()
21+
22 return set(args)
23 }
24
25
26=== modified file 'cmd/snappy/main.go'
27--- cmd/snappy/main.go 2015-03-26 13:02:07 +0000
28+++ cmd/snappy/main.go 2015-07-06 18:46:45 +0000
29@@ -18,28 +18,23 @@
30 package main
31
32 import (
33- "errors"
34 "fmt"
35 "os"
36
37+ "launchpad.net/snappy/logger"
38 "launchpad.net/snappy/priv"
39 "launchpad.net/snappy/snappy"
40
41- "launchpad.net/snappy/logger"
42-
43 "github.com/jessevdk/go-flags"
44 )
45
46-// fixed errors the command can return
47-var ErrRequiresRoot = errors.New("command requires sudo (root)")
48-
49 type options struct {
50 // No global options yet
51 }
52
53 var optionsData options
54
55-var parser = flags.NewParser(&optionsData, flags.Default)
56+var parser = flags.NewParser(&optionsData, flags.HelpFlag|flags.PassDoubleDash)
57
58 func init() {
59 err := logger.ActivateLogger()
60@@ -55,6 +50,7 @@
61 // the CLI user.
62 err = snappy.ErrNeedRoot
63 }
64+ fmt.Fprintln(os.Stderr, err)
65 os.Exit(1)
66 }
67 }

Subscribers

People subscribed via source and target branches