## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 6;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by go2rpm 1.8.1
%bcond_without check

# https://github.com/moby/swarmkit
%global goipath         github.com/moby/swarmkit/v2
%global forgeurl        https://github.com/moby/swarmkit
Version:                2.0.0
%global commit          139c54b5dae310e6cb74d18c85dc06393aa1bac1

%gometa -f

%global common_description %{expand:
A toolkit for orchestrating distributed systems at any scale. It includes
primitives for node discovery, raft-based consensus, task scheduling and more.}

%global golicenses      LICENSE
%global godocs          BUILDING.md CONTRIBUTING.md README.md

Name:           %{goname}
Release:        %autorelease -p -e pre1
Summary:        Toolkit for orchestrating distributed systems at any scale

License:        Apache-2.0
URL:            %{gourl}
Source:         %{gosource}
Patch0:         0001-Convert-BasicKeyRequest-to-KeyRequest-to-use-cloudfl.patch

BuildRequires:  golang(github.com/docker/libkv)
BuildRequires:  golang(github.com/docker/libkv/store)
BuildRequires:  golang(github.com/ishidawataru/sctp)
BuildRequires:  golang(github.com/phayes/permbits)

%description %{common_description}

%gopkg

%prep
%goprep
%patch0 -p1

%generate_buildrequires
%go_generate_buildrequires

%build
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

%install
%gopkginstall
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/

%if %{with check}
%check
for test in "TestValidateCAConfigValidValues" \
            "TestMixedFIPSClusterNonMandatoryFIPS" \
            "TestListManagerNodes" \
            "TestSuccessfulRootRotation" \
            "TestRestartLeader" \
            "TestDemoteLeader" \
            "TestDemotePromoteLeader" \
            "TestDemotePromote" \
            "TestNodeOps" \
            "TestAllocator" \
            "TestRaftLeaderLeave" \
            "TestCertRenewals" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
%gocheck -d agent -d ca -d manager/csi -d manager/orchestrator/jobs/replicated -d manager/scheduler -t manager/state/raft -t integration
%endif

%files
%license LICENSE
%doc BUILDING.md CONTRIBUTING.md README.md
%{_bindir}/*

%gopkgfiles

%changelog
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> 2.0.0-0.6.pre1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Tue Nov 01 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.0.0-0.5.pre1
- Disable some flaky tests

* Sun Oct 30 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.0.0-0.4.pre1
- Disable some flaky tests

* Sat Oct 22 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.0.0-0.3.pre1
- Disable some tests for ppc64le

* Sat Oct 22 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.0.0-0.2.pre1
- Disable some tests for ppc64le

* Sat Oct 22 2022 Robert-André Mauchin <zebob.m@gmail.com> 2.0.0-0.1.pre1
- Initial import