Skip to content

Commit 8753f86

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 8fde6aa commit 8753f86

File tree

127 files changed

+1660
-170
lines changed

Some content is hidden

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

127 files changed

+1660
-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}))

converger/converger_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package converger

engine/autoedge_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package engine

engine/graph/autogroup/autogroup_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package autogroup

engine/graph/graph_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package graph

engine/graph/semaphore_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package graph

engine/metaparams_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package engine

engine/resources/augeas.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !noaugeas
1819
// +build !noaugeas
1920

2021
package resources

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/docker_container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !nodocker
1819
// +build !nodocker
1920

2021
package resources

engine/resources/docker_container_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !nodocker
1819
// +build !nodocker
1920

2021
package resources

engine/resources/docker_image.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !nodocker
1819
// +build !nodocker
1920

2021
package resources

engine/resources/exec_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

engine/resources/file_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

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/mount_linux_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root || !darwin
1819
// +build !root !darwin
1920

2021
package resources

engine/resources/mount_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

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/msg_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

engine/resources/net.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !darwin
1819
// +build !darwin
1920

2021
package resources

engine/resources/net_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !darwin
1819
// +build !darwin
1920

2021
package resources

engine/resources/noop_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

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/pippet_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

engine/resources/pkg_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

engine/resources/resources_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

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/resources/test_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package resources

engine/resources/virt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !novirt
1819
// +build !novirt
1920

2021
package resources

engine/util/mode_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package util

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 (

engine/util/util_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18+
//go:build !root
1819
// +build !root
1920

2021
package util

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.

0 commit comments

Comments
 (0)