-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for v6.4.0 #54
Comments
I think you mean Technically this changed occurred in Zabbix 5.4; I have a patch, by the way, that takes care of this in a backward-compatible way. (I am maintaining my own clone of this repo now because it seems to take a while for issues to get fixed.) Happy to pass along the patch if you like. |
A one-liner patch, here's what we're using:
|
I have to support both Zabbix < 5.4 and Zabbix >= 6.4 in my environment, so my patch is backward compatible: diff --git a/go.mod b/go.mod
index db6a935..b74b8dc 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,5 @@
module github.com/cavaliercoder/go-zabbix
go 1.16
+
+require github.com/hashicorp/go-version v1.6.0
diff --git a/go.sum b/go.sum
index e69de29..805e323 100644
--- a/go.sum
+++ b/go.sum
@@ -0,0 +1,2 @@
+github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
+github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
diff --git a/session.go b/session.go
index d1b8e46..c13ded8 100644
--- a/session.go
+++ b/session.go
@@ -7,6 +7,8 @@ import (
"fmt"
"io/ioutil"
"net/http"
+
+ "github.com/hashicorp/go-version"
)
// ErrNotFound describes an empty result set for an API call.
@@ -51,9 +53,18 @@ func (c *Session) login(username, password string) error {
return fmt.Errorf("Failed to retrieve Zabbix API version: %v", err)
}
+ // "user" parameter changed to "username" in Zabbix 5.4. Use the
+ // new parameter unless we can unequivocally determine we are
+ // pre-5.4.
+ userParam := "username"
+ vZabbix, err := version.NewVersion(c.APIVersion)
+ if err == nil && vZabbix.LessThan(version.Must(version.NewVersion("5.4"))) {
+ userParam = "user"
+ }
+
// login to API
params := map[string]string{
- "user": username,
+ userParam: username,
"password": password,
}
|
Looks good, I like it! |
found the same,opened PR #55 |
I've fixed this in my fork of this library: https://github.com/fabiang/go-zabbix |
user.log paramter had been changed, from user to username.
The text was updated successfully, but these errors were encountered: