File kube-capacity.spec of Package kube-capacity

%define realname kube-capacity
%define srcext   tar.xz

%if ! 0%{?go_os:1}
%define go_os %(go env GOOS)
%endif
%if ! 0%{?go_arch:1}
%define go_arch %(go env GOARCH)
%endif

# Common info
Name:          %{realname}
Version:       0
Release:       wiz%{?extraver:0.}1%{?dist}
License:       Apache-2.0
Group:         System/Management
URL:           https://github.com/robscott/kube-capacity
Summary:       Utility providing an overview of host resources in a K8s cluster

# Build-time parameters
BuildRequires: go
BuildRoot:     %{_tmppath}/%{name}-root
Source0:       %{realname}-%{version}.%{srcext}
# go mod vendor -v && tar -Jcvf ../vendor.tar.xz vendor && rm -rf vendor/
Source1:       vendor.tar.xz

%description
This is a simple CLI that provides an overview of the resource requests, limits,
and utilization in a Kubernetes cluster. It attempts to combine the best parts
of the output from kubectl top and kubectl describe into an easy to use CLI
focused on cluster resources.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-%{version}%{?extraver} -a1

# Build step (compile/build binaries, documentation, etc)
%build
go build -v -mod=vendor -buildmode=pie \
    -gcflags=all=-dwarf=false \
    -ldflags='all=-s -w' \
    -o bin/kube-capacity

# Install built stuff
%install
%{__install} -D -m0755 bin/kube-capacity %{buildroot}%{_bindir}/kube-capacity

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

# Files
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_bindir}/kube-capacity

%changelog
openSUSE Build Service is sponsored by