Skip to content

Commit

Permalink
misc: Use go mod
Browse files Browse the repository at this point in the history
Update package imports to reflect go-mod dependency versions.

Update to etcd/v3. etcd upstream versioning doesn't play well with Go
modules or newer versions of gRPC. v3.5.0 and newer follow Go semantic
versioning guidelines and resolves most versioning conflicts with
co-dependent libraries. There are many issues surrounding this, see [1].

Fix test-examples for Go Modules. Previously this test script symlinked
the examples source directory outside of the mgmt tree, but this doesn't
work with Go modules. Switch to building the example programs in-place,
and simplify the script to reduce the amount of superfluous operations.

Fixes a couple shellcheck warnings in test-examples too.

[1]: etcd-io/etcd#12124

Signed-off-by: Joe Groocock <me@frebib.net>
  • Loading branch information
guilhem authored and frebib committed May 26, 2021
1 parent 19f4047 commit b709a86
Show file tree
Hide file tree
Showing 58 changed files with 1,579 additions and 149 deletions.
36 changes: 0 additions & 36 deletions .gitmodules

This file was deleted.

8 changes: 4 additions & 4 deletions engine/resources/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

sdbus "github.com/coreos/go-systemd/dbus"
"github.com/coreos/go-systemd/unit"
systemdUtil "github.com/coreos/go-systemd/util"
"github.com/godbus/dbus"
sdbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/coreos/go-systemd/v22/unit"
systemdUtil "github.com/coreos/go-systemd/v22/util"
"github.com/godbus/dbus/v5"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

"github.com/godbus/dbus"
"github.com/godbus/dbus/v5"
)

func init() {
Expand Down
8 changes: 4 additions & 4 deletions engine/resources/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

sdbus "github.com/coreos/go-systemd/dbus"
"github.com/coreos/go-systemd/unit"
systemdUtil "github.com/coreos/go-systemd/util"
sdbus "github.com/coreos/go-systemd/v22/dbus"
"github.com/coreos/go-systemd/v22/unit"
systemdUtil "github.com/coreos/go-systemd/v22/util"
fstab "github.com/deniswernert/go-fstab"
"github.com/godbus/dbus"
"github.com/godbus/dbus/v5"
"golang.org/x/sys/unix"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/resources/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/purpleidea/mgmt/engine"
"github.com/purpleidea/mgmt/engine/traits"

"github.com/coreos/go-systemd/journal"
"github.com/coreos/go-systemd/v22/journal"
)

func init() {
Expand Down
8 changes: 4 additions & 4 deletions engine/resources/nspawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

systemdDbus "github.com/coreos/go-systemd/dbus"
machined "github.com/coreos/go-systemd/machine1"
systemdUtil "github.com/coreos/go-systemd/util"
"github.com/godbus/dbus"
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
machined "github.com/coreos/go-systemd/v22/machine1"
systemdUtil "github.com/coreos/go-systemd/v22/util"
"github.com/godbus/dbus/v5"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion engine/resources/packagekit/packagekit.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

"github.com/godbus/dbus"
"github.com/godbus/dbus/v5"
)

// global tweaks of verbosity and code path
Expand Down
6 changes: 3 additions & 3 deletions engine/resources/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

systemd "github.com/coreos/go-systemd/dbus" // change namespace
systemdUtil "github.com/coreos/go-systemd/util"
"github.com/godbus/dbus" // namespace collides with systemd wrapper
systemd "github.com/coreos/go-systemd/v22/dbus" // change namespace
systemdUtil "github.com/coreos/go-systemd/v22/util"
"github.com/godbus/dbus/v5" // namespace collides with systemd wrapper
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion engine/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/purpleidea/mgmt/lang/types"
"github.com/purpleidea/mgmt/util/errwrap"

"github.com/godbus/dbus"
"github.com/godbus/dbus/v5"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions etcd/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3" // "clientv3"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
)

// nominateApply applies the changed watcher data onto our local caches.
Expand Down Expand Up @@ -306,7 +306,7 @@ func (obj *EmbdEtcd) volunteerCb(ctx context.Context) error {

// NOTE: There used to be an is_leader check right here...
// FIXME: Should we use WithRequireLeader instead? Here? Elsewhere?
// https://godoc.org/github.com/etcd-io/etcd/clientv3#WithRequireLeader
// https://godoc.org/github.com/etcd-io/etcd/client/v3#WithRequireLeader

// FIXME: can this happen, and if so, is it an error or a pass-through?
if len(obj.volunteers) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion etcd/chooser/chooser.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/purpleidea/mgmt/etcd/interfaces"

etcdtypes "go.etcd.io/etcd/pkg/types"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
)

