1
0
Fork 0

Updated for go 1.16 modules

This commit is contained in:
Julien Dessaux 2021-04-23 16:51:22 +02:00
parent 8278d7b471
commit 38d9c881b3
25 changed files with 25 additions and 19 deletions

View file

@ -15,7 +15,7 @@ This program was born from a need to query the status of the backups from the cl
## Dependencies
go is required. Only go version >= 1.13.5 on linux amd64 has been tested.
go is required. Only go version >= 1.16 on linux amd64 has been tested.
## Building
@ -26,12 +26,12 @@ go test -cover ./...
For a debug build, use :
```
go build
go build ./cmd/bareos-zabbix-check/
```
For a release build, use :
```
go build -ldflags="-s -w"
go build -ldflags="-s -w" ./cmd/bareos-zabbix-check/
```
## Usage

View file

@ -3,8 +3,9 @@
package main
import (
"bareos-zabbix-check/zabbix"
"fmt"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/zabbix"
)
func main() {

4
go.mod
View file

@ -1,5 +1,5 @@
module bareos-zabbix-check
module git.adyxax.org/adyxax/bareos-zabbix-check
go 1.13
go 1.16
require github.com/pkg/errors v0.9.1

View file

@ -1,11 +1,11 @@
package spool
import (
"bareos-zabbix-check/job"
"encoding/csv"
"io"
"strconv"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
"github.com/pkg/errors"
)

View file

@ -1,12 +1,13 @@
package spool
import (
"bareos-zabbix-check/job"
"bytes"
"io"
"reflect"
"testing"
"testing/iotest"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
)
func TestParse(t *testing.T) {

View file

@ -1,10 +1,11 @@
package spool
import (
"bareos-zabbix-check/job"
"encoding/csv"
"fmt"
"io"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
)
// Serialize writes a spool on the disk

View file

@ -1,9 +1,10 @@
package spool
import (
"bareos-zabbix-check/job"
"bytes"
"testing"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
)
func TestSerialize(t *testing.T) {

View file

@ -1,12 +1,12 @@
package state
import (
"bareos-zabbix-check/utils"
"bytes"
"encoding/binary"
"fmt"
"io"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/utils"
"github.com/pkg/errors"
)

View file

@ -1,8 +1,6 @@
package state
import (
"bareos-zabbix-check/job"
"bareos-zabbix-check/utils"
"bytes"
"encoding/binary"
"fmt"
@ -10,6 +8,8 @@ import (
"regexp"
"time"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/utils"
"github.com/pkg/errors"
)

View file

@ -1,11 +1,12 @@
package state
import (
"bareos-zabbix-check/job"
"bytes"
"io"
"reflect"
"testing"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
)
func Test_jobEntry_String(t *testing.T) {

View file

@ -1,13 +1,14 @@
package zabbix
import (
"bareos-zabbix-check/job"
"bareos-zabbix-check/spool"
"bareos-zabbix-check/state"
"fmt"
"os"
"path/filepath"
"time"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/job"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/spool"
"git.adyxax.org/adyxax/bareos-zabbix-check/pkg/state"
)
const (

View file

@ -37,9 +37,9 @@ func TestMain(t *testing.T) {
{"failed bacula_auto_detect", 0, "tmp/bacula_auto_detect_failed", []string{}, "INFO Failed to init programm : Could not find a suitable state file. Has a job ever run?"},
{"failed bareos_auto_detect", 0, "tmp/bareos_auto_detect_failed", []string{}, "INFO Failed to init programm : Could not find a suitable state file. Has a job ever run?"},
{"failed auto_detect", 0, "tmp/non_existent", []string{}, "INFO Failed to init programm : Could not find a suitable work directory. Is bareos or bacula installed?"},
{"no work directory", 0, "tmp", []string{"-w", "/non_existent"}, fmt.Sprintf("INFO Failed to init programm : Invalid work directory %s/zabbix/tmp/non_existent : it does not exist or is not a directory", wd)},
{"no work directory", 0, "tmp", []string{"-w", "/non_existent"}, fmt.Sprintf("INFO Failed to init programm : Invalid work directory %s/tmp/non_existent : it does not exist or is not a directory", wd)},
{"no state file auto_detect", 0, "tmp", []string{"-w", "/no_state_file"}, "INFO Failed to init programm : Could not find a suitable state file. Has a job ever run?"},
{"no state file", 0, "tmp", []string{"-w", "/no_state_file", "-f", "test"}, fmt.Sprintf("INFO Failed to init programm : The state file %s/zabbix/tmp/no_state_file/test does not exist", wd},
{"no state file", 0, "tmp", []string{"-w", "/no_state_file", "-f", "test"}, fmt.Sprintf("INFO Failed to init programm : The state file %s/tmp/no_state_file/test does not exist", wd)},
{"ok bareos 18.2", 1582579731, "tmp/ok-18.2", []string{"-w", "/", "-f", "state"}, "OK"},
{"ok bareos 17.2", 1582579731, "tmp/ok-17.2", []string{"-w", "/", "-f", "state"}, "OK"},
{"missing", 1582709331, "tmp/ok-18.2", []string{"-w", "/", "-f", "state"}, "AVERAGE: missing: awhphpipam1_percona_xtrabackup, awhphpipam1_LinuxAll, awhphpipam1_www"},