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 26, 2021
1 parent 8fde6aa commit 8753f86
Show file tree
Hide file tree
Showing 127 changed files with 1,660 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
1 change: 1 addition & 0 deletions converger/converger_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package converger
Expand Down
1 change: 1 addition & 0 deletions engine/autoedge_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package engine
Expand Down
1 change: 1 addition & 0 deletions engine/graph/autogroup/autogroup_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package autogroup
Expand Down
1 change: 1 addition & 0 deletions engine/graph/graph_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package graph
Expand Down
1 change: 1 addition & 0 deletions engine/graph/semaphore_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package graph
Expand Down
1 change: 1 addition & 0 deletions engine/metaparams_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package engine
Expand Down
1 change: 1 addition & 0 deletions engine/resources/augeas.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !noaugeas
// +build !noaugeas

package resources
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
1 change: 1 addition & 0 deletions engine/resources/docker_container.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !nodocker
// +build !nodocker

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/docker_container_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !nodocker
// +build !nodocker

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/docker_image.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !nodocker
// +build !nodocker

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/exec_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/file_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
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
1 change: 1 addition & 0 deletions engine/resources/mount_linux_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root || !darwin
// +build !root !darwin

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/mount_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
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
1 change: 1 addition & 0 deletions engine/resources/msg_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/net.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !darwin
// +build !darwin

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/net_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !darwin
// +build !darwin

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/noop_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
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
1 change: 1 addition & 0 deletions engine/resources/pippet_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/pkg_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/resources_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
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
1 change: 1 addition & 0 deletions engine/resources/test_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/resources/virt.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !novirt
// +build !novirt

package resources
Expand Down
1 change: 1 addition & 0 deletions engine/util/mode_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package util
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
1 change: 1 addition & 0 deletions engine/util/util_test.go
Expand Up @@ -15,6 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

//go:build !root
// +build !root

package util
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

0 comments on commit 8753f86

Please sign in to comment.