// Data represents the input data that is passed to the chooser.
Expand Down
4 changes: 2 additions & 2 deletions etcd/chooser/dynamicsize.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (

"github.com/purpleidea/mgmt/etcd/interfaces"

etcd "go.etcd.io/etcd/clientv3"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcd "go.etcd.io/etcd/client/v3"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
)

// XXX: Test causing cluster shutdowns with:
Expand Down
2 changes: 1 addition & 1 deletion etcd/client/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/purpleidea/mgmt/etcd/interfaces"
"github.com/purpleidea/mgmt/util"

etcd "go.etcd.io/etcd/clientv3"
etcd "go.etcd.io/etcd/client/v3"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions etcd/client/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/purpleidea/mgmt/etcd/interfaces"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3" // "clientv3"
"go.etcd.io/etcd/clientv3/namespace"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
"go.etcd.io/etcd/client/v3/namespace"
)

// method represents the method we used to build the simple client.
Expand Down
4 changes: 2 additions & 2 deletions etcd/client/str/str.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/purpleidea/mgmt/etcd/interfaces"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
etcd "go.etcd.io/etcd/client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions etcd/client/strmap/strmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
etcd "go.etcd.io/etcd/client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion etcd/converger.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
etcd "go.etcd.io/etcd/client/v3"
)

// setHostnameConverged sets whether a specific hostname is converged.
Expand Down
4 changes: 2 additions & 2 deletions etcd/deployer/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/purpleidea/mgmt/etcd/interfaces"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
etcd "go.etcd.io/etcd/client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)

const (
Expand Down
10 changes: 5 additions & 5 deletions etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3" // "clientv3"
"go.etcd.io/etcd/clientv3/concurrency"
"go.etcd.io/etcd/clientv3/namespace"
"go.etcd.io/etcd/embed"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
"go.etcd.io/etcd/client/v3/namespace"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
"go.etcd.io/etcd/server/v3/embed"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions etcd/fs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3" // "clientv3"
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions etcd/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import (
"github.com/purpleidea/mgmt/util/errwrap"

"github.com/spf13/afero"
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
rpctypes "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
)

func init() {
Expand Down
8 changes: 4 additions & 4 deletions etcd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
"go.etcd.io/etcd/mvcc/mvccpb"
etcdtypes "go.etcd.io/etcd/pkg/types" // generated package
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/mvccpb"
etcd "go.etcd.io/etcd/client/v3"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types" // generated package
)

// setEndpoints sets the endpoints on the etcd client if it exists. It
Expand Down
4 changes: 2 additions & 2 deletions etcd/interfaces/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package interfaces
import (
"context"

etcd "go.etcd.io/etcd/clientv3" // "clientv3"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
)

// WatcherData is the structure of data passed to a callback from any watcher.
Expand Down
8 changes: 4 additions & 4 deletions etcd/membership.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
rpctypes "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
etcdtypes "go.etcd.io/etcd/pkg/types"
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
etcd "go.etcd.io/etcd/client/v3"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
)

// addSelfState is used to populate the initial state when I am adding myself.
Expand Down
6 changes: 3 additions & 3 deletions etcd/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcd "go.etcd.io/etcd/client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
)

// volunteer offers yourself up to be a server if needed. If you specify a nil
Expand Down
4 changes: 2 additions & 2 deletions etcd/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcd "go.etcd.io/etcd/clientv3"
"go.etcd.io/etcd/clientv3/concurrency"
etcd "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions etcd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"

"go.etcd.io/etcd/embed"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
"go.etcd.io/etcd/server/v3/embed"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion etcd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/purpleidea/mgmt/util/errwrap"

etcdtypes "go.etcd.io/etcd/pkg/types"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
)

// copyURL copies a URL.
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/exec-send-recv.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
mgmt "github.com/purpleidea/mgmt/lib"
"github.com/purpleidea/mgmt/pgraph"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome!
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/libmgmt-subgraph0.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/purpleidea/mgmt/pgraph"
"github.com/purpleidea/mgmt/util/errwrap"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome!
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/libmgmt-subgraph1.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
mgmt "github.com/purpleidea/mgmt/lib"
"github.com/purpleidea/mgmt/pgraph"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome!
Expand Down
2 changes: 1 addition & 1 deletion examples/lib/libmgmt2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
mgmt "github.com/purpleidea/mgmt/lib"
"github.com/purpleidea/mgmt/pgraph"

"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

// XXX: this has not been updated to latest GAPI/Deploy API. Patches welcome!
Expand Down

0 comments on commit b709a86

Please sign in to comment.