File kind.spec of Package kind

%define realname kind
%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://kind.sigs.k8s.io
Summary:       Kubernetes IN Docker - local clusters for testing Kubernetes

# Install-time parameters
Requires:      (docker or podman)

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

%description
kind is a tool for running local Kubernetes clusters using Docker
container "nodes". kind was primarily designed for testing Kubernetes
itself, but may be used for local development or CI.

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

# Build step (compile/build binaries, documentation, etc)
%build
# Build
go build \
  -a -v \
  -mod=vendor \
  -buildmode=pie \
  -gcflags=all=-dwarf=false \
  -ldflags='all=-s -w -X=sigs.k8s.io/kind/pkg/cmd/kind/version.GitCommit=%{version}' \
  -o bin/kind

# Install built stuff
%install
%{__install} -D -m0755 bin/kind %{buildroot}%{_bindir}/kind
%{__install} -d %{buildroot}%{_datadir}/bash-completion/completions/
bin/kind completion bash > %{buildroot}%{_datadir}/bash-completion/completions/kind

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

%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_bindir}/kind
%{_datadir}/bash-completion/completions/kind

%changelog
openSUSE Build Service is sponsored by