Merge lp:~stevenwilkin/snapweb/add-remove-snaps-via-api into lp:~snappy-dev/snapweb/trunk

Proposed by Steven Wilkin
Status: Merged
Approved by: Federico Gimenez
Approved revision: 180
Merged at revision: 178
Proposed branch: lp:~stevenwilkin/snapweb/add-remove-snaps-via-api
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 823 lines (+302/-310)
10 files modified
snappy/common_test.go (+8/-0)
snappy/converge.go (+23/-56)
snappy/converge_test.go (+11/-11)
snappy/handlers.go (+3/-10)
snappy/handlers_test.go (+0/-2)
snappy/snapd_client.go (+2/-0)
statustracker/statustracker.go (+134/-0)
statustracker/statustracker_test.go (+121/-0)
webprogress/meter.go (+0/-159)
webprogress/progress.go (+0/-72)
To merge this branch: bzr merge lp:~stevenwilkin/snapweb/add-remove-snaps-via-api
Reviewer Review Type Date Requested Status
Martin Albisetti (community) Approve
Review via email: mp+288437@code.launchpad.net

Commit message

Add and remove snaps via the snapd API

Description of the change

Add and remove snaps via the snapd API.

Includes a workaround to keep track of which snaps are being added/removed which will be excised when progress of background operations can be communicated via the API.

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (3.7 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
github.com/davecheney/gmx
github.com/miekg/dns
github.com/gorilla/context
github.com/gorilla/mux
github.com/ubuntu-core/snappy/dirs
github.com/ubuntu-core/snappy/logger
github.com/ubuntu-core/snappy/helpers
github.com/davecheney/mdns
launchpad.net/webdm/avahi
golang.org/x/crypto/cast5
golang.org/x/crypto/openpgp/elgamal
golang.org/x/crypto/openpgp/errors
golang.org/x/crypto/openpgp/s2k
gopkg.in/yaml.v2
golang.org/x/crypto/openpgp/packet
github.com/ubuntu-core/snappy/asserts
github.com/ubuntu-core/snappy/snap
github.com/ubuntu-core/snappy/arch
github.com/ubuntu-core/snappy/systemd
github.com/ubuntu-core/snappy/client
github.com/ubuntu-core/snappy/coreconfig
github.com/gosexy/gettext
github.com/ubuntu-core/snappy/oauth
github.com/mvo5/goconfigparser
github.com/mvo5/uboot-go/uenv
github.com/ubuntu-core/snappy/partition
github.com/ubuntu-core/snap...

Read more...

Revision history for this message
Steven Wilkin (stevenwilkin) wrote :

retest this please

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
Building
Running tests from /tmp/tmp.AGdfepCKxx/src/launchpad.net/webdm
=== RUN Test
OK: 4 passed
--- PASS: Test (0.01s)
PASS
coverage: 60.0% of statements
ok launchpad.net/webdm/avahi 0.030s coverage: 60.0% of statements
? launchpad.net/webdm/cmd/snappyd [no test files]
=== RUN Test
WARNING: cannot create /tmp/check-3551783473842660955/1/badDataPath/icons
OK: 17 passed
--- PASS: Test (0.01s)
PASS
coverage: 46.8% of statements
ok launchpad.net/webdm/snappy 0.019s coverage: 46.8% of statements
=== RUN Test

----------------------------------------------------------------------
FAIL: statustracker_test.go:96: StatusTrackerSuite.TestTrackInstallExpiry

statustracker_test.go:105:
    c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
... obtained string = "installing"
... expected string = "uninstalled"

OOPS: 7 passed, 1 FAILED
--- FAIL: Test (0.51s)
FAIL
coverage: 100.0% of statements
FAIL launchpad.net/webdm/statustracker 0.517s

# 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/we...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
Building
Running tests from /tmp/tmp.QdyEV1gFim/src/launchpad.net/webdm
=== RUN Test
OK: 4 passed
--- PASS: Test (0.01s)
PASS
coverage: 60.0% of statements
ok launchpad.net/webdm/avahi 0.023s coverage: 60.0% of statements
? launchpad.net/webdm/cmd/snappyd [no test files]
=== RUN Test
WARNING: cannot create /tmp/check-38914096932556278/1/badDataPath/icons
OK: 17 passed
--- PASS: Test (0.01s)
PASS
coverage: 46.8% of statements
ok launchpad.net/webdm/snappy 0.022s coverage: 46.8% of statements
=== RUN Test

----------------------------------------------------------------------
FAIL: statustracker_test.go:96: StatusTrackerSuite.TestTrackInstallExpiry

statustracker_test.go:105:
    c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
... obtained string = "installing"
... expected string = "uninstalled"

OOPS: 7 passed, 1 FAILED
--- FAIL: Test (0.51s)
FAIL
coverage: 100.0% of statements
FAIL launchpad.net/webdm/statustracker 0.518s

# 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/webd...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.7 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
update github.com/davecheney/gmx failed; trying to fetch newer version
update github.com/davecheney/mdns failed; trying to fetch newer version
update github.com/gorilla/context failed; trying to fetch newer version
update github.com/gosexy/gettext failed; trying to fetch newer version
update github.com/mvo5/uboot-go failed; trying to fetch newer version
update gopkg.in/check.v1 failed; trying to fetch newer version
update golang.org/x/crypto failed; trying to fetch newer version
update github.com/cheggaaa/pb failed; trying to fetch newer version
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
update github.com/miekg/dns failed; trying to fetch newer version
update gopkg.in/yaml.v2 failed; trying to fetch newer version
1 repositories updated; 12 failed

# 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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
godeps: cannot update "/tmp/tmp.3NhTSnXJMS/src/github.com/ubuntu-core/snappy": cannot create repo: Cloning into '/tmp/tmp.3NhTSnXJMS/src/github.com/ubuntu-core/snappy'...
error: unable to create file interfaces/builtin/system_observe_test.go (No space left on device)
error: unable to create file interfaces/builtin/timeserver_control.go (No space left on device)
error: unable to create file interfaces/builtin/timeserver_control_test.go (No space left on device)
error: unable to create file interfaces/builtin/timezone_control.go (No space left on device)
error: unable to create file interfaces/builtin/timezone_control_test.go (No space left on device)
error: unable to create file interfaces/builtin/unity7.go (No space left on device)
error: unable to create file interfaces/builtin/unity7_test.go (No space left on device)
error: unable to create file interfaces/builtin/x11.go (No space left on device)
error: unable to create file interfaces/builtin/x11_test.go (No space left on device)
error: unable to create file interfaces/core.go (No space left on device)
error: unable to create file interfaces/core_test.go (No space left on device)
fatal: cannot create directory at 'interfaces/dbus': No space left on device
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
godeps: cannot update "/tmp/tmp.3NhTSnXJMS/src/github.com/davecheney/gmx": cannot create repo: fatal: could not create work tree dir '/tmp/tmp.3NhTSnXJMS/src/github.com/davecheney/gmx'.: No space left on device
godeps: cannot update "/tmp/tmp.3NhTSnXJMS/src/github.com/davecheney/mdns": cannot create repo: fatal: co...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (3.9 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
update github.com/miekg/dns failed; trying to fetch newer version
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
update github.com/mvo5/uboot-go failed; trying to fetch newer version
update golang.org/x/crypto failed; trying to fetch newer version
update gopkg.in/check.v1 failed; trying to fetch newer version
update github.com/cheggaaa/pb failed; trying to fetch newer version
update github.com/davecheney/gmx failed; trying to fetch newer version
update github.com/davecheney/mdns failed; trying to fetch newer version
update github.com/gorilla/context failed; trying to fetch newer version
update gopkg.in/yaml.v2 failed; trying to fetch newer version
update github.com/gorilla/mux failed; trying to fetch newer version
1 repositories updated; 12 failed

# 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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/ubuntu-core/snappy": cannot create repo: Cloning into '/tmp/tmp.AGTotcVxgl/src/github.com/ubuntu-core/snappy'...
error: unable to create file integration-tests/data/snaps/basic-binaries/bin/success (No space left on device)
fatal: cannot create directory at 'integration-tests/data/snaps/basic-binaries/meta': No space left on device
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/miekg/dns": cannot create repo: fatal: could not create work tree dir '/tmp/tmp.AGTotcVxgl/src/github.com/miekg/dns'.: No space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/mvo5/goconfigparser": cannot create repo: mkdir /tmp/tmp.AGTotcVxgl/src/github.com/mvo5/: no space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/mvo5/uboot-go": cannot create repo: mkdir /tmp/tmp.AGTotcVxgl/src/github.com/mvo5/: no space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/golang.org/x/crypto": cannot create repo: fatal: could not create work tree dir '/tmp/tmp.AGTotcVxgl/src/golang.org/x/crypto'.: No space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/gopkg.in/check.v1": cannot create repo: mkdir /tmp/tmp.AGTotcVxgl/src/gopkg.in/: no space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/cheggaaa/pb": cannot create repo: mkdir /tmp/tmp.AGTotcVxgl/src/github.com/cheggaaa/: no space left on device
godeps: cannot update "/tmp/tmp.AGTotcVxgl/src/github.com/davecheney/gmx": cannot create re...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (5.8 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/davecheney/mdns failed; trying to fetch newer version
update github.com/gosexy/gettext failed; trying to fetch newer version
update github.com/miekg/dns failed; trying to fetch newer version
update github.com/cheggaaa/pb failed; trying to fetch newer version
update github.com/mvo5/uboot-go failed; trying to fetch newer version
update gopkg.in/check.v1 failed; trying to fetch newer version
update github.com/gorilla/mux failed; trying to fetch newer version
update github.com/gorilla/context failed; trying to fetch newer version
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
4 repositories updated; 9 failed

# 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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
godeps: cannot update "/tmp/tmp.1zL22BfGK4/src/github.com/davecheney/mdns": cannot create repo: Cloning into '/tmp/tmp.1zL22BfGK4/src/github.com/davecheney/mdns'...
/tmp/tmp.1zL22BfGK4/src/github.com/davecheney/mdns/.git/objects/info: No space left on device
godeps: cannot update "/tmp/tmp.1zL22BfGK4/src/github.com/gosexy/gettext": cannot create repo: Cloning into '/tmp/tmp.1zL22BfGK4/src/github.com/gosexy/gettext'...
/tmp/tmp.1zL22BfGK4/src/github.com/gosexy/gettext/.git/objects/pack: No space left on device
godeps: cannot update "/tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns": cannot create repo: Cloning into '/tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns'...
error: could not lock config file /tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns/.git/config: No space left on device
error: could not lock config file /tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns/.git/config: No space left on device
error: could not lock config file /tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns/.git/config: No space left on device
fatal: Unable to create temporary file '/tmp/tmp.1zL22BfGK4/src/github.com/miekg/dns/.git/tBEFJ2p': No space left on device
godeps: cannot update "/tmp/tmp.1zL22BfGK4/src/github.com/cheggaaa/pb": cannot create repo: Cloning into '/tmp/tmp.1zL22BfGK4/src/github.com/cheggaaa/pb'...
error: could not lock config file /tmp/tmp.1zL22BfGK4/src/github.com/cheggaaa/pb/.git/config: No space left on device
error: could not lock config file /tmp/tmp.1zL22BfGK4/src/github.com...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.5 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gosexy/gettext failed; trying to fetch newer version
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/mvo5/uboot-go failed; trying to fetch newer version
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
update github.com/gorilla/mux failed; trying to fetch newer version
update github.com/gorilla/context failed; trying to fetch newer version
update golang.org/x/crypto failed; trying to fetch newer version
7 repositories updated; 6 failed

# 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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
godeps: cannot update "/tmp/tmp.JIqQJxg1Cx/src/github.com/gosexy/gettext": cannot create repo: Cloning into '/tmp/tmp.JIqQJxg1Cx/src/github.com/gosexy/gettext'...
error: unable to create temporary file: No space left on device
fatal: failed to write object
fatal: unpack-objects failed
godeps: cannot update "/tmp/tmp.JIqQJxg1Cx/src/github.com/mvo5/uboot-go": cannot create repo: Cloning into '/tmp/tmp.JIqQJxg1Cx/src/github.com/mvo5/uboot-go'...
error: unable to create directory for /tmp/tmp.JIqQJxg1Cx/src/github.com/mvo5/uboot-go/.git/logs/refs/heads/master
fatal: Cannot update the ref 'HEAD'.
Unexpected end of command stream
godeps: cannot update "/tmp/tmp.JIqQJxg1Cx/src/github.com/ubuntu-core/snappy": cannot create repo: Cloning into '/tmp/tmp.JIqQJxg1Cx/src/github.com/ubuntu-core/snappy'...
error: Unable to open /tmp/tmp.JIqQJxg1Cx/src/github.com/ubuntu-core/snappy/.git/HEAD.lock for writing
fatal: Unable to create '/tmp/tmp.JIqQJxg1Cx/src/github.com/ubuntu-core/snappy/.git/refs/heads/master.lock': No space left on device
Unexpected end of command stream
godeps: cannot update "/tmp/tmp.JIqQJxg1Cx/src/github.com/gorilla/mux": cannot create repo: Cloning into '/tmp/tmp.JIqQJxg1Cx/src/github.com/gorilla/mux'...
error: Unable to append to /tmp/tmp.JIqQJ...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (3.6 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
update gopkg.in/check.v1 failed; trying to fetch newer version
update github.com/miekg/dns failed; trying to fetch newer version
update github.com/davecheney/gmx failed; trying to fetch newer version
update github.com/gosexy/gettext failed; trying to fetch newer version
update golang.org/x/crypto failed; trying to fetch newer version
update github.com/mvo5/uboot-go failed; trying to fetch newer version
update gopkg.in/yaml.v2 failed; trying to fetch newer version
5 repositories updated; 8 failed

# 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/webdm
cp -a . $GOPATH/src/launchpad.net/webdm/
cd $GOPATH/src/launchpad.net/webdm

./run-checks
godeps: cannot update "/tmp/tmp.maH2XVR150/src/github.com/ubuntu-core/snappy": cannot create repo: Cloning into '/tmp/tmp.maH2XVR150/src/github.com/ubuntu-core/snappy'...
error: unable to create file gen-coverage.sh (No space left on device)
error: unable to create file get-deps.sh (No space left on device)
fatal: cannot create directory at 'i18n': No space left on device
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
godeps: cannot update "/tmp/tmp.maH2XVR150/src/gopkg.in/check.v1": cannot create repo: fatal: could not create work tree dir '/tmp/tmp.maH2XVR150/src/gopkg.in/check.v1'.: No space left on device
godeps: cannot update "/tmp/tmp.maH2XVR150/src/github.com/miekg/dns": cannot create repo: mkdir /tmp/tmp.maH2XVR150/src/github.com/miekg/: no space left on device
godeps: cannot update "/tmp/tmp.maH2XVR150/src/github.com/davecheney/gmx": cannot create repo: fatal: could not create work tree dir '/tmp/tmp.maH2XVR150/src/github.com/davecheney/gmx'.: No space left on device
godeps: cannot update "/tmp/tmp.maH2XVR150/src/github.com/gosexy/gettext": cannot create repo: mkdir /tmp/tmp.maH2XVR150/src/github.com/gosexy/: no space left on device
godeps: cannot update "/tmp/tmp.maH2XVR150/src/golang.org/x/crypto": cannot create repo: fatal: could not create work tree dir '/tmp...

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (3.7 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/cheggaaa/pb failed; trying to fetch newer version
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
Building

# we always run in a fresh dir in tarmac
export GOPATH=$(mktemp -d)

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

./run-checks
github.com/davecheney/gmx
github.com/miekg/dns
github.com/gorilla/context
github.com/gorilla/mux
github.com/ubuntu-core/snappy/dirs
github.com/ubuntu-core/snappy/logger
github.com/ubuntu-core/snappy/helpers
golang.org/x/crypto/cast5
golang.org/x/crypto/openpgp/elgamal
golang.org/x/crypto/openpgp/errors
golang.org/x/crypto/openpgp/s2k
golang.org/x/crypto/openpgp/packet
github.com/ubuntu-core/snappy/asserts
github.com/davecheney/mdns
launchpad.net/webdm/avahi
github.com/ubuntu-core/snappy/client
gopkg.in/yaml.v2
github.com/ubuntu-core/snappy/arch
github.com/ubuntu-core/snappy/systemd
github.com/gosexy/gettext
github.com/ubuntu-core/snappy/i18n
github.com/ubuntu-core/snappy/oauth
github.com/mvo5/goconfigparser
github.com/ubuntu-core/snappy/snap
github.com/ubuntu-core/snappy/coreconfig
github.com/mvo5/uboot-go/uenv
github.com/ubuntu-core/snappy/partition
github.com/ubuntu-co...

Read more...

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

The `tree_dir` option for the target branch is not a lightweight checkout. Please ask a project administrator to resolve the issue, and try again.

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

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

sed: -e expression #1, char 52: unknown option to `s'

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (4.4 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
Building

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

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

./run-checks
github.com/davecheney/gmx
github.com/miekg/dns
github.com/gorilla/context
github.com/gorilla/mux
github.com/ubuntu-core/snappy/dirs
github.com/ubuntu-core/snappy/logger
github.com/ubuntu-core/snappy/helpers
# github.com/ubuntu-core/snappy/helpers
Assembler messages:
Fatal error: can't create $WORK/github.com/ubuntu-core/snappy/helpers/_obj/_cgo_main.o: No space left on device
golang.org/x/crypto/cast5
go build golang.org/x/crypto/cast5: mkdir /tmp/go-build237809545/golang.org/x: no space left on device
golang.org/x/crypto/openpgp/elgamal
go build golang.org/x/crypto/openpgp/elgamal: mkdir /tmp/go-build237809545/golang.org/x: no space left on device
golang.org/x/crypto/openpgp/errors
go build golang.org/x/crypto/openpgp/errors: mkdir /tmp/go-build237809545/golang.org/x: no space left on device
gopkg.in/yaml.v2
go build gopkg....

Read more...

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (5.1 KiB)

The attempt to merge lp:~stevenwilkin/webdm/add-remove-snaps-via-api into lp:webdm failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update golang.org/x/crypto failed; trying to fetch newer version
golang.org/x/crypto now at 60052bd85f2d91293457e8811b0cf26b773de469
update github.com/davecheney/mdns failed; trying to fetch newer version
github.com/davecheney/mdns now at de174d86a3d3e87bfad9cb66cedd0433380b67b0
update github.com/gorilla/context failed; trying to fetch newer version
github.com/gorilla/context now at 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da
update github.com/gorilla/mux failed; trying to fetch newer version
github.com/gorilla/mux now at e444e69cbd2e2e3e0749a2f3c717cec491552bbf
update github.com/gosexy/gettext failed; trying to fetch newer version
github.com/gosexy/gettext now at 98b7b91596d20b96909e6b60d57411547dd9959c
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/mvo5/uboot-go now at 69978a3e4b05cca9d7cfee489b3453dfed45e72c
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update gopkg.in/check.v1 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update github.com/davecheney/gmx failed; trying to fetch newer version
github.com/davecheney/gmx now at d765420e7fbaccecb2a38cf2a02701fe3e0888a3
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
update github.com/miekg/dns failed; trying to fetch newer version
github.com/miekg/dns now at 5a357a6fc5e85268b929350aa6423e2d56dcc4ff
update github.com/ubuntu-core/snappy failed; trying to fetch newer version
github.com/ubuntu-core/snappy now at 5bcb20229bb884b85144eab0fe5db7aa05a27ebf
Building
Running tests from /mnt/tarmac/tmp/tmp.RkPg752sU4/src/launchpad.net/webdm
=== RUN Test
OK: 4 passed
--- PASS: Test (0.00s)
PASS
coverage: 60.0% of statements
ok launchpad.net/webdm/avahi 0.012s coverage: 60.0% of statements
? launchpad.net/webdm/cmd/snappyd [no test files]
=== RUN Test
WARNING: cannot create /mnt/tarmac/tmp/check-4282530047168441630/1/badDataPath/icons
OK: 17 passed
--- PASS: Test (0.02s)
PASS
coverage: 46.8% of statements
ok launchpad.net/webdm/snappy 0.029s coverage: 46.8% of statements
=== RUN Test
OK: 8 passed
--- PASS: Test (0.41s)
PASS
coverage: 100.0% of statements
ok launchpad.net/webdm/statustracker 0.414s coverage: 100.0% of statements
Running vet
Running lint
Obtaining npm dependencies

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

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

./run-checks
github.com/davecheney/gmx
github.com/miekg/dns
github.com/gorilla/c...

Read more...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'snappy/common_test.go'
--- snappy/common_test.go 2016-02-02 17:51:45 +0000
+++ snappy/common_test.go 2016-04-21 06:04:15 +0000
@@ -85,6 +85,14 @@
85 return snaps, f.err85 return snaps, f.err
86}86}
8787
88func (f *fakeSnapdClient) AddSnap(name string) (string, error) {
89 return "", nil
90}
91
92func (f *fakeSnapdClient) RemoveSnap(name string) (string, error) {
93 return "", nil
94}
95
88var _ snapdClient = (*fakeSnapdClient)(nil)96var _ snapdClient = (*fakeSnapdClient)(nil)
8997
90type fakeSnapdClientServicesNoExternalUI struct {98type fakeSnapdClientServicesNoExternalUI struct {
9199
=== modified file 'snappy/converge.go'
--- snappy/converge.go 2016-02-02 17:51:45 +0000
+++ snappy/converge.go 2016-04-21 06:04:15 +0000
@@ -26,25 +26,22 @@
2626
27 "github.com/ubuntu-core/snappy/client"27 "github.com/ubuntu-core/snappy/client"
28 "github.com/ubuntu-core/snappy/snap"28 "github.com/ubuntu-core/snappy/snap"
29 "github.com/ubuntu-core/snappy/snappy"
30 "launchpad.net/webdm/webprogress"
31)29)
3230
33type snapPkg struct {31type snapPkg struct {
34 ID string `json:"id"`32 ID string `json:"id"`
35 Name string `json:"name"`33 Name string `json:"name"`
36 Origin string `json:"origin"`34 Origin string `json:"origin"`
37 Version string `json:"version"`35 Version string `json:"version"`
38 Description string `json:"description"`36 Description string `json:"description"`
39 Icon string `json:"icon"`37 Icon string `json:"icon"`
40 Status webprogress.Status `json:"status"`38 Status string `json:"status"`
41 Message string `json:"message,omitempty"`39 Message string `json:"message,omitempty"`
42 IsError bool `json:"-"`40 Progress float64 `json:"progress,omitempty"`
43 Progress float64 `json:"progress,omitempty"`41 InstalledSize int64 `json:"installed_size,omitempty"`
44 InstalledSize int64 `json:"installed_size,omitempty"`42 DownloadSize int64 `json:"download_size,omitempty"`
45 DownloadSize int64 `json:"download_size,omitempty"`43 Type snap.Type `json:"type,omitempty"`
46 Type snap.Type `json:"type,omitempty"`44 UIPort uint64 `json:"ui_port,omitempty"`
47 UIPort uint64 `json:"ui_port,omitempty"`
48}45}
4946
50type response struct {47type response struct {
@@ -77,40 +74,28 @@
77 return snapPkgs, nil74 return snapPkgs, nil
78}75}
7976
80func (h *Handler) doRemovePackage(progress *webprogress.WebProgress, ID string) {
81 pkgName := strings.Split(ID, ".")[0]
82
83 err := snappy.Remove(pkgName, 0, progress)
84 progress.ErrorChan <- err
85 close(progress.ErrorChan)
86}
87
88func (h *Handler) removePackage(ID string) error {77func (h *Handler) removePackage(ID string) error {
89 progress, err := h.statusTracker.Add(ID, webprogress.OperationRemove)78 snap, err := h.snapdClient.Snap(ID)
90 if err != nil {79 if err != nil {
91 return err80 return err
92 }81 }
9382
94 go h.doRemovePackage(progress, ID)83 h.statusTracker.TrackUninstall(snap)
9584
96 return nil85 _, err = h.snapdClient.RemoveSnap(ID)
97}86 return err
98
99func (h *Handler) doInstallPackage(progress *webprogress.WebProgress, ID string) {
100 _, err := snappy.Install(ID, 0, progress)
101 progress.ErrorChan <- err
102 close(progress.ErrorChan)
103}87}
10488
105func (h *Handler) installPackage(ID string) error {89func (h *Handler) installPackage(ID string) error {
106 progress, err := h.statusTracker.Add(ID, webprogress.OperationInstall)90 snap, err := h.snapdClient.Snap(ID)
107 if err != nil {91 if err != nil {
108 return err92 return err
109 }93 }
11094
111 go h.doInstallPackage(progress, ID)95 h.statusTracker.TrackInstall(snap)
11296
113 return nil97 _, err = h.snapdClient.AddSnap(ID)
98 return err
114}99}
115100
116func hasPortInformation(snapQ *client.Snap) bool {101func hasPortInformation(snapQ *client.Snap) bool {
@@ -126,6 +111,7 @@
126 Version: snapQ.Version,111 Version: snapQ.Version,
127 Description: snapQ.Description,112 Description: snapQ.Description,
128 Type: snap.Type(snapQ.Type),113 Type: snap.Type(snapQ.Type),
114 Status: h.statusTracker.Status(snapQ),
129 }115 }
130116
131 if hasPortInformation(snapQ) {117 if hasPortInformation(snapQ) {
@@ -150,25 +136,6 @@
150 snap.DownloadSize = snapQ.DownloadSize136 snap.DownloadSize = snapQ.DownloadSize
151 }137 }
152138
153 if stat, ok := h.statusTracker.Get(snap.ID); ok {
154 snap.Status = stat.Status
155 if stat.Done() {
156 defer h.statusTracker.Remove(snap.ID)
157
158 if stat.Error != nil {
159 snap.Message = stat.Error.Error()
160 snap.IsError = true
161 }
162
163 } else {
164 snap.Progress = stat.Progress()
165 }
166 } else if isInstalled {
167 snap.Status = webprogress.StatusInstalled
168 } else {
169 snap.Status = webprogress.StatusUninstalled
170 }
171
172 return snap139 return snap
173}140}
174141
175142
=== modified file 'snappy/converge_test.go'
--- snappy/converge_test.go 2016-02-02 17:51:45 +0000
+++ snappy/converge_test.go 2016-04-21 06:04:15 +0000
@@ -24,7 +24,7 @@
24 "github.com/ubuntu-core/snappy/client"24 "github.com/ubuntu-core/snappy/client"
25 "github.com/ubuntu-core/snappy/snap"25 "github.com/ubuntu-core/snappy/snap"
26 . "gopkg.in/check.v1"26 . "gopkg.in/check.v1"
27 "launchpad.net/webdm/webprogress"27 "launchpad.net/webdm/statustracker"
28)28)
2929
30type PackagePayloadSuite struct {30type PackagePayloadSuite struct {
@@ -36,7 +36,7 @@
3636
37func (s *PackagePayloadSuite) SetUpTest(c *C) {37func (s *PackagePayloadSuite) SetUpTest(c *C) {
38 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())38 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
39 s.h.statusTracker = webprogress.New()39 s.h.statusTracker = statustracker.New()
40 s.c = &fakeSnapdClient{}40 s.c = &fakeSnapdClient{}
41 s.h.setClient(s.c)41 s.h.setClient(s.c)
42}42}
@@ -75,7 +75,7 @@
7575
76func (s *PayloadSuite) SetUpTest(c *C) {76func (s *PayloadSuite) SetUpTest(c *C) {
77 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())77 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
78 s.h.statusTracker = webprogress.New()78 s.h.statusTracker = statustracker.New()
79 s.h.setClient(&fakeSnapdClient{})79 s.h.setClient(&fakeSnapdClient{})
80}80}
8181
@@ -86,7 +86,7 @@
8686
87 c.Check(q.Name, Equals, fakeSnap.Name)87 c.Check(q.Name, Equals, fakeSnap.Name)
88 c.Check(q.Version, Equals, fakeSnap.Version)88 c.Check(q.Version, Equals, fakeSnap.Version)
89 c.Check(q.Status, Equals, webprogress.StatusInstalled)89 c.Check(q.Status, Equals, statustracker.StatusInstalled)
90 c.Check(q.Type, Equals, snap.Type(fakeSnap.Type))90 c.Check(q.Type, Equals, snap.Type(fakeSnap.Type))
91 c.Check(q.UIPort, Equals, uint64(0))91 c.Check(q.UIPort, Equals, uint64(0))
92 c.Check(q.Icon, Equals, "/icons/chatroom.ogra_icon.png")92 c.Check(q.Icon, Equals, "/icons/chatroom.ogra_icon.png")
@@ -101,7 +101,7 @@
101101
102 c.Assert(q.Name, Equals, fakeSnap.Name)102 c.Assert(q.Name, Equals, fakeSnap.Name)
103 c.Assert(q.Version, Equals, fakeSnap.Version)103 c.Assert(q.Version, Equals, fakeSnap.Version)
104 c.Assert(q.Status, Equals, webprogress.StatusInstalled)104 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
105 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))105 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
106 c.Assert(q.UIPort, Equals, uint64(0))106 c.Assert(q.UIPort, Equals, uint64(0))
107}107}
@@ -114,7 +114,7 @@
114114
115 c.Assert(q.Name, Equals, fakeSnap.Name)115 c.Assert(q.Name, Equals, fakeSnap.Name)
116 c.Assert(q.Version, Equals, fakeSnap.Version)116 c.Assert(q.Version, Equals, fakeSnap.Version)
117 c.Assert(q.Status, Equals, webprogress.StatusInstalled)117 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
118 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))118 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
119 c.Assert(q.UIPort, Equals, uint64(1024))119 c.Assert(q.UIPort, Equals, uint64(1024))
120}120}
@@ -129,18 +129,18 @@
129129
130 c.Assert(q.Name, Equals, fakeSnap.Name)130 c.Assert(q.Name, Equals, fakeSnap.Name)
131 c.Assert(q.Version, Equals, fakeSnap.Version)131 c.Assert(q.Version, Equals, fakeSnap.Version)
132 c.Assert(q.Status, Equals, webprogress.StatusInstalled)132 c.Assert(q.Status, Equals, statustracker.StatusInstalled)
133 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))133 c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
134 c.Assert(q.UIPort, Equals, uint64(0))134 c.Assert(q.UIPort, Equals, uint64(0))
135}135}
136136
137func (s *PayloadSuite) TestPayloadSnapInstalling(c *C) {137func (s *PayloadSuite) TestPayloadSnapInstalling(c *C) {
138 fakeSnap := newDefaultSnap()138 fakeSnap := newDefaultSnap()
139 fakeSnapID := fakeSnap.Name + "." + fakeSnap.Origin139 fakeSnap.Status = client.StatusNotInstalled
140 s.h.statusTracker.Add(fakeSnapID, webprogress.OperationInstall)140 s.h.statusTracker.TrackInstall(fakeSnap)
141141
142 payload := s.h.snapToPayload(fakeSnap)142 payload := s.h.snapToPayload(fakeSnap)
143 c.Assert(payload.Status, Equals, webprogress.StatusInstalling)143 c.Assert(payload.Status, Equals, statustracker.StatusInstalling)
144}144}
145145
146type AllPackagesSuite struct {146type AllPackagesSuite struct {
@@ -152,7 +152,7 @@
152152
153func (s *AllPackagesSuite) SetUpTest(c *C) {153func (s *AllPackagesSuite) SetUpTest(c *C) {
154 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())154 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
155 s.h.statusTracker = webprogress.New()155 s.h.statusTracker = statustracker.New()
156 s.c = &fakeSnapdClient{}156 s.c = &fakeSnapdClient{}
157 s.h.setClient(s.c)157 s.h.setClient(s.c)
158}158}
159159
=== modified file 'snappy/handlers.go'
--- snappy/handlers.go 2016-02-23 16:00:47 +0000
+++ snappy/handlers.go 2016-04-21 06:04:15 +0000
@@ -26,21 +26,21 @@
2626
27 "github.com/ubuntu-core/snappy/client"27 "github.com/ubuntu-core/snappy/client"
28 "github.com/ubuntu-core/snappy/snappy"28 "github.com/ubuntu-core/snappy/snappy"
29 "launchpad.net/webdm/webprogress"29 "launchpad.net/webdm/statustracker"
3030
31 "github.com/gorilla/mux"31 "github.com/gorilla/mux"
32)32)
3333
34// Handler implements snappy's packages api.34// Handler implements snappy's packages api.
35type Handler struct {35type Handler struct {
36 statusTracker *webprogress.StatusTracker36 statusTracker *statustracker.StatusTracker
37 snapdClient snapdClient37 snapdClient snapdClient
38}38}
3939
40// NewHandler creates an instance that implements snappy's packages api.40// NewHandler creates an instance that implements snappy's packages api.
41func NewHandler() *Handler {41func NewHandler() *Handler {
42 return &Handler{42 return &Handler{
43 statusTracker: webprogress.New(),43 statusTracker: statustracker.New(),
44 snapdClient: client.New(nil),44 snapdClient: client.New(nil),
45 }45 }
46}46}
@@ -92,10 +92,6 @@
92 return92 return
93 }93 }
9494
95 if payload.IsError {
96 w.WriteHeader(http.StatusInternalServerError)
97 }
98
99 if err := enc.Encode(payload); err != nil {95 if err := enc.Encode(payload); err != nil {
100 w.WriteHeader(http.StatusInternalServerError)96 w.WriteHeader(http.StatusInternalServerError)
101 // give up on json97 // give up on json
@@ -155,9 +151,6 @@
155 case snappy.ErrAlreadyInstalled:151 case snappy.ErrAlreadyInstalled:
156 status = http.StatusOK152 status = http.StatusOK
157 msg = "Installed"153 msg = "Installed"
158 case webprogress.ErrPackageInstallInProgress:
159 status = http.StatusBadRequest
160 msg = "Operation in progress"
161 case snappy.ErrPackageNotFound:154 case snappy.ErrPackageNotFound:
162 status = http.StatusNotFound155 status = http.StatusNotFound
163 msg = "Package not found"156 msg = "Package not found"
164157
=== modified file 'snappy/handlers_test.go'
--- snappy/handlers_test.go 2016-02-02 17:50:38 +0000
+++ snappy/handlers_test.go 2016-04-21 06:04:15 +0000
@@ -23,7 +23,6 @@
23 "os"23 "os"
2424
25 "github.com/ubuntu-core/snappy/client"25 "github.com/ubuntu-core/snappy/client"
26 "launchpad.net/webdm/webprogress"
2726
28 . "gopkg.in/check.v1"27 . "gopkg.in/check.v1"
29)28)
@@ -37,7 +36,6 @@
3736
38func (s *HandlersSuite) SetUpTest(c *C) {37func (s *HandlersSuite) SetUpTest(c *C) {
39 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())38 os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
40 s.h.statusTracker = webprogress.New()
41 s.c = &fakeSnapdClient{}39 s.c = &fakeSnapdClient{}
42 s.h.setClient(s.c)40 s.h.setClient(s.c)
43}41}
4442
=== modified file 'snappy/snapd_client.go'
--- snappy/snapd_client.go 2016-02-02 17:50:37 +0000
+++ snappy/snapd_client.go 2016-04-21 06:04:15 +0000
@@ -26,4 +26,6 @@
26 Services(pkg string) (map[string]*client.Service, error)26 Services(pkg string) (map[string]*client.Service, error)
27 Snap(name string) (*client.Snap, error)27 Snap(name string) (*client.Snap, error)
28 FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error)28 FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error)
29 AddSnap(name string) (string, error)
30 RemoveSnap(name string) (string, error)
29}31}
3032
=== added directory 'statustracker'
=== added file 'statustracker/statustracker.go'
--- statustracker/statustracker.go 1970-01-01 00:00:00 +0000
+++ statustracker/statustracker.go 2016-04-21 06:04:15 +0000
@@ -0,0 +1,134 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18// Package statustracker enables the tracking of snap installation and removal.
19//
20// Once a snap has been marked as "installing" it will remain in that
21// state until it's status as provided by snapd indicates that it is installed
22// on the system. Similarly for removing snaps. Status lifecycle is thus:
23//
24// "uninstalled" -> "installing" -> "installed" -> "uninstalling" and repeat
25package statustracker
26
27import (
28 "sync"
29 "time"
30
31 "github.com/ubuntu-core/snappy/client"
32)
33
34const (
35 // StatusInstalled indicates the package is in an installed state.
36 StatusInstalled = "installed"
37 // StatusUninstalled indicates the package is in an uninstalled state.
38 StatusUninstalled = "uninstalled"
39 // StatusInstalling indicates the package is in an installing state.
40 StatusInstalling = "installing"
41 // StatusUninstalling indicates the package is in an uninstalling state.
42 StatusUninstalling = "uninstalling"
43)
44
45var trackerDuration = 1 * time.Minute
46
47// StatusTracker tracks statuses
48type StatusTracker struct {
49 sync.Mutex
50 statuses map[string]string
51}
52
53// New returns a new status tracker
54func New() *StatusTracker {
55 return &StatusTracker{
56 statuses: make(map[string]string),
57 }
58}
59
60// Status returns the status of the given snap
61func (s *StatusTracker) Status(snap *client.Snap) string {
62 s.Lock()
63 defer s.Unlock()
64
65 status, ok := s.statuses[snapID(snap)]
66 if !ok {
67 return translateStatus(snap)
68 }
69
70 if hasCompleted(status, snap) {
71 delete(s.statuses, snapID(snap))
72 return translateStatus(snap)
73 }
74
75 return status
76}
77
78// TrackInstall tracks the installation of the given snap
79func (s *StatusTracker) TrackInstall(snap *client.Snap) {
80 if isInstalled(snap) {
81 return
82 }
83
84 s.trackOperation(snapID(snap), StatusInstalling)
85}
86
87func (s *StatusTracker) trackOperation(id, operation string) {
88 s.Lock()
89 defer s.Unlock()
90
91 s.statuses[id] = operation
92
93 go func() {
94 <-time.After(trackerDuration)
95 s.Lock()
96 delete(s.statuses, id)
97 s.Unlock()
98 }()
99}
100
101// TrackUninstall tracks the removal of the given snap
102func (s *StatusTracker) TrackUninstall(snap *client.Snap) {
103 if !isInstalled(snap) {
104 return
105 }
106
107 s.trackOperation(snapID(snap), StatusUninstalling)
108}
109
110func snapID(s *client.Snap) string {
111 return s.Name + "." + s.Origin
112}
113
114func isInstalled(s *client.Snap) bool {
115 return s.Status == client.StatusInstalled || s.Status == client.StatusActive
116}
117
118// translate a status from the snappy world into one webdm understands
119func translateStatus(s *client.Snap) string {
120 if isInstalled(s) {
121 return StatusInstalled
122 }
123
124 return StatusUninstalled
125}
126
127// has the tracked process denoted by status completed?
128func hasCompleted(status string, snap *client.Snap) bool {
129 if status == StatusInstalling {
130 return isInstalled(snap)
131 }
132
133 return !isInstalled(snap)
134}
0135
=== added file 'statustracker/statustracker_test.go'
--- statustracker/statustracker_test.go 1970-01-01 00:00:00 +0000
+++ statustracker/statustracker_test.go 2016-04-21 06:04:15 +0000
@@ -0,0 +1,121 @@
1/*
2 * Copyright (C) 2016 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18package statustracker
19
20import (
21 "testing"
22 "time"
23
24 "github.com/ubuntu-core/snappy/client"
25
26 . "gopkg.in/check.v1"
27)
28
29func Test(t *testing.T) { TestingT(t) }
30
31type StatusTrackerSuite struct {
32 t *StatusTracker
33}
34
35var _ = Suite(&StatusTrackerSuite{})
36
37func (s *StatusTrackerSuite) SetUpTest(c *C) {
38 s.t = New()
39}
40
41func (s *StatusTrackerSuite) TestTranslateStatus(c *C) {
42 tests := []struct {
43 snapStatus string
44 status string
45 }{
46 {client.StatusInstalled, StatusInstalled},
47 {client.StatusActive, StatusInstalled},
48 {client.StatusNotInstalled, StatusUninstalled},
49 {client.StatusRemoved, StatusUninstalled},
50 }
51
52 for _, tt := range tests {
53 snap := &client.Snap{Status: tt.snapStatus}
54 c.Assert(translateStatus(snap), Equals, tt.status)
55 }
56}
57
58func (s *StatusTrackerSuite) TestHasCompleted(c *C) {
59 tests := []struct {
60 status string
61 snapStatus string
62 completed bool
63 }{
64 {StatusInstalling, client.StatusInstalled, true},
65 {StatusInstalling, client.StatusRemoved, false},
66 {StatusUninstalling, client.StatusRemoved, true},
67 {StatusUninstalling, client.StatusActive, false},
68 }
69
70 for _, tt := range tests {
71 snap := &client.Snap{Status: tt.snapStatus}
72 c.Assert(hasCompleted(tt.status, snap), Equals, tt.completed)
73 }
74}
75
76func (s *StatusTrackerSuite) TestUntrackedSnap(c *C) {
77 snap := &client.Snap{Status: client.StatusInstalled}
78 c.Assert(s.t.Status(snap), Equals, StatusInstalled)
79}
80
81func (s *StatusTrackerSuite) TestTrackInstallAlreadyInstalled(c *C) {
82 snap := &client.Snap{Status: client.StatusInstalled}
83 s.t.TrackInstall(snap)
84 c.Assert(s.t.Status(snap), Equals, StatusInstalled)
85}
86
87func (s *StatusTrackerSuite) TestTrackInstall(c *C) {
88 snap := &client.Snap{Status: client.StatusNotInstalled}
89 s.t.TrackInstall(snap)
90 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
91 // installation completes
92 snap.Status = client.StatusActive
93 c.Assert(s.t.Status(snap), Equals, StatusInstalled)
94}
95
96func (s *StatusTrackerSuite) TestTrackInstallExpiry(c *C) {
97 trackerDuration = 200 * time.Millisecond
98
99 snap := &client.Snap{Status: client.StatusNotInstalled}
100 s.t.TrackInstall(snap)
101 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
102
103 // don't track indefinitely if operation fails
104 time.Sleep(trackerDuration * 2)
105 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
106}
107
108func (s *StatusTrackerSuite) TestTrackUninstallNotInstalled(c *C) {
109 snap := &client.Snap{Status: client.StatusNotInstalled}
110 s.t.TrackUninstall(snap)
111 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
112}
113
114func (s *StatusTrackerSuite) TestTrackUninstall(c *C) {
115 snap := &client.Snap{Status: client.StatusInstalled}
116 s.t.TrackUninstall(snap)
117 c.Assert(s.t.Status(snap), Equals, StatusUninstalling)
118 // uninstallation completes
119 snap.Status = client.StatusRemoved
120 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
121}
0122
=== removed file 'webprogress/meter.go'
--- webprogress/meter.go 2015-12-11 15:07:16 +0000
+++ webprogress/meter.go 1970-01-01 00:00:00 +0000
@@ -1,159 +0,0 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18package webprogress
19
20import "github.com/ubuntu-core/snappy/progress"
21
22// Operation indicates the desired operation to perform
23type Operation uint
24
25const (
26 // OperationInstall indicates that a package needs installing
27 OperationInstall Operation = iota
28 // OperationRemove indicates that a package needs uninstalling
29 OperationRemove
30)
31
32// Status indicates the status a package is in.
33type Status string
34
35const (
36 // StatusInstalled indicates the package is in an installed state.
37 StatusInstalled Status = "installed"
38 // StatusUninstalled indicates the package is in an uninstalled state.
39 StatusUninstalled Status = "uninstalled"
40 // StatusInstalling indicates the package is in an installing state.
41 StatusInstalling Status = "installing"
42 // StatusUninstalling indicates the package is in an uninstalling state.
43 StatusUninstalling Status = "uninstalling"
44)
45
46// WebProgress show progress on the terminal
47type WebProgress struct {
48 progress.Meter
49 total float64
50 current float64
51 Status Status
52 statusMessage string
53 notificationMessage string
54 Error error
55 ErrorChan chan error
56 operation Operation
57}
58
59// NewWebProgress returns a new WebProgress type
60func NewWebProgress(op Operation) *WebProgress {
61 var status Status
62 switch op {
63 case OperationInstall:
64 status = StatusInstalling
65 case OperationRemove:
66 status = StatusUninstalling
67 default:
68 panic("Not a valid Operation")
69 }
70
71 t := &WebProgress{
72 ErrorChan: make(chan error),
73 Status: status,
74 operation: op,
75 }
76
77 go func() {
78 err := <-t.ErrorChan
79
80 if err != nil {
81 t.Status = StatusUninstalled
82 t.Error = err
83 } else {
84 var status Status
85 switch op {
86 case OperationInstall:
87 status = StatusInstalled
88 case OperationRemove:
89 status = StatusUninstalled
90 default:
91 panic("Not a valid Operation")
92 }
93 t.Status = status
94 }
95 }()
96
97 return t
98}
99
100// Start starts showing progress
101func (t *WebProgress) Start(pkgName string, total float64) {
102 t.total = total
103}
104
105// Set sets the progress to the current value
106func (t *WebProgress) Set(current float64) {
107 t.current = current
108}
109
110// SetTotal set the total steps needed
111func (t *WebProgress) SetTotal(total float64) {
112 t.total = total
113}
114
115// Finished stops displaying the progress
116func (t *WebProgress) Finished() {
117}
118
119// Done returns a boolean value indicating that the progress report
120// has finished with no concerns if it was succesfull or not.
121func (t *WebProgress) Done() bool {
122 return t.Status == StatusInstalled || t.Status == StatusUninstalled
123}
124
125// Write is there so that progress can implement a Writer and can be
126// used to display progress of io operations
127//
128// This is not needed for web progress.
129func (t *WebProgress) Write(p []byte) (n int, err error) {
130 t.current += float64(len(p))
131 return len(p), nil
132}
133
134// Spin advances a spinner, i.e. can be used to show progress for operations
135// that have a unknown duration
136func (t *WebProgress) Spin(msg string) {
137 t.statusMessage = msg
138}
139
140// Agreed asks the user whether they agree to the given license text
141func (t *WebProgress) Agreed(intro, license string) bool {
142 // TODO needs implementation
143 return true
144}
145
146// Notify the user of miscelaneous events
147func (t *WebProgress) Notify(msg string) {
148 // TODO needs implementation producer/consumer
149 t.notificationMessage = msg
150}
151
152// Progress returns the current progress
153func (t *WebProgress) Progress() float64 {
154 if t.total == 0 {
155 return 0
156 }
157
158 return t.current * 100 / t.total
159}
1600
=== removed file 'webprogress/progress.go'
--- webprogress/progress.go 2015-05-06 14:41:13 +0000
+++ webprogress/progress.go 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18package webprogress
19
20import (
21 "errors"
22 "sync"
23)
24
25var (
26 // ErrPackageInstallInProgress indicates that installation of the package is
27 // already in progress.
28 ErrPackageInstallInProgress = errors.New("package installion in progress")
29)
30
31// StatusTracker holds the state of all operations that require progress information.
32type StatusTracker struct {
33 status map[string]*WebProgress
34 l sync.Mutex
35}
36
37// New creates a new Status.
38func New() *StatusTracker {
39 return &StatusTracker{status: make(map[string]*WebProgress)}
40}
41
42// Add add pkg to the list of progresses to track, it is idempotent
43func (i *StatusTracker) Add(pkg string, op Operation) (*WebProgress, error) {
44 i.l.Lock()
45 defer i.l.Unlock()
46
47 if _, ok := i.status[pkg]; ok {
48 return nil, ErrPackageInstallInProgress
49 }
50
51 i.status[pkg] = NewWebProgress(op)
52
53 return i.status[pkg], nil
54}
55
56// Remove removes pkg to the list of progresses to track, it is a no op
57// to remove multiple times.
58func (i *StatusTracker) Remove(pkg string) {
59 i.l.Lock()
60 defer i.l.Unlock()
61
62 delete(i.status, pkg)
63}
64
65// Get returns a *WebProgress corresponding to pkg or nil if not tracked.
66func (i *StatusTracker) Get(pkg string) (*WebProgress, bool) {
67 i.l.Lock()
68 defer i.l.Unlock()
69
70 w, ok := i.status[pkg]
71 return w, ok
72}

Subscribers

People subscribed via source and target branches