Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapcraft: Add snap packaging #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: nsd-exporter
base: core20
version: git
grade: stable
summary: Prometheus exporter for NSD (Name Server Daemon)
description: |-
Prometheus exporter for NSD (Name Server Daemon)

confinement: strict

architectures:
- build-on: amd64
- build-on: arm64
- build-on: armhf
- build-on: ppc64el
- build-on: s390x

apps:
nsd-exporter:
command: daemon.start
daemon: simple
plugs:
- network
- network-bind

parts:
nsd-exporter:
source: .
plugin: go
prime:
- bin/nsd_exporter

wrappers:
plugin: dump
source: .snapcraft/
16 changes: 16 additions & 0 deletions .snapcraft/daemon.start
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh -eu
for i in "${SNAP_DATA}/nsd_server.pem" "${SNAP_DATA}/nsd_control.key" "${SNAP_DATA}/nsd_control.pem"; do
if ! [ -e "${i}" ]; then
echo "Missing certificate file: ${i}"
snapctl stop nsd-exporter.nsd-exporter
exit 0
fi
done

export GODEBUG="x509ignoreCN=0"
exec nsd_exporter \
-listen-address :9167 \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with snap, how do you document to the user that the default listen address is different on snap?

-nsd-address 127.0.0.1:8952 \
-ca "${SNAP_DATA}/nsd_server.pem" \
-key "${SNAP_DATA}/nsd_control.key" \
-cert "${SNAP_DATA}/nsd_control.pem"