aboutsummaryrefslogtreecommitdiff
path: root/state/parser.go
diff options
context:
space:
mode:
authorJulien Dessaux2020-02-22 11:57:50 +0100
committerJulien Dessaux2020-02-22 11:57:50 +0100
commitbcfaffac240d74cd79bec3c2a9d3c144d215b495 (patch)
treeedd2c5f1e011afee759970323042fcf35bf68962 /state/parser.go
parentImproved tests for job package (diff)
downloadbareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.tar.gz
bareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.tar.bz2
bareos-zabbix-check-bcfaffac240d74cd79bec3c2a9d3c144d215b495.zip
Added tests to the state package, and reworked the code around that
Diffstat (limited to '')
-rw-r--r--state/parser.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/state/parser.go b/state/parser.go
deleted file mode 100644
index 60f5394..0000000
--- a/state/parser.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package state
-
-import (
- "bareos-zabbix-check/config"
- "fmt"
- "os"
-)
-
-// Parse parses a bareos state file
-func (s *State) Parse(c *config.Config) (err error) {
- s.config = c
- // Open the state file
- file, err := os.Open(c.StateFile())
- if err != nil {
- return fmt.Errorf("INFO Couldn't open state file : %s", err)
- }
- defer file.Close()
-
- err = s.parseHeader(file)
- if err != nil {
- return err
- }
- err = s.parseJobs(file)
- if err != nil {
- return err
- }
-
- return
-}
-
-// readNextBytes : Reads the next "number" bytes from a "file", returns the number of bytes actually read as well as the bytes read
-func (s *State) readNextBytes(file *os.File, number int) (n int, bytes []byte, err error) {
- bytes = make([]byte, number)
- n, err = file.Read(bytes)
- if err != nil {
- return 0, nil, fmt.Errorf("file.Read failed in %s : %s", s.config.StateFile(), err)
- }
-
- return
-}