diff --git a/README.md b/README.md index d36b922..ad904b8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/main.go b/cmd/bareos-zabbix-check/main.go similarity index 61% rename from main.go rename to cmd/bareos-zabbix-check/main.go index f55943d..b695119 100644 --- a/main.go +++ b/cmd/bareos-zabbix-check/main.go @@ -3,8 +3,9 @@ package main import ( - "bareos-zabbix-check/zabbix" "fmt" + + "git.adyxax.org/adyxax/bareos-zabbix-check/pkg/zabbix" ) func main() { diff --git a/go.mod b/go.mod index 4ee0177..8863b6d 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/job/job.go b/pkg/job/job.go similarity index 100% rename from job/job.go rename to pkg/job/job.go diff --git a/job/job_test.go b/pkg/job/job_test.go similarity index 100% rename from job/job_test.go rename to pkg/job/job_test.go diff --git a/job/utils.go b/pkg/job/utils.go similarity index 100% rename from job/utils.go rename to pkg/job/utils.go diff --git a/job/utils_test.go b/pkg/job/utils_test.go similarity index 100% rename from job/utils_test.go rename to pkg/job/utils_test.go diff --git a/spool/parse.go b/pkg/spool/parse.go similarity index 91% rename from spool/parse.go rename to pkg/spool/parse.go index 5695890..fc378f3 100644 --- a/spool/parse.go +++ b/pkg/spool/parse.go @@ -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" ) diff --git a/spool/parse_test.go b/pkg/spool/parse_test.go similarity index 94% rename from spool/parse_test.go rename to pkg/spool/parse_test.go index 80b961f..cfbb050 100644 --- a/spool/parse_test.go +++ b/pkg/spool/parse_test.go @@ -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) { diff --git a/spool/serialize.go b/pkg/spool/serialize.go similarity index 88% rename from spool/serialize.go rename to pkg/spool/serialize.go index 04af8da..bfa7729 100644 --- a/spool/serialize.go +++ b/pkg/spool/serialize.go @@ -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 diff --git a/spool/serialize_test.go b/pkg/spool/serialize_test.go similarity index 92% rename from spool/serialize_test.go rename to pkg/spool/serialize_test.go index 896125c..7337121 100644 --- a/spool/serialize_test.go +++ b/pkg/spool/serialize_test.go @@ -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) { diff --git a/state/header.go b/pkg/state/header.go similarity index 97% rename from state/header.go rename to pkg/state/header.go index 3becd5d..ee6629b 100644 --- a/state/header.go +++ b/pkg/state/header.go @@ -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" ) diff --git a/state/header_test.go b/pkg/state/header_test.go similarity index 100% rename from state/header_test.go rename to pkg/state/header_test.go diff --git a/state/job.go b/pkg/state/job.go similarity index 96% rename from state/job.go rename to pkg/state/job.go index e8333ff..e86bc8e 100644 --- a/state/job.go +++ b/pkg/state/job.go @@ -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" ) diff --git a/state/job_test.go b/pkg/state/job_test.go similarity index 99% rename from state/job_test.go rename to pkg/state/job_test.go index 410401b..f814574 100644 --- a/state/job_test.go +++ b/pkg/state/job_test.go @@ -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) { diff --git a/utils/clen.go b/pkg/utils/clen.go similarity index 100% rename from utils/clen.go rename to pkg/utils/clen.go diff --git a/utils/clen_test.go b/pkg/utils/clen_test.go similarity index 100% rename from utils/clen_test.go rename to pkg/utils/clen_test.go diff --git a/zabbix/flags.go b/pkg/zabbix/flags.go similarity index 100% rename from zabbix/flags.go rename to pkg/zabbix/flags.go diff --git a/zabbix/statefile.go b/pkg/zabbix/statefile.go similarity index 100% rename from zabbix/statefile.go rename to pkg/zabbix/statefile.go diff --git a/zabbix/testdata/bareos-fd-17.2.state b/pkg/zabbix/testdata/bareos-fd-17.2.state similarity index 100% rename from zabbix/testdata/bareos-fd-17.2.state rename to pkg/zabbix/testdata/bareos-fd-17.2.state diff --git a/zabbix/testdata/bareos-fd-18.2.state b/pkg/zabbix/testdata/bareos-fd-18.2.state similarity index 100% rename from zabbix/testdata/bareos-fd-18.2.state rename to pkg/zabbix/testdata/bareos-fd-18.2.state diff --git a/zabbix/testdata/bareos-fd-18.2.state-with-error b/pkg/zabbix/testdata/bareos-fd-18.2.state-with-error similarity index 100% rename from zabbix/testdata/bareos-fd-18.2.state-with-error rename to pkg/zabbix/testdata/bareos-fd-18.2.state-with-error diff --git a/zabbix/workdir.go b/pkg/zabbix/workdir.go similarity index 100% rename from zabbix/workdir.go rename to pkg/zabbix/workdir.go diff --git a/zabbix/main.go b/pkg/zabbix/zabbix.go similarity index 94% rename from zabbix/main.go rename to pkg/zabbix/zabbix.go index 576fc17..77fef6d 100644 --- a/zabbix/main.go +++ b/pkg/zabbix/zabbix.go @@ -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 ( diff --git a/zabbix/main_test.go b/pkg/zabbix/zabbix_test.go similarity index 95% rename from zabbix/main_test.go rename to pkg/zabbix/zabbix_test.go index ca722f6..d623d41 100644 --- a/zabbix/main_test.go +++ b/pkg/zabbix/zabbix_test.go @@ -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"},