%global with_debug 0

%if 0%{?with_debug}
%global _find_debuginfo_dwz_opts %{nil}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif

%global shortname podman_exporter
%global provider github
%global provider_tld com
%global project containers
%global repo %{name}
%global import_path %{provider}.%{provider_tld}/%{project}/%{repo}
%global git0 https://%{import_path}

Name: prometheus-podman-exporter
Version: 1.15.0
Release: dev.20250301080659331638.pr339.25.g3184f29d%{?dist}
Summary: Prometheus exporter for podman environment.
License: ASL 2.0
URL: %{git0}
VCS: git+https://github.com/containers/prometheus-podman-exporter#3184f29de2cd2a1e104987f77e4dcb51f7bca638:
Source0: %{name}-1.15.0.tar.gz

%if 0%{?fedora} && ! 0%{?rhel}
BuildRequires: btrfs-progs-devel
%endif
BuildRequires: gcc
BuildRequires: golang
BuildRequires: glib2-devel
BuildRequires: glibc-devel
BuildRequires: glibc-static
BuildRequires: git-core
BuildRequires: go-rpm-macros
BuildRequires: make
BuildRequires: gpgme-devel
BuildRequires: device-mapper-devel
BuildRequires: libassuan-devel
%if 0%{?fedora} >= 35
BuildRequires: shadow-utils-subid-devel
%endif

%description
Prometheus exporter for podman environments exposing containers, pods, images,
volumes and networks information.

%prep
%setup -T -b 0 -q -n %{name}-1.15.0

%build
%set_build_flags
make binary

%install
install -dp %{buildroot}%{_bindir}
install -dp %{buildroot}%{_unitdir}
install -dp %{buildroot}%{_userunitdir}
install -p ./bin/%{name} %{buildroot}%{_bindir}
install -Dpm0644 ./contrib/systemd/system/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
install -Dpm0644 ./contrib/systemd/system/%{name}.service %{buildroot}%{_unitdir}/%{name}.service
install -Dpm0644 ./contrib/systemd/user/%{name}.service %{buildroot}%{_userunitdir}/%{name}.service

pushd %{buildroot}%{_unitdir}
ln -s %{name}.service %{shortname}.service
popd

pushd %{buildroot}%{_userunitdir}
ln -s %{name}.service %{shortname}.service
popd

pushd %{buildroot}%{_bindir}
ln -s %{name} %{shortname}
popd

%check

#define license tag if not already defined
%{!?_licensedir:%global license %doc}

%files
%license LICENSE
%doc README.md MAINTAINERS.md SECURITY.md CONTRIBUTING.md CODE_OF_CONDUCT.md
%{_bindir}/%{name}
%{_bindir}/%{shortname}
%{_sysconfdir}/sysconfig/%{name}
%{_unitdir}/%{name}.service
%{_unitdir}/%{shortname}.service
%{_userunitdir}/%{name}.service
%{_userunitdir}/%{shortname}.service


%changelog
* Sat Dec 14 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.15.0-dev-1

* Sat Dec 14 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.14.0-1
- Podman update to v5.3.1
- Bump github.com/prometheus/exporter-toolkit from 0.13.0 to 0.13.2
- Bump github.com/onsi/gomega from 1.36.0 to 1.36.1
- Bump github.com/onsi/ginkgo/v2 from 2.21.0 to 2.22.0
- Bump github.com/prometheus/common from 0.60.0 to 0.61.0

* Sat Aug 03 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.13.0-1
- New metric - container network dropped,errors,packets
- README.md update
- Go version 1.21.0
- Vagrant update to fedora 40
- Bump github.com/containers/podman/v5 from 5.1.0 to 5.2.0
- Bump github.com/containers/common from 0.59.1 to 0.59.2
- Bump github.com/containers/image/v5 from 5.31.0 to 5.31.1
- Bump github.com/prometheus/common from 0.53.0 to 0.55.0
- Bump github.com/spf13/cobra from 1.8.0 to 1.8.1
- Bump github.com/onsi/ginkgo/v2 from 2.19.0 to 2.19.1
- Bump github.com/onsi/gomega from 1.33.1 to 1.34.1

