Skip to content

Commit

Permalink
Merge pull request #217 from mhilton/013-dependency-update
Browse files Browse the repository at this point in the history
all: update dependencies
  • Loading branch information
mhilton authored Oct 13, 2020
2 parents 45c1315 + 681f58b commit 66fd825
Show file tree
Hide file tree
Showing 49 changed files with 1,223 additions and 622 deletions.
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
language: go
go_import_path: github.com/juju/charmstore-client
go:
- "1.9"
- "1.10"
before_install:
- "go get github.com/rogpeppe/godeps"
install:
- "godeps -u $GOPATH/src/github.com/juju/charmstore-client/dependencies.tsv"
script: go test ./...
- "1.14.x"
- "1.15.x"
script: GO111MODULE=on go test ./...
services:
- mongodb
2 changes: 1 addition & 1 deletion cmd/charm-ingest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"os"
"strings"

"github.com/juju/charmrepo/v6/csclient"
"github.com/juju/charmstore-client/internal/ingest"
"github.com/juju/gnuflag"
"github.com/juju/persistent-cookiejar"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charmrepo.v4/csclient"
"gopkg.in/macaroon-bakery.v2/httpbakery"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/charm-ingest/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"io"
"strings"

"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/charmstore-client/internal/ingest"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charmrepo.v4/csclient/params"
)

// parseError is the error returned when a whitelist cannot be parsed.
Expand Down
2 changes: 1 addition & 1 deletion cmd/charm-ingest/whitelist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"

qt "github.com/frankban/quicktest"
"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/charmstore-client/internal/ingest"
"gopkg.in/juju/charmrepo.v4/csclient/params"
)

var whiteListTests = []struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/charm/charmcmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charm.v6"

"github.com/juju/charmstore-client/internal/charm"
)

