File observatorium-cli.spec of Package observatorium-cli
#
# spec file for package observatorium-cli
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define __arch_install_post export NO_BRP_STRIP_DEBUG=true
%define executable_name obsctl
Name: observatorium-cli
Version: 0.1.0~rc.0
Release: 0
Summary: Cli to interact with Observatorium instances
License: Apache-2.0
URL: https://github.com/observatorium/obsctl
Source: obsctl-%{version}.tar.gz
Source1: vendor.tar.gz
# https://raw.githubusercontent.com/observatorium/obsctl/main/.promu.yml
Source2: promu.yml
BuildRequires: go >= 1.22
BuildRequires: golang-github-prometheus-promu
%description
A CLI to interact with Observatorium instances as a tenant and get/set various
resources.
Goals
Currently, we do not have a simple and convenient way to interact with the
Observatorium API from the command line. Manually crafting cURL commands while
authenticating with OIDC or mTLS is not an optimal experience and is generally
confusing/trickier for users, both old and new.
obsctl aims to greatly simplifies this process by storing the configuration for
multiple tenants and instances of the Observatorium API locally and allowing
users to switch between them and perform operations.
Features
* Manage authentication configuration for multiple tenants/APIs by saving them locally
* Allow users to switch between tenants/APIs conveniently
* View metrics-based resources series, rules, and labels for a tenant
* Configure and view Prometheus rules for a tenant
obsctl also aims to support more such one-off operations for other domains as
well (logs, traces, alert-routing configs)
%package -n %{name}-bash-completion
Summary: Bash Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Requires: bash-completion
Supplements: (%{name} and bash-completion)
BuildArch: noarch
%description -n %{name}-bash-completion
Bash command line completion support for %{name}.
%package -n %{name}-fish-completion
Summary: Fish Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Supplements: (%{name} and fish)
BuildArch: noarch
%description -n %{name}-fish-completion
Fish command line completion support for %{name}.
%package -n %{name}-zsh-completion
Summary: Zsh Completion for %{name}
Group: System/Shells
Requires: %{name} = %{version}
Supplements: (%{name} and zsh)
BuildArch: noarch
%description -n %{name}-zsh-completion
zsh command line completion support for %{name}.
%prep
%autosetup -p 1 -a 1 -n obsctl-%{version}
# not yet included in version 0.1.0-rc.0
cp %{SOURCE2} .promu.yml
%build
sed -i '/flags/ s/-a -tags/-buildmode=pie -a -tags/g' .promu.yml
GOPATH=%{_builddir}/go promu build -v
%install
# Install the binary.
install -D -m 0755 %{executable_name} %{buildroot}/%{_bindir}/%{executable_name}
# create the bash completion file
mkdir -p %{buildroot}%{_datarootdir}/bash-completion/completions/
%{buildroot}/%{_bindir}/%{executable_name} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{executable_name}
# create the fish completion file
mkdir -p %{buildroot}%{_datarootdir}/fish/vendor_completions.d/
%{buildroot}/%{_bindir}/%{executable_name} completion fish > %{buildroot}%{_datarootdir}/fish/vendor_completions.d/%{executable_name}.fish
# create the zsh completion file
mkdir -p %{buildroot}%{_datarootdir}/zsh_completion.d/
%{buildroot}/%{_bindir}/%{executable_name} completion zsh > %{buildroot}%{_datarootdir}/zsh_completion.d/_%{executable_name}
%check
%files
%doc README.md
%license LICENSE
%{_bindir}/%{executable_name}
%files -n %{name}-bash-completion
%dir %{_datarootdir}/bash-completion/completions/
%{_datarootdir}/bash-completion/completions/%{executable_name}
%files -n %{name}-fish-completion
%dir %{_datarootdir}/fish
%dir %{_datarootdir}/fish/vendor_completions.d
%{_datarootdir}/fish/vendor_completions.d/%{executable_name}.fish
%files -n %{name}-zsh-completion
%defattr(-,root,root)
%dir %{_datarootdir}/zsh_completion.d/
%{_datarootdir}/zsh_completion.d/_%{executable_name}
%changelog