* Sun Jun 02 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.12.0-1
- Bump github.com/containers/podman from 5.0.3 to 5.1.0
- Bump github.com/containers/image/v5 from 5.30.1 to 5.31.0
- Bump github.com/containers/common from 0.58.3 to 0.59.0
- Bump github.com/prometheus/common from 0.48.0 to 0.53.0
- Bump github.com/onsi/ginkgo/v2 from 2.17.3 to 2.19.0
- github action update - codespell + podman v5 image

* Thu Mar 21 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.11.0-1
- Podman v5 support (5.0.0)
- Bump github.com/containers/image/v5 to v5.30.0
- Bump github.com/containers/common to v0.58.0
- Bump github.com/go-jose/go-jose/v3 from 3.0.1 to 3.0.3 - CVE-2024-28180
- Bump gopkg.in/go-jose/go-jose.v2 from 2.6.1 to 2.6.3 - CVE-2024-28180

* Sun Mar 17 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.10.1-1
- systemd use default.target + users environment file path
- Add openrc service and it's config file
- Add systemd user service...
- fix userns option for rootless unix socket use case in install.md

* Sat Mar 16 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.10.0-1
- Enhance all metrics with the same fields as for podman_<...>_info metric
- Cached scraping of container size
- Unit test + e2e test
- Golangci-lint update 1.56.2
- Vagrantfile update (fedora 39)
- install.md update - ArchLinux (AUR)
- install.md update - AlmaLinux and Rocky Linux
- github action update
- rpm spec update
- Bump github.com/onsi/ginkgo/v2 from 2.15.0 to 2.16.0

* Wed Feb 28 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.9.0-1
- Fix exporter panic when using cli store_labels option
- Bump github.com/containers/podman/v4 from 4.9.2 to 4.9.3
- Bump github.com/prometheus/client_golang from 1.18.0 to 1.19.0
- Bump github.com/prometheus/common from 0.46.0 to 0.48.0

* Sun Feb 04 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.8.0-1
- Add pod_id and pod_name to all container metrics
- Fix inconsistent label cardinality on image scrap
- Add digest (sha256) labels for container info metric
- Cache scrapping of images
- Bump github.com/containers/podman/v4 to 4.9.2
- Bump github.com/containers/common to 0.57.4
- Bump github.com/containers/image/v5 to v5.29.2
- Go version update to 1.20

* Sun Jan 21 2024 Navid Yaghoobi <navidys@fedoraproject.org> 1.7.0-1
- Bump github.com/containers/podman/v4 from 4.8.2 to 4.8.3
- Bump github.com/containers/common from 0.57.1 to 0.57.2
- Bump github.com/prometheus/common from 0.45.0 to 0.46.0
- Bump github.com/prometheus/client_golang from 1.17.0 to 1.18.0
- Bump github.com/prometheus/exporter-toolkit from 0.10.0 to 0.11.0
- Github action use golang 1.21.4 for golangci-lint

* Fri Dec 01 2023 Navid Yaghoobi <navidys@fedoraproject.org> 1.6.0-1
- Bump github.com/containers/podman/v4 from 4.7.2 to 4.8.0
- Bump github.com/containers/image/v5 from 5.28.0 to 5.29.0
- Docs (install.md) update: add Gentoo packaged version
- Packit configuration update
- Github actions update

* Sat Nov 11 2023 Navid Yaghoobi <navidys@fedoraproject.org> 1.5.0-1
- Update install.md - official fedora and epel rpm package
- GH action fix container build push
- Bump github.com/containers/podman/v4 to 4.7.2
- Bump github.com/containers/image to 5.28.0
- Bump github.com/containers/common to 0.56.0
- Bump github.com/prometheus/common from 0.44.0 to 0.45.0
- Bump github.com/spf13/cobra from 1.7.0 to 1.8.0
- Running codespell
- Bump github.com/prometheus/client_golang from 1.16.0 to 1.17.0
- Multiarch container image build
- Packit update for multiarch build + centos-stream build