type attachCommand struct {
Expand Down
10 changes: 5 additions & 5 deletions cmd/charm/charmcmd/attach_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ import (
"time"

qt "github.com/frankban/quicktest"
"github.com/juju/charm/v8/resource"
"github.com/juju/charmrepo/v6/csclient"
"github.com/juju/charmrepo/v6/csclient/params"
charmtesting "github.com/juju/charmrepo/v6/testing"
"github.com/juju/juju/juju/osenv"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charm.v6/resource"
"gopkg.in/juju/charmrepo.v4/csclient"
"gopkg.in/juju/charmrepo.v4/csclient/params"
charmtesting "gopkg.in/juju/charmrepo.v4/testing"

"github.com/juju/charmstore-client/cmd/charm/charmcmd"
"github.com/juju/charmstore-client/internal/charm"
)

func TestAttach(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions cmd/charm/charmcmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ import (
"sync"
"time"

"github.com/canonical/candid/candidclient/ussologin"
"github.com/juju/charmrepo/v6/csclient"
"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"github.com/juju/juju/juju/osenv"
"github.com/juju/loggo"
"github.com/juju/persistent-cookiejar"
cookiejar "github.com/juju/persistent-cookiejar"
planscmd "github.com/juju/plans-client/cmd"
termscmd "github.com/juju/terms-client/cmd"
"github.com/juju/usso"
"golang.org/x/net/publicsuffix"
"gopkg.in/errgo.v1"
charm "gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient"
"gopkg.in/juju/charmrepo.v4/csclient/params"
esform "gopkg.in/juju/environschema.v1/form"
"gopkg.in/juju/idmclient.v1/ussologin"
"gopkg.in/juju/worker.v1"
"gopkg.in/macaroon-bakery.v2/httpbakery"
"gopkg.in/macaroon-bakery.v2/httpbakery/agent"

"github.com/juju/charmstore-client/internal/charm"
"github.com/juju/charmstore-client/internal/iomon"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/charm/charmcmd/cmd_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (

qt "github.com/frankban/quicktest"
"github.com/google/go-cmp/cmp"
"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/gnuflag"
"github.com/juju/loggo"
"gopkg.in/juju/charmrepo.v4/csclient/params"
)

var authFlagTests = []struct {
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestChannelDevelopmentDeprecated(t *testing.T) {
defer c.Done()
w := &testWriter{}
loggo.RegisterWriter("test", w)
c.Defer(loggo.ResetWriters)
c.Cleanup(loggo.ResetWriters)

ch := parseChannel(c, "development")
c.Assert(ch, qt.Equals, params.EdgeChannel)
Expand Down
41 changes: 25 additions & 16 deletions cmd/charm/charmcmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,27 @@ import (
"path/filepath"
"strings"
"testing"
"time"

"github.com/canonical/candid/candidtest"
qt "github.com/frankban/quicktest"
"github.com/juju/charmrepo/v6/csclient"
"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/juju/juju/osenv"
"github.com/juju/loggo"
"github.com/juju/mgotest"
"github.com/juju/usso"
"github.com/juju/utils"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient"
"gopkg.in/juju/charmrepo.v4/csclient/params"
"gopkg.in/juju/charmstore.v5"
"gopkg.in/juju/idmclient.v1/idmtest"
bakery2u "gopkg.in/macaroon-bakery.v2-unstable/bakery"
"gopkg.in/macaroon-bakery.v2/bakery"
"gopkg.in/macaroon-bakery.v2/httpbakery"
yaml "gopkg.in/yaml.v2"

"github.com/juju/charmstore-client/cmd/charm/charmcmd"
"github.com/juju/charmstore-client/internal/charm"
)

// run runs a charm plugin subcommand with the given arguments,
Expand All @@ -61,7 +62,7 @@ func run(dir string, args ...string) (stdout, stderr string, exitCode int) {
func fakeHome(c *qt.C) {
oldHome := utils.Home()
utils.SetHome(c.Mkdir())
c.Defer(func() {
c.Cleanup(func() {
utils.SetHome(oldHome)
})
err := os.MkdirAll(osenv.JujuXDGDataHomeDir(), 0755)
Expand All @@ -86,7 +87,7 @@ type charmstoreEnv struct {
cookieFile string
client *csclient.Client
serverParams charmstore.ServerParams
discharger *idmtest.Server
discharger *candidtest.Server
}

const minUploadPartSize = 100 * 1024
Expand All @@ -100,27 +101,35 @@ func initCharmstoreEnv(c *qt.C) *charmstoreEnv {
c.Skip(err)
}
c.Assert(err, qt.Equals, nil)
c.Defer(func() {
c.Cleanup(func() {
env.database.Close()
})
env.database.Session.SetSyncTimeout(10 * time.Second)
env.database.Session.SetSocketTimeout(1 * time.Minute)
session := env.database.Session.Copy()
c.Cleanup(func() {
session.Close()
})
db := env.database.Database.With(session)

env.dockerHandler = newDockerHandler()
env.dockerSrv = httptest.NewServer(env.dockerHandler)
c.Defer(env.dockerSrv.Close)
c.Cleanup(env.dockerSrv.Close)
env.dockerAuthHandler = newDockerAuthHandler()
env.dockerAuthServer = httptest.NewServer(env.dockerAuthHandler)
c.Defer(env.dockerAuthServer.Close)
c.Cleanup(env.dockerAuthServer.Close)
env.dockerRegistryHandler = newDockerRegistryHandler(env.dockerAuthServer.URL)
env.dockerRegistry = httptest.NewTLSServer(env.dockerRegistryHandler)
c.Defer(env.dockerRegistry.Close)
c.Cleanup(env.dockerRegistry.Close)

dockerURL, err := url.Parse(env.dockerSrv.URL)
c.Assert(err, qt.Equals, nil)
env.dockerHost = dockerURL.Host

c.Setenv("DOCKER_HOST", env.dockerSrv.URL)

env.discharger = idmtest.NewServer()
c.Defer(env.discharger.Close)
env.discharger = candidtest.NewServer()
c.Cleanup(env.discharger.Close)
env.discharger.AddUser("charmstoreuser")
env.serverParams = charmstore.ServerParams{
AuthUsername: "test-user",
Expand All @@ -133,11 +142,11 @@ func initCharmstoreEnv(c *qt.C) *charmstoreEnv {
DockerRegistryAddress: env.dockerHost,
NoIndexes: true,
}
env.handler, err = charmstore.NewServer(env.database.Database, nil, "", env.serverParams, charmstore.V5)
env.handler, err = charmstore.NewServer(db, nil, "", env.serverParams, charmstore.V5)
c.Assert(err, qt.Equals, nil)
c.Defer(env.handler.Close)
c.Cleanup(env.handler.Close)
env.srv = httptest.NewServer(env.handler)
c.Defer(env.srv.Close)
c.Cleanup(env.srv.Close)
env.client = csclient.New(csclient.Params{
URL: env.srv.URL,
User: env.serverParams.AuthUsername,
Expand Down Expand Up @@ -234,7 +243,7 @@ func (s *cmdSuite) TestServerURLFromEnvContext(c *qt.C) {

// A first call fails.
_, stderr, code := run(c.Mkdir(), "show", "--list")
c.Assert(stderr, qt.Matches, "ERROR cannot get metadata endpoints: Get invalid-url/v5/meta/: .*\n")
c.Assert(stderr, qt.Matches, "ERROR cannot get metadata endpoints: Get \"invalid-url/v5/meta/\": .*\n")
c.Assert(code, qt.Equals, 1)

// After setting the JUJU_CHARMSTORE variable, the call succeeds.
Expand Down
7 changes: 4 additions & 3 deletions cmd/charm/charmcmd/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ package charmcmd
import (
"strings"

"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"github.com/juju/names"
"github.com/juju/names/v4"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient/params"

"github.com/juju/charmstore-client/internal/charm"
)

type grantCommand struct {
Expand Down
26 changes: 11 additions & 15 deletions cmd/charm/charmcmd/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

qt "github.com/frankban/quicktest"
"github.com/google/go-cmp/cmp/cmpopts"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient"
"gopkg.in/juju/charmrepo.v4/csclient/params"
"github.com/juju/charmrepo/v6/csclient"
"github.com/juju/charmrepo/v6/csclient/params"

"github.com/juju/charmstore-client/internal/charm"
"github.com/juju/charmstore-client/internal/entitytesting"
)

Expand Down Expand Up @@ -276,36 +276,32 @@ func (s *grantSuite) TestSuccessfulWithChannel(c *qt.C) {
c.Assert(s.getWritePerms(c, url), qt.DeepEquals, []string{"foo"})
}

func mustGetPerms(client *csclient.Client, id *charm.URL) params.PermResponse {
func assertGetPerms(c *qt.C, client *csclient.Client, id *charm.URL) params.PermResponse {
var grant params.PermResponse
path := "/" + id.Path() + "/meta/perm"
err := client.Get(path, &grant)
if err != nil {
panic(err)
}
c.Assert(err, qt.IsNil)
return grant
}

func mustSetPerms(client *csclient.Client, key string, id *charm.URL, p []string) {
func assertSetPerms(c *qt.C, client *csclient.Client, key string, id *charm.URL, p []string) {
path := "/" + id.Path() + "/meta/perm/" + key
err := client.Put(path, p)
if err != nil {
panic(err)
}
c.Assert(err, qt.IsNil)
}

func (s *grantSuite) getReadPerms(c *qt.C, id *charm.URL) []string {
return mustGetPerms(s.client, id).Read
return assertGetPerms(c, s.client, id).Read
}

func (s *grantSuite) getWritePerms(c *qt.C, id *charm.URL) []string {
return mustGetPerms(s.client, id).Write
return assertGetPerms(c, s.client, id).Write
}

func (s *grantSuite) setReadPerms(c *qt.C, id *charm.URL, p []string) {
mustSetPerms(s.client, "read", id, p)
assertSetPerms(c, s.client, "read", id, p)
}

func (s *grantSuite) setWritePerms(c *qt.C, id *charm.URL, p []string) {
mustSetPerms(s.client, "write", id, p)
assertSetPerms(c, s.client, "write", id, p)
}
2 changes: 1 addition & 1 deletion cmd/charm/charmcmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"net/url"
"strings"

"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charmrepo.v4/csclient/params"
)

type listCommand struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/charm/charmcmd/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"testing"

qt "github.com/frankban/quicktest"
"gopkg.in/juju/charm.v6"

"github.com/juju/charmstore-client/internal/charm"
"github.com/juju/charmstore-client/internal/entitytesting"
)

Expand All @@ -29,7 +29,7 @@ func (s *listSuite) TestInvalidServerURL(c *qt.C) {
stdout, stderr, exitCode := run(c.Mkdir(), "list")
c.Assert(stdout, qt.Equals, "")
c.Assert(exitCode, qt.Equals, 1)
c.Assert(stderr, qt.Equals, "ERROR cannot retrieve identity: parse #%zz/v5/whoami: invalid URL escape \"%zz\"\n")
c.Assert(stderr, qt.Equals, "ERROR cannot retrieve identity: parse \"#%zz/v5/whoami\": invalid URL escape \"%zz\"\n")
}

func (s *listSuite) TestListUserProvided(c *qt.C) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/charm/charmcmd/listresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
"io"
"text/tabwriter"

"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient/params"

"github.com/juju/charmstore-client/internal/charm"
)

var listResourcesInfo = cmd.Info{
Expand Down
7 changes: 4 additions & 3 deletions cmd/charm/charmcmd/listresources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"testing"

qt "github.com/frankban/quicktest"
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v4/csclient/params"
charmtesting "gopkg.in/juju/charmrepo.v4/testing"
"github.com/juju/charmrepo/v6/csclient/params"
charmtesting "github.com/juju/charmrepo/v6/testing"

"github.com/juju/charmstore-client/internal/charm"
)

func TestListResources(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/charm/charmcmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
package charmcmd

import (
"github.com/juju/charmrepo/v6/csclient/params"
"github.com/juju/cmd"
"github.com/juju/gnuflag"
"gopkg.in/errgo.v1"
"gopkg.in/juju/charmrepo.v4/csclient/params"
)

type loginCommand struct {
Expand Down
Loading

0 comments on commit 66fd825

Please sign in to comment.