Release 0.1.0

- add packaging via goreleaser
- finaliza changelog for 0.1.0
- add debian changelog and copyright
- add configuration for golangci-lint
This commit is contained in:
Jan Dittberner 2024-09-26 15:44:21 +02:00
parent 59692ae698
commit 902d4cb310
6 changed files with 232 additions and 8 deletions

5
.gitignore vendored
View file

@ -2,6 +2,7 @@
*.rej *.rej
.*.swp .*.swp
/.idea/ /.idea/
/debian/changelog.Debian.gz
/dist/
/matrix-host-notification /matrix-host-notification
/matrix-service-notification /matrix-service-notification
dist/

68
.golangci.yml Normal file
View file

@ -0,0 +1,68 @@
---
run:
go: "1.23"
output:
sort-results: true
linters-settings:
goheader:
values:
const:
AUTHOR: Jan Dittberner
template: |-
Copyright {{ AUTHOR }}
SPDX-License-Identifier: GPL-3.0-or-later
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
goimports:
local-prefixes: git.dittberner.info/git/icinga2-matrix-notification
misspell:
locale: "US"
ignore-words:
- Icinga2
linters:
disable-all: false
enable:
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
- errorlint
- exportloopref
- forbidigo
- forcetypeassert
- gocognit
- goconst
- gocritic
- gofmt
- goheader
- goimports
- mnd
- gosec
- lll
- makezero
- misspell
- nakedret
- nestif
- nlreturn
- nolintlint
- predeclared
- revive
- rowserrcheck
- sqlclosecheck
- wrapcheck
- wsl

128
.goreleaser.yaml Normal file
View file

@ -0,0 +1,128 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 2
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
- sh -c "gzip --best -n -c debian/changelog > debian/changelog.Debian.gz"
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
id: matrix-host-notification
binary: matrix-host-notification
main: ./cmd/matrix-host-notification/main.go
- env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
- arm64
id: matrix-service-notification
binary: matrix-service-notification
main: ./cmd/matrix-service-notification/main.go
archives:
- format: tar.gz
allow_different_binary_count: true
wrap_in_directory: true
# this name template makes the OS and Arch compatible with the results of `uname`.
builds:
- matrix-host-notification
- matrix-service-notification
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
files:
- cfg/*
- COPYING
- README.md
checksum:
name_template: "checksums.txt"
changelog:
sort: asc
snapshot:
version_template: "{{ incpatch .Version }}-next"
nfpms:
- package_name: icinga2-matrix-notification
builds:
- matrix-host-notification
- matrix-service-notification
file_name_template: "{{ .ProjectName }}_{{ .Version }}-1_{{ .Arch }}"
vendor: Jan Dittberner
maintainer: Jan Dittberner <jan@dittberner.info>
description: |-
Icinga2 notification commands to send notifications to Matrix chat rooms
The icinga2-matrix-notification package contains notification commands to send
Icinga2 host and service status notifications to Matrix chat rooms.
.
The package contains configuration examples that need to be copied and adapted
for your Icinga 2 installation.
formats:
- deb
bindir: /usr/lib/nagios/plugins
section: utils
release: "1"
priority: optional
deb:
lintian_overrides:
- statically-linked-binary
- initial-upload-closes-no-bugs
recommends:
- icinga2
contents:
- src: debian/changelog.Debian.gz
dst: /usr/share/doc/{{ .ProjectName }}/changelog.Debian.gz
file_info:
mode: 0644
- src: debian/copyright
dst: /usr/share/doc/{{ .ProjectName }}/copyright
file_info:
mode: 0644
- src: README.md
dst: /usr/share/doc/{{ .ProjectName }}/README.md
file_info:
mode: 0644
- src: cfg/command.cfg
dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/command.cfg
file_info:
mode: 0644
- src: cfg/services.cfg
dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/services.cfg
file_info:
mode: 0644
- src: cfg/templates.cfg
dst: /usr/share/doc/{{ .ProjectName }}/examples/cfg/templates.cfg
file_info:
mode: 0644
release:
gitea:
owner: jan
name: "icinga2-matrix-notification"
gitea_urls:
api: https://git.dittberner.info/api/v1
download: https://git.dittberner.info

View file

@ -2,7 +2,7 @@
object NotificationCommand "matrix-host-notification" { object NotificationCommand "matrix-host-notification" {
import "plugin-notification-command" import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/matrix-host-notification" ] command = [ PluginDir + "/matrix-host-notification" ]
arguments += { arguments += {
"-4" = "$notification_address$" "-4" = "$notification_address$"
"-6" = "$notification_address6$" "-6" = "$notification_address6$"
@ -61,7 +61,7 @@ object NotificationCommand "matrix-host-notification" {
object NotificationCommand "matrix-service-notification" { object NotificationCommand "matrix-service-notification" {
import "plugin-notification-command" import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/matrix-service-notification" ] command = [ PluginDir + "/matrix-service-notification" ]
arguments += { arguments += {
"-4" = { "-4" = {
required = true required = true
@ -99,10 +99,6 @@ object NotificationCommand "matrix-service-notification" {
required = true required = true
value = "$notification_servicestate$" value = "$notification_servicestate$"
} }
"-t" = {
required = true
value = "$notification_type$"
}
"-u" = { "-u" = {
required = true required = true
value = "$notification_servicedisplayname$" value = "$notification_servicedisplayname$"

5
debian/changelog vendored Normal file
View file

@ -0,0 +1,5 @@
icinga2-matrix-notification (0.1.0-1) unstable; urgency=medium
* Initial release
-- Jan Dittberner <jandd@debian.org> Thu, 26 Sep 2024 15:45:07 +0200

26
debian/copyright vendored Normal file
View file

@ -0,0 +1,26 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://git.dittberner.info/jan/icinga2-matrix-notification
Upstream-Name: icinga2-matrix-notification
Upstream-Contact: Jan Dittberner <jan@dittberner.info>
Files:
*
Copyright: 2024 Jan Dittberner
License: GPL-3+
License: GPL-3+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this package; if not, see &lt;https://www.gnu.org/licenses/&gt;.
Comment:
On Debian systems, the full text of the GNU General Public License
version 2 can be found in the file '/usr/share/common-licenses/GPL-2'.