Skip to content

Commit 940344b

Browse files
guilhemfrebib
authored andcommitted
misc: Use go mod
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 <[email protected]>
1 parent d491bfd commit 940344b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1595
-170
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ jobs:
2727
# macos tests are currently failing in CI
2828
#- macos-latest
2929
golang_version:
30-
# TODO: add 1.15.x and tip
31-
# minimum required and latest published go_version
32-
#- 1.13
33-
- 1.15
30+
- 1.17
3431
test_block:
3532
- basic
3633
- shell

.gitmodules

Lines changed: 0 additions & 39 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ lang: ## generates the lexer/parser for the language frontend
151151

152152
# build a `mgmt` binary for current host os/arch
153153
$(PROGRAM): build/mgmt-${GOHOSTOS}-${GOHOSTARCH} ## build an mgmt binary for current host os/arch
154-
cp -a $< $@
154+
@cp -a $< $@
155155

156156
$(PROGRAM).static: $(GO_FILES) $(MCL_FILES)
157157
@echo "Building: $(PROGRAM).static, version: $(SVERSION)..."
@@ -170,7 +170,7 @@ GOOS=$(firstword $(subst -, ,$*))
170170
GOARCH=$(lastword $(subst -, ,$*))
171171
build/mgmt-%: $(GO_FILES) $(MCL_FILES) | bindata lang funcgen
172172
@echo "Building: $(PROGRAM), os/arch: $*, version: $(SVERSION)..."
173-
@time env GOOS=${GOOS} GOARCH=${GOARCH} go build -i -ldflags=$(PKGNAME)="-X main.program=$(PROGRAM) -X main.version=$(SVERSION) ${LDFLAGS}" -o $@ $(BUILD_FLAGS)
173+
@time env GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags=$(PKGNAME)="-X main.program=$(PROGRAM) -X main.version=$(SVERSION) ${LDFLAGS}" -o $@ $(BUILD_FLAGS)
174174

175175
# create a list of binary file names to use as make targets
176176
crossbuild_targets = $(addprefix build/mgmt-,$(subst /,-,${GOOSARCHES}))

engine/resources/cron.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import (
3333
"github.com/purpleidea/mgmt/util"
3434
"github.com/purpleidea/mgmt/util/errwrap"
3535

36-
sdbus "github.com/coreos/go-systemd/dbus"
37-
"github.com/coreos/go-systemd/unit"
38-
systemdUtil "github.com/coreos/go-systemd/util"
39-
"github.com/godbus/dbus"
36+
sdbus "github.com/coreos/go-systemd/v22/dbus"
37+
"github.com/coreos/go-systemd/v22/unit"
38+
systemdUtil "github.com/coreos/go-systemd/v22/util"
39+
"github.com/godbus/dbus/v5"
4040
)
4141

4242
const (

engine/resources/hostname.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/purpleidea/mgmt/util"
2828
"github.com/purpleidea/mgmt/util/errwrap"
2929

30-
"github.com/godbus/dbus"
30+
"github.com/godbus/dbus/v5"
3131
)
3232

3333
func init() {

engine/resources/mount.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ import (
3535
"github.com/purpleidea/mgmt/util"
3636
"github.com/purpleidea/mgmt/util/errwrap"
3737

38-
sdbus "github.com/coreos/go-systemd/dbus"
39-
"github.com/coreos/go-systemd/unit"
40-
systemdUtil "github.com/coreos/go-systemd/util"
38+
sdbus "github.com/coreos/go-systemd/v22/dbus"
39+
"github.com/coreos/go-systemd/v22/unit"
40+
systemdUtil "github.com/coreos/go-systemd/v22/util"
4141
fstab "github.com/deniswernert/go-fstab"
42-
"github.com/godbus/dbus"
42+
"github.com/godbus/dbus/v5"
4343
"golang.org/x/sys/unix"
4444
)
4545

engine/resources/msg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"github.com/purpleidea/mgmt/engine"
2626
"github.com/purpleidea/mgmt/engine/traits"
2727

28-
"github.com/coreos/go-systemd/journal"
28+
"github.com/coreos/go-systemd/v22/journal"
2929
)
3030

