File kubectl-get-all.spec of Package kubectl-get-all
#
# spec file for package kubectl-get-all
#
# Copyright (c) 2021 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 kubectl_plugin_name=kubectl-get_all
Name: kubectl-get-all
Version: 1.3.8
Release: 0
Summary: Like 'kubectl get all', but get really all resources
License: Apache-2.0
URL: https://github.com/corneliusweig/ketall
Source: ketall-%{version}.tar.gz
Source1: vendor.tar.gz
BuildRequires: go >= 1.16
BuildRequires: fdupes
Provides: ketall = %{version}
%description
Kubectl plugin to show really all kubernetes resources
For a complete overview of all resources in a kubernetes cluster, kubectl get all --all-namespaces is not enough, because it simply does not show everything. This helper lists really all resources the cluster has to offer.
%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}-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
%setup -q -n ketall-%{version}
%setup -q -T -D -a 1 -n ketall-%{version}
%build
DATE_FMT="+%%Y-%%m-%%dT%%H:%%M:%%SZ"
BUILD_DATE=$(date -u -d "@${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "${DATE_FMT}" 2>/dev/null || date -u "${DATE_FMT}")
go build \
-mod=vendor \
--buildmode=pie \
-ldflags="-X github.com/corneliusweig/ketall/internal/version.version=%{version} \
-X github.com/corneliusweig/ketall/internal/version.gitCommit=v%{version} \
-X github.com/corneliusweig/ketall/internal/version.buildDate=$BUILD_DATE" \
-o bin/%{name}
%install
# Install the binary.
install -D -m 0755 bin/%{name} "%{buildroot}/%{_bindir}/%{kubectl_plugin_name}"
ln -s %{kubectl_plugin_name} "%{buildroot}/%{_bindir}/ketall"
# create the bash completion file
mkdir -p %{buildroot}%{_datarootdir}/bash-completion/completions/
%{buildroot}/%{_bindir}/%{kubectl_plugin_name} completion bash > %{buildroot}%{_datarootdir}/bash-completion/completions/%{name}
cp %{buildroot}%{_datarootdir}/bash-completion/completions/%{name} %{buildroot}%{_datarootdir}/bash-completion/completions/ketall
# create the zsh completion file
mkdir -p %{buildroot}%{_datarootdir}/zsh_completion.d/
%{buildroot}/%{_bindir}/%{kubectl_plugin_name} completion zsh > %{buildroot}%{_datarootdir}/zsh_completion.d/_%{name}
cp %{buildroot}%{_datarootdir}/zsh_completion.d/_%{name} %{buildroot}%{_datarootdir}/zsh_completion.d/_ketall
# remove duplicates
%fdupes %{buildroot}%{_datarootdir}
%files
%doc README.md
%license LICENSE
%{_bindir}/ketall
%{_bindir}/%{kubectl_plugin_name}
%files -n %{name}-bash-completion
%dir %{_datarootdir}/bash-completion/completions/
%{_datarootdir}/bash-completion/completions/%{name}
%{_datarootdir}/bash-completion/completions/ketall
%files -n %{name}-zsh-completion
%defattr(-,root,root)
%dir %{_datarootdir}/zsh_completion.d/
%{_datarootdir}/zsh_completion.d/_%{name}
%{_datarootdir}/zsh_completion.d/_ketall
%changelog