* Sun Sep 17 2023 Navid Yaghoobi <navidys@fedoraproject.org> 1.4.0-1
- Add support for HTTPS & authentication
- Vagrantfile update (fedora-38 image)
- Golangci-lint update to v1.51.1
- Remove .cirrus.yml configuration and using .github workflow
- Add packit configuration to build RPM as part of PR tests
- Packit update - remove centos9 RPM stream build (EPEL9 available)
- Bump github.com/containers/podman/v4 from 4.5.1 to 4.6.2
- Bump github.com/containers/image/v5 from 5.26.1 to 5.27.0
- Bump github.com/containers/common from 0.53.0 to 0.55.2
- Bump github.com/prometheus/client_golang from 1.15.1 to 1.16.0
- Bump github.com/sirupsen/logrus from 1.9.0 to 1.9.3
- Bump github.com/prometheus/exporter-toolkit from 0.9.1 to 0.10.0
- Bump github.com/spf13/cobra from 1.6.1 to 1.7.0

* Sat Feb 25 2023 Navid Yaghoobi <navidys@fedoraproject.org> 1.3.0
- Add health status in container metrics
- update net/block io metric help string to include the type (bytes)
- Fix copy-pasted root example
- Bump podman/v4 to v4.4.2
- Bump github.com/containers/image/v5 from 5.23.1 to 5.24.2
- Bump github.com/prometheus/common from 0.39.0 to 0.40.0
- Bump github.com/prometheus/common from 0.38.0 to 0.39.0
- Bump github.com/prometheus/common from 0.37.0 to 0.38.0
- Bump github.com/prometheus/exporter-toolkit from 0.8.1 to 0.8.2
- github workflow - quay.io container image tag fix

* Sun Nov 20 2022 Navid Yaghoobi <navidys@fedoraproject.org> 1.2.0-1
- Convert pod/container/image labels on prometheus metrics
- Github workflow - build container image
- Makefile update - add vendor check target
- Vagrant box update to fc37
- Do not init podman registry if --version flag is enabled
- Running codespell
- Fix trivial golangci-lint issues
- Fix golangci failure in cirrus
- Fix export crash when pod is created without infra container
- Bump github.com/containers/podman/v4 from 4.3.0 to 4.3.1
- Bump containers/podman (v4.3.0), common (v0.51.1) and image/v5 (v5.23.0)
- Bump github.com/prometheus/client_golang from 1.13.1 to 1.14.0
- Bump github.com/prometheus/client_golang from 1.13.0 to 1.13.1
- Bump prometheus/exporter-toolkit from 0.7.1 to 0.8.1
- Bump github.com/spf13/cobra from 1.6.0 to 1.6.1
- Bump github.com/spf13/cobra from 1.5.0 to 1.6.0

* Sun Sep 11 2022 Navid Yaghoobi <navidys@fedoraproject.org> 1.1.0-1
- Fix image metrics gathering error (collected before)
- Added container exit code to list of exported metrics
- Image repo and name parse issue fix
- Added container started and exited time metrics
- Docs (install.md) update - exporter container and unix socket file
- Fix build and vendoring issue
- Bump github.com/containers/podman/v4 from 4.2.0 to 4.2.1
- Bump github.com/containers/podman/v4 from 4.1.1 to 4.2.0
- Bump github.com/prometheus/client_golang from 1.12.2 to 1.13.0
- Bump github.com/containers/common from 0.48.0 to 0.49.0
- Bump github.com/sirupsen/logrus from 1.8.1 to 1.9.0
- Bump github.com/prometheus/common from 0.36.0 to 0.37.0
- Bump github.com/prometheus/common from 0.35.0 to 0.36.0

* Sun Jul 03 2022 Navid Yaghoobi <navidys@fedoraproject.org> 1.0.0-1
- initial release