commit - f5fde32e94d77a44e85a28f9263531b34fdf7c8b
commit + dd1562c064ef82c610805dfd8cdaca5af54f6d22
blob - 08c3bb298903b6e7ed660a9dd370003d345bbc95
blob + aee29003cd9406fed861d0fc0ecdff2202a5763d
--- README.md
+++ README.md
Icinga2 object types, such as Host and Service, are generated
automatically.
+To generate the code, ensure the following tools are available:
+
+* POSIX shell (/bin/sh)
+* awk
+* gofmt
+
The shell script crud.sh writes Go source code by reading a template
file and doing some text substitution. It loops through object types,
piping the template file crud.skel into the awk script crud.awk for
blob - ef0c13cb27a60a4050375907a86d2a293651657c
blob + 80a024bcecbca0755bbb780f1fc35472380a6206
--- crud.go
+++ crud.go
}
return nil
}
-
// Services returns a slice of Service matching the filter expression filter.
// If no services match, error wraps ErrNoMatch.
// To fetch all service, set filter to the empty string ("").
}
return nil
}
-
// Users returns a slice of User matching the filter expression filter.
// If no users match, error wraps ErrNoMatch.
// To fetch all user, set filter to the empty string ("").
}
return nil
}
-
// HostGroups returns a slice of HostGroup matching the filter expression filter.
// If no hostgroups match, error wraps ErrNoMatch.
// To fetch all hostgroup, set filter to the empty string ("").
blob - 6b8ffbf9297141704fd930b6cd2de2db41d14782
blob + 2bfde846644d3988f576e0136e9afe7d219c9d62
--- crud.sh
+++ crud.sh
esac
done
-
if test -n "$file"
then
echo "$head" > "$file"
do
if test -n "$file"
then
- awk -v "type=$t" -f crud.awk crud.skel >> "$file"
+ awk -v "type=$t" -f crud.awk crud.skel | gofmt >> "$file"
else
- awk -v "type=$t" -f crud.awk crud.skel
+ awk -v "type=$t" -f crud.awk crud.skel | gofmt
fi
done
blob - ae632700bfed2ae9da2abec5f19be31065e895b8
blob + 0aed23206f89c7a23d04fe9bc52bdfa190ae4b18
--- crud.skel
+++ crud.skel
// depending on the TYPE are also deleted. If no TYPE is found, error wraps
// ErrNotExist.
func (c *Client) DeleteTYPE(name string, cascade bool) error {
- if err := c.deleteObject("/objects/PLURAL/" + name, cascade); err != nil {
+ if err := c.deleteObject("/objects/PLURAL/"+name, cascade); err != nil {
return fmt.Errorf("delete LOWER %s: %w", name, err)
}
return nil