3131
func init() {

engine/resources/nspawn.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import (
3030
"github.com/purpleidea/mgmt/util"
3131
"github.com/purpleidea/mgmt/util/errwrap"
3232

33-
systemdDbus "github.com/coreos/go-systemd/dbus"
34-
machined "github.com/coreos/go-systemd/machine1"
35-
systemdUtil "github.com/coreos/go-systemd/util"
36-
"github.com/godbus/dbus"
33+
systemdDbus "github.com/coreos/go-systemd/v22/dbus"
34+
machined "github.com/coreos/go-systemd/v22/machine1"
35+
systemdUtil "github.com/coreos/go-systemd/v22/util"
36+
"github.com/godbus/dbus/v5"
3737
)
3838

3939
const (

engine/resources/packagekit/packagekit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/purpleidea/mgmt/util"
3030
"github.com/purpleidea/mgmt/util/errwrap"
3131

32-
"github.com/godbus/dbus"
32+
"github.com/godbus/dbus/v5"
3333
)
3434

3535
// global tweaks of verbosity and code path

engine/resources/svc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import (
3030
"github.com/purpleidea/mgmt/util"
3131
"github.com/purpleidea/mgmt/util/errwrap"
3232

33-
systemd "github.com/coreos/go-systemd/dbus" // change namespace
34-
systemdUtil "github.com/coreos/go-systemd/util"
35-
"github.com/godbus/dbus" // namespace collides with systemd wrapper
33+
systemd "github.com/coreos/go-systemd/v22/dbus" // change namespace
34+
systemdUtil "github.com/coreos/go-systemd/v22/util"
35+
"github.com/godbus/dbus/v5" // namespace collides with systemd wrapper
3636
)
3737

3838
func init() {

engine/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"github.com/purpleidea/mgmt/lang/types"
3434
"github.com/purpleidea/mgmt/util/errwrap"
3535

36-
"github.com/godbus/dbus"
36+
"github.com/godbus/dbus/v5"
3737
)
3838

3939
const (

etcd/callback.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"github.com/purpleidea/mgmt/util"
2727
"github.com/purpleidea/mgmt/util/errwrap"
2828

29-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
30-
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
29+
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
30+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
3131
)
3232

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

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

311311
// FIXME: can this happen, and if so, is it an error or a pass-through?
312312
if len(obj.volunteers) == 0 {

etcd/chooser/chooser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

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

25-
etcdtypes "go.etcd.io/etcd/pkg/types"
25+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
2626
)
2727

2828
// Data represents the input data that is passed to the chooser.

etcd/chooser/dynamicsize.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import (
2525

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

28-
etcd "go.etcd.io/etcd/clientv3"
29-
etcdtypes "go.etcd.io/etcd/pkg/types"
28+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
29+
etcd "go.etcd.io/etcd/client/v3"
3030
)
3131

3232
// XXX: Test causing cluster shutdowns with:

etcd/client/resources/resources.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/purpleidea/mgmt/etcd/interfaces"
2828
"github.com/purpleidea/mgmt/util"
2929

30-
etcd "go.etcd.io/etcd/clientv3"
30+
etcd "go.etcd.io/etcd/client/v3"
3131
)
3232

3333
const (

etcd/client/simple.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"github.com/purpleidea/mgmt/etcd/interfaces"
2727
"github.com/purpleidea/mgmt/util/errwrap"
2828

29-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
30-
"go.etcd.io/etcd/clientv3/namespace"
29+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
30+
"go.etcd.io/etcd/client/v3/namespace"
3131
)
3232

3333
// method represents the method we used to build the simple client.

etcd/client/str/str.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"github.com/purpleidea/mgmt/etcd/interfaces"
2525
"github.com/purpleidea/mgmt/util/errwrap"
2626

27-
etcd "go.etcd.io/etcd/clientv3"
28-
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
27+
etcd "go.etcd.io/etcd/client/v3"
28+
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
2929
)
3030

3131
const (

etcd/client/strmap/strmap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"github.com/purpleidea/mgmt/util"
2727
"github.com/purpleidea/mgmt/util/errwrap"
2828

29-
etcd "go.etcd.io/etcd/clientv3"
30-
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
29+
etcd "go.etcd.io/etcd/client/v3"
30+
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
3131
)
3232

3333
const (

etcd/converger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

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

26-
etcd "go.etcd.io/etcd/clientv3"
26+
etcd "go.etcd.io/etcd/client/v3"
2727
)
2828

2929
// setHostnameConverged sets whether a specific hostname is converged.

etcd/deployer/deployer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"github.com/purpleidea/mgmt/etcd/interfaces"
2828
"github.com/purpleidea/mgmt/util/errwrap"
2929

