# Generated by go2rpm 1.8.0
%bcond_without check

# https://github.com/fluxcd/flux2
%global goipath         github.com/fluxcd/flux2
%global goname          flux
Version:                0.35.0

%gometa

%global common_description %{expand:
Open and extensible continuous delivery solution for Kubernetes. Powered by
GitOps Toolkit.}

%global golicenses      LICENSE
%global godocs          docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md\\\
                        action/README.md install/README.md\\\

Name:           %{goname}
Release:        %autorelease
Summary:        Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit

License:        Apache-2.0
URL:            %{gourl}
Source:         %{name}-%{version}.tar.gz
Source1:        %{name}-%{version}-vendored-deps.tar.gz
Source2:        bundled.inc
Source3:        %{name}-%{version}-bundled-manifests.tar.gz

%include        %SOURCE2

%description %{common_description}

%gopkg

%prep
%autosetup -n %{name}2-%{version}
tar -xf %SOURCE1 --strip-components=1
tar -xf %SOURCE3 --strip-components=1
%goprep -e -k
# RFCs change often, and create a burden for godocs
rm -r rfcs/

%build
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done
# Generate shell completions
%{gobuilddir}/bin/flux completion bash > flux.bash
%{gobuilddir}/bin/flux completion fish > flux.fish
%{gobuilddir}/bin/flux completion zsh  > flux.zsh

%install
%gopkginstall
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
# Install shell completions
install -Dpm 0644 flux.bash %{buildroot}%{_datadir}/bash-completion/completions/flux
install -Dpm 0644 flux.fish %{buildroot}%{_datadir}/fish/vendor_completions.d/flux.fish
install -Dpm 0644 flux.zsh  %{buildroot}%{_datadir}/zsh/site-functions/_flux


%if %{with check}
%check
# Requires Internet
for test in "TestCreateGitSecret" "TestGenerate" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
# Not found in vendor tree?
%gocheck -d tests/azure
%endif

%files
%license LICENSE
%doc docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md action/README.md
%doc install/README.md
%{_bindir}/*
%dir %{_datadir}/bash-completion
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/flux
%dir %{_datadir}/fish
%dir %{_datadir}/fish/vendor_completions.d
%{_datadir}/fish/vendor_completions.d/flux.fish
%dir %{_datadir}/zsh
%dir %{_datadir}/zsh/site-functions
%{_datadir}/zsh/site-functions/_flux

%gopkgfiles

%changelog
%autochangelog