This commit is contained in:
commit
666a0b379a
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
[Makefile]
|
||||||
|
indent_style = tab
|
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Makefile eol=lf txt
|
27
.github/workflows/build-merge-request.yaml
vendored
Normal file
27
.github/workflows/build-merge-request.yaml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: build-merge-request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [ "opened", "reopened", "synchronize" ]
|
||||||
|
push:
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_PULL_HOST: ${{ secrets.REGISTRY_PULL_HOST }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
env:
|
||||||
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
|
# Skip the job if the CI was triggered by a pull request that was merged,
|
||||||
|
# because the CI was already running for the pull request.
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-your-pull_request-workflow-when-a-pull-request-merges
|
||||||
|
if: github.event.pull_request.merged == false
|
||||||
|
runs-on:
|
||||||
|
- podman
|
||||||
|
steps:
|
||||||
|
- uses: dedalus-cis4u/with-standard-setup@v2.0.1
|
||||||
|
- name: Run build
|
||||||
|
run: |
|
||||||
|
make container-run/build/build-settings.rpm \
|
||||||
|
BUILD_IMAGE_REGISTRY_HOST=${REGISTRY_PULL_HOST}
|
24
.github/workflows/push-tagged.yaml
vendored
Normal file
24
.github/workflows/push-tagged.yaml
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
name: push-tagged
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY_PULL_HOST: ${{ secrets.REGISTRY_PULL_HOST }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push-tagged:
|
||||||
|
env:
|
||||||
|
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
|
||||||
|
if: github.repository == 'dedalus-cis4u/build-settings-rpm'
|
||||||
|
runs-on:
|
||||||
|
- podman
|
||||||
|
steps:
|
||||||
|
- uses: dedalus-cis4u/with-standard-setup@v2.0.1
|
||||||
|
- name: Run build
|
||||||
|
run: |
|
||||||
|
make container-run/deploy/build-settings.rpm \
|
||||||
|
BUILD_IMAGE_REGISTRY_HOST=${REGISTRY_PULL_HOST} \
|
||||||
|
VERSION=${GITHUB_REF_NAME}
|
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pkg
|
||||||
|
src/prometheus-x509-certificate-exporter
|
||||||
|
*.rpm
|
||||||
|
**/*.iml
|
||||||
|
**/*.idea
|
52
Makefile
Normal file
52
Makefile
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# VERSION / RELEASE
|
||||||
|
# If no version is specified as a parameter of make, the last git hash
|
||||||
|
# value is taken.
|
||||||
|
EPOCH=0
|
||||||
|
VERSION?=3.18.0
|
||||||
|
RELEASE=0
|
||||||
|
ARCH=x86_64
|
||||||
|
|
||||||
|
# RPM_PACKAGE_NAME
|
||||||
|
# Defines the name of the rpm package. This name is required to install the rpm package with an rpm package manager like
|
||||||
|
# dnf, rpm or yum.
|
||||||
|
RPM_PACKAGE_NAME=prometheus-x509-certificate-exporter
|
||||||
|
RPM_FILE_NAME_SHORT=${RPM_PACKAGE_NAME}.rpm
|
||||||
|
RPM_FILE_NAME_FULL:=${RPM_PACKAGE_NAME}-${EPOCH}-${VERSION}-${RELEASE}.${ARCH}.rpm
|
||||||
|
|
||||||
|
root_dir:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||||
|
|
||||||
|
# BUILD
|
||||||
|
# ==============================================================================
|
||||||
|
PHONY:=${RPM_FILE_NAME_SHORT}
|
||||||
|
${RPM_FILE_NAME_SHORT}: ${RPM_FILE_NAME_FULL}
|
||||||
|
|
||||||
|
${RPM_FILE_NAME_FULL}: clean
|
||||||
|
|
||||||
|
git clone https://github.com/enix/x509-certificate-exporter.git ./src/${RPM_PACKAGE_NAME}
|
||||||
|
go build -C ./src/${RPM_PACKAGE_NAME}/cmd/x509-certificate-exporter/ -o ${RPM_PACKAGE_NAME}
|
||||||
|
|
||||||
|
install -D --mode 0644 "${root_dir}/src/systemd.service" "${root_dir}/pkg/usr/lib/systemd/system/${RPM_PACKAGE_NAME}.service"
|
||||||
|
install -D --mode 0755 --target-directory "${root_dir}/pkg/usr/bin" "${root_dir}/src/${RPM_PACKAGE_NAME}/cmd/x509-certificate-exporter/${RPM_PACKAGE_NAME}"
|
||||||
|
install -D --mode 0600 /dev/null "${root_dir}/pkg/etc/conf.d/${RPM_PACKAGE_NAME}"
|
||||||
|
install -D --mode 0755 --target-directory "${root_dir}/pkg/usr/share/licenses/${RPM_PACKAGE_NAME}" "${root_dir}/src/${RPM_PACKAGE_NAME}/LICENSE"
|
||||||
|
|
||||||
|
rpm-builder \
|
||||||
|
--dir pkg/:/ \
|
||||||
|
--epoch ${EPOCH} \
|
||||||
|
--version ${VERSION} \
|
||||||
|
--release ${RELEASE} \
|
||||||
|
--arch ${ARCH} \
|
||||||
|
--out ${RPM_FILE_NAME_FULL} \
|
||||||
|
${RPM_PACKAGE_NAME}
|
||||||
|
|
||||||
|
# # CLEAN
|
||||||
|
# # ==============================================================================
|
||||||
|
clean:
|
||||||
|
- rm --force --recursive ./pkg ./src/${RPM_PACKAGE_NAME}
|
||||||
|
- rm --force ${RPM_FILE_NAME_FULL}
|
||||||
|
|
||||||
|
# PHONY
|
||||||
|
# ==============================================================================
|
||||||
|
# Declare the contents of the PHONY variable as phony. We keep that information
|
||||||
|
# in a variable so we can use it in if_changed.
|
||||||
|
.PHONY: ${PHONY}
|
18
src/systemd.service
Normal file
18
src/systemd.service
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Prometheus exporter for x509 certificate metrics
|
||||||
|
Requires=network-online.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
EnvironmentFile=-/etc/conf.d/prometheus-x509-certificate-exporter
|
||||||
|
ExecStart=/usr/bin/prometheus-x509-certificate-exporter $EXTRA_ARGS
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
|
User=root
|
||||||
|
Group=root
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
|
||||||
|
NoNewPrivileges=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user