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 Sep 4, 2021
1 parent d491bfd commit 940344b
Show file tree
Hide file tree
Showing 62 changed files with 1,595 additions and 170 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/test.yaml
Expand Up @@ -27,10 +27,7 @@ jobs:
# macos tests are currently failing in CI
#- macos-latest
golang_version:
# TODO: add 1.15.x and tip
# minimum required and latest published go_version
#- 1.13
- 1.15
- 1.17
test_block:
- basic
- shell
Expand Down
39 changes: 0 additions & 39 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -151,7 +151,7 @@ lang: ## generates the lexer/parser for the language frontend

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

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

# create a list of binary file names to use as make targets
crossbuild_targets = $(addprefix build/mgmt-,$(subst /,-,${GOOSARCHES}))
Expand Down
8 changes: 4 additions & 4 deletions engine/resources/cron.go
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
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
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
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
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
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
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
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
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
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
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"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3"
)

// XXX: Test causing cluster shutdowns with:
Expand Down
2 changes: 1 addition & 1 deletion etcd/client/resources/resources.go
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
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
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
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
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
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
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"
etcdtypes "go.etcd.io/etcd/client/pkg/v3/types"
etcd "go.etcd.io/etcd/client/v3" // "client/v3"
"go.etcd.io/etcd/client/v3/concurrency"
"go.etcd.io/etcd/client/v3/namespace"
"go.etcd.io/etcd/server/v3/embed"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions etcd/fs/file.go
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
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
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"
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
Expand Down
4 changes: 2 additions & 2 deletions etcd/interfaces/client.go
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
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"
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.
Expand Down
6 changes: 3 additions & 3 deletions etcd/methods.go
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"
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
Expand Down
4 changes: 2 additions & 2 deletions etcd/scheduler/scheduler.go
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
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
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
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 940344b

Please sign in to comment.