lib: Move to go modules and shed a few tears

The old system with vendor/ and git submodules worked great,
unfortunately FUD around git submodules seemed to scare people away and
golang moved to a go.mod system that adds a new lock file format instead
of using the built-in git version. It's now almost impossible to use
modern golang without this, so we've switched.

So much for the golang compatibility promise-- turns out it doesn't
apply to the useful parts that I actually care about like this.

Thanks to frebib for his incredibly valuable contributions to this
patch. This snide commit message is mine alone.

This patch also mixes in some changes due to legacy golang as we've also
bumped the minimum version to 1.16 in the docs and tests.

Lastly, we had to disable some tests and fix up a few other misc things
to get this passing. We've definitely hot bugs in the go.mod system, and
our Makefile tries to workaround those.
This commit is contained in:
James Shubin
2021-05-25 01:44:30 -04:00
parent 9c75c55fa4
commit 88516546fa
80 changed files with 1115 additions and 287 deletions

View File

@@ -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"
)
// nominateApply applies the changed watcher data onto our local caches.

View File

@@ -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.

View File

@@ -25,8 +25,8 @@ import (
"github.com/purpleidea/mgmt/etcd/interfaces"
etcd "go.etcd.io/etcd/clientv3"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3"
)
// XXX: Test causing cluster shutdowns with:

View File

@@ -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 (

View File

@@ -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"
"go.etcd.io/etcd/client/v3/namespace"
)
// method represents the method we used to build the simple client.
@@ -301,7 +301,7 @@ func (obj *Simple) Get(ctx context.Context, path string, opts ...etcd.OpOption)
return nil, fmt.Errorf("empty response")
}
// TODO: write a resp.ToMap() function on https://godoc.org/github.com/etcd-io/etcd/etcdserver/etcdserverpb#RangeResponse
// TODO: write a resp.ToMap() function on https://godoc.org/github.com/etcd-io/etcd/api/etcdserverpb#RangeResponse
result := make(map[string]string)
for _, x := range resp.Kvs {
result[string(x.Key)] = string(x.Value)

View File

@@ -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 (

View File

@@ -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 (

View File

@@ -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.

View File

@@ -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 (

View File

@@ -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"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
"go.etcd.io/etcd/client/v3/namespace"
"go.etcd.io/etcd/server/v3/embed"
)
const (

View File

@@ -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"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)
func init() {

View File

@@ -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"
rpctypes "go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
etcd "go.etcd.io/etcd/client/v3"
)
func init() {

View File

@@ -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"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types" // generated package
etcd "go.etcd.io/etcd/client/v3"
)
// setEndpoints sets the endpoints on the etcd client if it exists. It

View File

@@ -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"
)
// WatcherData is the structure of data passed to a callback from any watcher.

View File

@@ -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"
rpctypes "go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3"
)
// addSelfState is used to populate the initial state when I am adding myself.

View File

@@ -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"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3"
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
)
// volunteer offers yourself up to be a server if needed. If you specify a nil

View File

@@ -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 (

View File

@@ -27,8 +27,9 @@ import (
"github.com/purpleidea/mgmt/util"
"github.com/purpleidea/mgmt/util/errwrap"
"go.etcd.io/etcd/embed"
etcdtypes "go.etcd.io/etcd/pkg/types"
etcdTransport "go.etcd.io/etcd/client/pkg/v3/transport"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
"go.etcd.io/etcd/server/v3/embed"
)
const (
@@ -149,6 +150,11 @@ func (obj *EmbdEtcd) runServer(newCluster bool, peerURLsMap etcdtypes.URLsMap) (
//cfg.LogOutputs = []string{} // FIXME: add a way to pass in our logf func
cfg.LogLevel = "error" // keep things quieter for now
cfg.SocketOpts = etcdTransport.SocketOpts{
//ReusePort: false, // SO_REUSEPORT
ReuseAddress: true, // SO_REUSEADDR
}
cfg.InitialCluster = initialPeerURLsMap.String() // including myself!
if newCluster {
cfg.ClusterState = embed.ClusterStateFlagNew

View File

@@ -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.