30-
etcd "go.etcd.io/etcd/clientv3"
31-
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
30+
etcd "go.etcd.io/etcd/client/v3"
31+
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
3232
)
3333

3434
const (

etcd/etcd.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ import (
122122
"github.com/purpleidea/mgmt/util"
123123
"github.com/purpleidea/mgmt/util/errwrap"
124124

125-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
126-
"go.etcd.io/etcd/clientv3/concurrency"
127-
"go.etcd.io/etcd/clientv3/namespace"
128-
"go.etcd.io/etcd/embed"
129-
etcdtypes "go.etcd.io/etcd/pkg/types"
125+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
126+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
127+
"go.etcd.io/etcd/client/v3/concurrency"
128+
"go.etcd.io/etcd/client/v3/namespace"
129+
"go.etcd.io/etcd/server/v3/embed"
130130
)
131131

132132
const (

etcd/fs/file.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030

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

33-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
34-
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
33+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
34+
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
3535
)
3636

3737
func init() {

etcd/fs/fs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ import (
3838
"github.com/purpleidea/mgmt/util/errwrap"
3939

4040
"github.com/spf13/afero"
41-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
42-
rpctypes "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
41+
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
42+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
4343
)
4444

4545
func init() {

etcd/helpers.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
"github.com/purpleidea/mgmt/util"
2828
"github.com/purpleidea/mgmt/util/errwrap"
2929

30-
etcd "go.etcd.io/etcd/clientv3"
31-
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
32-
"go.etcd.io/etcd/mvcc/mvccpb"
33-
etcdtypes "go.etcd.io/etcd/pkg/types" // generated package
30+
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
31+
"go.etcd.io/etcd/api/v3/mvccpb"
32+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types" // generated package
33+
etcd "go.etcd.io/etcd/client/v3"
3434
)
3535

3636
// setEndpoints sets the endpoints on the etcd client if it exists. It

etcd/interfaces/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ package interfaces
2020
import (
2121
"context"
2222

23-
etcd "go.etcd.io/etcd/clientv3" // "clientv3"
24-
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
23+
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
24+
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
2525
)
2626

2727
// WatcherData is the structure of data passed to a callback from any watcher.

etcd/membership.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626

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

29-
etcd "go.etcd.io/etcd/clientv3"
30-
rpctypes "go.etcd.io/etcd/etcdserver/api/v3rpc/rpctypes"
31-
pb "go.etcd.io/etcd/etcdserver/etcdserverpb"
32-
etcdtypes "go.etcd.io/etcd/pkg/types"
29+
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
30+
"go.etcd.io/etcd/api/v3/v3rpc/rpctypes"
31+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
32+
etcd "go.etcd.io/etcd/client/v3"
3333
)
3434

3535
// addSelfState is used to populate the initial state when I am adding myself.

etcd/methods.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import (
2424

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

27-
etcd "go.etcd.io/etcd/clientv3"
28-
etcdutil "go.etcd.io/etcd/clientv3/clientv3util"
29-
etcdtypes "go.etcd.io/etcd/pkg/types"
27+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
28+
etcd "go.etcd.io/etcd/client/v3"
29+
etcdutil "go.etcd.io/etcd/client/v3/clientv3util"
3030
)
3131

3232
// volunteer offers yourself up to be a server if needed. If you specify a nil

etcd/scheduler/scheduler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import (
2828

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

31-
etcd "go.etcd.io/etcd/clientv3"
32-
"go.etcd.io/etcd/clientv3/concurrency"
31+
etcd "go.etcd.io/etcd/client/v3"
32+
"go.etcd.io/etcd/client/v3/concurrency"
3333
)
3434

3535
const (

etcd/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"github.com/purpleidea/mgmt/util"
2828
"github.com/purpleidea/mgmt/util/errwrap"
2929

30-
"go.etcd.io/etcd/embed"
31-
etcdtypes "go.etcd.io/etcd/pkg/types"
30+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
31+
"go.etcd.io/etcd/server/v3/embed"
3232
)
3333

3434
const (

etcd/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626

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

29-
etcdtypes "go.etcd.io/etcd/pkg/types"
29+
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
3030
)
3131

3232
// copyURL copies a URL.

examples/lib/exec-send-recv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
mgmt "github.com/purpleidea/mgmt/lib"
1717
"github.com/purpleidea/mgmt/pgraph"
1818

19-
"github.com/urfave/cli"
19+
"github.com/urfave/cli/v2"
2020
)
2121

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

0 commit comments

Comments
 (0)