# Generated by go2rpm 1.8.1
%bcond_without check

#debuginfo not supported with Go
%global debug_package %{nil}

# https://github.com/openshift/oc
%global goipath         github.com/openshift/oc
Version:                4.10.0
%global commit          442535c4d8b2734811309cffadb4f70560cf730f

%global golang_version 1.17
%global kubernetes_version 1.23.0

%gometa

%global common_description %{expand:
With OpenShift Client CLI (oc), you can create applications and manage OpenShift resources. It is built on top of kubectl which means it provides its full capabilities to connect with any kubernetes compliant cluster, and on top adds commands simplifying interaction with an OpenShift cluster.}

%global golicenses      LICENSE
%global godocs          docs README.md examples

Name:           openshift-clients
Release:        3%{dist}
Summary:        The OpenShift Command Line, part of OKD

License:        Apache-2.0
URL:            %{gourl}
Source0:        https://%{goipath}/archive/%{commit}/oc-%{commit}.tar.gz 
# We need the full kubernetes source to be able to generate man pages for kubectl, which we provide
Source1:        https://github.com/kubernetes/kubernetes/archive/v%{kubernetes_version}/kubernetes-v%{kubernetes_version}.tar.gz

Source2:        vendor2provides.py

BuildRequires:  git-core
BuildRequires:  golang >= %{golang_version}
BuildRequires:  krb5-devel
BuildRequires:  rsync
BuildRequires:  gpgme-devel

Provides:       atomic-openshift-clients = %{version}
Provides:       kubectl = %{kubernetes_version}
Provides:       oc = %{version}
Obsoletes:      atomic-openshift-clients <= %{version}
Obsoletes:      kubectl <= %{kubernetes_version}
Requires:       bash-completion

# vendored libraries
# fedpkg prep
# ./vendor2provides.py oc-%%{commit}/vendor/modules.txt
Provides:       bundled(golang(cloud.google.com/go)) = 0.81.0
Provides:       bundled(golang(github.com/AaronO/go-git-http)) = 1d9485b
Provides:       bundled(golang(github.com/Azure/go-ansiterm)) = d185dfc
Provides:       bundled(golang(github.com/Azure/go-autorest)) = 14.2.0+incompatible
Provides:       bundled(golang(github.com/Azure/go-autorest/autorest)) = 0.11.18
Provides:       bundled(golang(github.com/Azure/go-autorest/autorest/adal)) = 0.9.13
Provides:       bundled(golang(github.com/Azure/go-autorest/autorest/date)) = 0.3.0
Provides:       bundled(golang(github.com/Azure/go-autorest/logger)) = 0.2.1
Provides:       bundled(golang(github.com/Azure/go-autorest/tracing)) = 0.6.0
Provides:       bundled(golang(github.com/BurntSushi/toml)) = 0.3.1
Provides:       bundled(golang(github.com/MakeNowJust/heredoc)) = bb23615
Provides:       bundled(golang(github.com/Microsoft/go-winio)) = 0.5.0
Provides:       bundled(golang(github.com/Microsoft/hcsshim)) = 0.8.20
Provides:       bundled(golang(github.com/PuerkitoBio/purell)) = 1.1.1
Provides:       bundled(golang(github.com/PuerkitoBio/urlesc)) = de5bf2a
Provides:       bundled(golang(github.com/RangelReale/osincli)) = fababb0
Provides:       bundled(golang(github.com/alexbrainman/sspi)) = e580b90
Provides:       bundled(golang(github.com/alicebob/sqlittle)) = 1.4.0
Provides:       bundled(golang(github.com/openshift/gssapi)) = 5fb4217
Provides:       bundled(golang(github.com/aws/aws-sdk-go)) = 1.35.24
Provides:       bundled(golang(github.com/beorn7/perks)) = 1.0.1
Provides:       bundled(golang(github.com/blang/semver)) = 3.5.1+incompatible
Provides:       bundled(golang(github.com/cespare/xxhash/v2)) = 2.1.1
Provides:       bundled(golang(github.com/chai2010/gettext-go)) = c6fed77
Provides:       bundled(golang(github.com/containerd/cgroups)) = 1.0.1
Provides:       bundled(golang(github.com/containerd/containerd)) = 1.5.1
Provides:       bundled(golang(github.com/containerd/continuity)) = 0.1.0
Provides:       bundled(golang(github.com/containers/image/v5)) = 5.15.0
Provides:       bundled(golang(github.com/containers/libtrust)) = 14b9617
Provides:       bundled(golang(github.com/containers/ocicrypt)) = 1.1.2
Provides:       bundled(golang(github.com/containers/storage)) = 1.33.0
Provides:       bundled(golang(github.com/davecgh/go-spew)) = 1.1.1
Provides:       bundled(golang(github.com/daviddengcn/go-colortext)) = 511bcaf
Provides:       bundled(golang(github.com/docker/distribution)) = 2.7.1+incompatible
Provides:       bundled(golang(github.com/docker/docker)) = 20.10.3+incompatible
Provides:       bundled(golang(github.com/docker/docker-credential-helpers)) = 0.6.4
Provides:       bundled(golang(github.com/docker/go-connections)) = 0.4.0
Provides:       bundled(golang(github.com/docker/go-metrics)) = 0.0.1
Provides:       bundled(golang(github.com/docker/go-units)) = 0.4.0
Provides:       bundled(golang(github.com/docker/libtrust)) = aabc10e
Provides:       bundled(golang(github.com/elazarl/goproxy)) = ecfe977
Provides:       bundled(golang(github.com/emicklei/go-restful)) = 2.9.5+incompatible
Provides:       bundled(golang(github.com/evanphx/json-patch)) = 4.12.0+incompatible
Provides:       bundled(golang(github.com/exponent-io/jsonpath)) = d6023ce
Provides:       bundled(golang(github.com/fatih/camelcase)) = 1.0.0
Provides:       bundled(golang(github.com/form3tech-oss/jwt-go)) = 3.2.3+incompatible
Provides:       bundled(golang(github.com/fsnotify/fsnotify)) = 1.4.9
Provides:       bundled(golang(github.com/fsouza/go-dockerclient)) = 1.7.1
Provides:       bundled(golang(github.com/fvbommel/sortorder)) = 1.0.1
Provides:       bundled(golang(github.com/ghodss/yaml)) = 1.0.0
Provides:       bundled(golang(github.com/go-errors/errors)) = 1.0.1
Provides:       bundled(golang(github.com/go-git/gcfg)) = 1.5.0
Provides:       bundled(golang(github.com/go-git/go-billy/v5)) = 5.1.0
Provides:       bundled(golang(github.com/go-git/go-git/v5)) = 5.3.0
Provides:       bundled(golang(github.com/go-logr/logr)) = 1.2.2
Provides:       bundled(golang(github.com/go-openapi/jsonpointer)) = 0.19.5
Provides:       bundled(golang(github.com/go-openapi/jsonreference)) = 0.19.5
Provides:       bundled(golang(github.com/go-openapi/swag)) = 0.19.14
Provides:       bundled(golang(github.com/gogo/protobuf)) = 1.3.2
Provides:       bundled(golang(github.com/golang/groupcache)) = 41bb18b
Provides:       bundled(golang(github.com/golang/protobuf)) = 1.5.2
Provides:       bundled(golang(github.com/golangplus/testing)) = 1.0.0
Provides:       bundled(golang(github.com/gonum/blas)) = f22b278
Provides:       bundled(golang(github.com/gonum/floats)) = c233463
Provides:       bundled(golang(github.com/gonum/graph)) = 50b27de
Provides:       bundled(golang(github.com/gonum/internal)) = f884aa7
Provides:       bundled(golang(github.com/gonum/lapack)) = e4cdc5a
Provides:       bundled(golang(github.com/gonum/mathext)) = 8a4bf00
Provides:       bundled(golang(github.com/gonum/matrix)) = c518dec
Provides:       bundled(golang(github.com/gonum/stat)) = 41a0da7
Provides:       bundled(golang(github.com/google/btree)) = 1.0.1
Provides:       bundled(golang(github.com/google/go-cmp)) = 0.5.6
Provides:       bundled(golang(github.com/google/gofuzz)) = 1.2.0
Provides:       bundled(golang(github.com/google/shlex)) = e7afc7f
Provides:       bundled(golang(github.com/google/uuid)) = 1.2.0
Provides:       bundled(golang(github.com/googleapis/gnostic)) = 0.5.5
Provides:       bundled(golang(github.com/gorilla/mux)) = 1.8.0
Provides:       bundled(golang(github.com/gregjones/httpcache)) = 9cad4c3
Provides:       bundled(golang(github.com/hashicorp/errwrap)) = 1.0.0
Provides:       bundled(golang(github.com/hashicorp/go-multierror)) = 1.1.1
Provides:       bundled(golang(github.com/imdario/mergo)) = 0.3.12
Provides:       bundled(golang(github.com/inconshreveable/mousetrap)) = 1.0.0
Provides:       bundled(golang(github.com/jbenet/go-context)) = d14ea06
Provides:       bundled(golang(github.com/jmespath/go-jmespath)) = 0.4.0
Provides:       bundled(golang(github.com/joelanford/ignore)) = 63d4919
Provides:       bundled(golang(github.com/jonboulle/clockwork)) = 0.2.2
Provides:       bundled(golang(github.com/josharian/intern)) = 1.0.0
Provides:       bundled(golang(github.com/json-iterator/go)) = 1.1.12
Provides:       bundled(golang(github.com/liggitt/tabwriter)) = 89fcab3
Provides:       bundled(golang(github.com/lithammer/dedent)) = 1.1.0
Provides:       bundled(golang(github.com/mailru/easyjson)) = 0.7.6
Provides:       bundled(golang(github.com/matttproud/golang_protobuf_extensions)) = c182aff
Provides:       bundled(golang(github.com/mitchellh/go-wordwrap)) = 1.0.0
Provides:       bundled(golang(github.com/moby/buildkit)) = c3a857e
Provides:       bundled(golang(github.com/moby/spdystream)) = 0.2.0
Provides:       bundled(golang(github.com/moby/sys/mount)) = 0.2.0
Provides:       bundled(golang(github.com/moby/sys/mountinfo)) = 0.4.1
Provides:       bundled(golang(github.com/moby/term)) = 9d4ed18
Provides:       bundled(golang(github.com/modern-go/concurrent)) = bacd9c7
Provides:       bundled(golang(github.com/modern-go/reflect2)) = 1.0.2
Provides:       bundled(golang(github.com/monochromegane/go-gitignore)) = 205db1a
Provides:       bundled(golang(github.com/morikuni/aec)) = 1.0.0
Provides:       bundled(golang(github.com/mtrmac/gpgme)) = 0.1.2
Provides:       bundled(golang(github.com/mxk/go-flowrate)) = cca7078
Provides:       bundled(golang(github.com/opencontainers/go-digest)) = 1.0.0
Provides:       bundled(golang(github.com/opencontainers/image-spec)) = 775207b
Provides:       bundled(golang(github.com/opencontainers/runc)) = 1.0.1
Provides:       bundled(golang(github.com/opencontainers/runtime-spec)) = 1c3f411
Provides:       bundled(golang(github.com/openshift/api)) = d747270
Provides:       bundled(golang(github.com/openshift/build-machinery-go)) = f94edc2
Provides:       bundled(golang(github.com/openshift/client-go)) = 7385dd6
Provides:       bundled(golang(github.com/openshift/library-go)) = 9f57c59
Provides:       bundled(golang(github.com/peterbourgon/diskv)) = 2.0.1+incompatible
Provides:       bundled(golang(github.com/pkg/errors)) = 0.9.1
Provides:       bundled(golang(github.com/pkg/profile)) = 1.3.0
Provides:       bundled(golang(github.com/pmezard/go-difflib)) = 1.0.0
Provides:       bundled(golang(github.com/prometheus/client_golang)) = 1.11.0
Provides:       bundled(golang(github.com/prometheus/client_model)) = 0.2.0
Provides:       bundled(golang(github.com/prometheus/common)) = 0.28.0
Provides:       bundled(golang(github.com/prometheus/procfs)) = 0.6.0
Provides:       bundled(golang(github.com/russross/blackfriday)) = 1.5.2
Provides:       bundled(golang(github.com/sirupsen/logrus)) = 1.8.1
Provides:       bundled(golang(github.com/spf13/cobra)) = 1.2.1
Provides:       bundled(golang(github.com/spf13/pflag)) = 1.0.5
Provides:       bundled(golang(github.com/stretchr/testify)) = 1.7.0
Provides:       bundled(golang(github.com/syndtr/gocapability)) = 42c35b4
Provides:       bundled(golang(github.com/xeipuuv/gojsonpointer)) = 02993c4
Provides:       bundled(golang(github.com/xlab/treeprint)) = a009c39
Provides:       bundled(golang(go.opencensus.io)) = 0.23.0
Provides:       bundled(golang(go.starlark.net)) = 8dd3e2e
Provides:       bundled(golang(golang.org/x/crypto)) = 32db794
Provides:       bundled(golang(golang.org/x/exp)) = 6cc2880
Provides:       bundled(golang(golang.org/x/net)) = 5cfca57
Provides:       bundled(golang(golang.org/x/oauth2)) = 2bc19b1
Provides:       bundled(golang(golang.org/x/sync)) = 036812b
Provides:       bundled(golang(golang.org/x/sys)) = f4d4317
Provides:       bundled(golang(golang.org/x/term)) = 6886f2d
Provides:       bundled(golang(golang.org/x/text)) = 0.3.7
Provides:       bundled(golang(golang.org/x/time)) = 1f47c86
Provides:       bundled(golang(golang.org/x/tools)) = d4cc65f
Provides:       bundled(golang(google.golang.org/appengine)) = 1.6.7
Provides:       bundled(golang(google.golang.org/genproto)) = fe13028
Provides:       bundled(golang(google.golang.org/grpc)) = 1.40.0
Provides:       bundled(golang(google.golang.org/protobuf)) = 1.27.1
Provides:       bundled(golang(gopkg.in/asn1-ber.v1)) = f715ec2
Provides:       bundled(golang(gopkg.in/inf.v0)) = 0.9.1
Provides:       bundled(golang(gopkg.in/ldap.v2)) = 2.5.1
Provides:       bundled(golang(gopkg.in/warnings.v0)) = 0.1.2
Provides:       bundled(golang(gopkg.in/yaml.v2)) = 2.4.0
Provides:       bundled(golang(gopkg.in/yaml.v3)) = 496545a
Provides:       bundled(golang(k8s.io/api)) = 0.23.2
Provides:       bundled(golang(k8s.io/apimachinery)) = 0.23.2
Provides:       bundled(golang(k8s.io/apiserver)) = 0.23.2
Provides:       bundled(golang(github.com/openshift/kubernetes-cli-runtime)) = 667bf63
Provides:       bundled(golang(k8s.io/client-go)) = 0.23.2
Provides:       bundled(golang(k8s.io/component-base)) = 0.23.2
Provides:       bundled(golang(k8s.io/component-helpers)) = 0.23.0
Provides:       bundled(golang(k8s.io/klog/v2)) = 2.40.1
Provides:       bundled(golang(k8s.io/kube-openapi)) = e816edb
Provides:       bundled(golang(github.com/openshift/kubernetes-kubectl)) = df787b5
Provides:       bundled(golang(k8s.io/metrics)) = 0.23.0
Provides:       bundled(golang(k8s.io/utils)) = 7d6a63d
Provides:       bundled(golang(sigs.k8s.io/json)) = 9f7c6b3
Provides:       bundled(golang(sigs.k8s.io/kustomize/api)) = 0.10.1
Provides:       bundled(golang(sigs.k8s.io/kustomize/kustomize/v4)) = 4.4.1
Provides:       bundled(golang(sigs.k8s.io/kustomize/kyaml)) = 0.13.0
Provides:       bundled(golang(sigs.k8s.io/structured-merge-diff/v4)) = 4.2.1
Provides:       bundled(golang(sigs.k8s.io/yaml)) = 1.2.0
Provides:       bundled(golang(github.com/openshift/gssapi)) = 5fb4217
Provides:       bundled(golang(github.com/openshift/kubernetes-cli-runtime)) = 667bf63
Provides:       bundled(golang(github.com/openshift/kubernetes-kubectl)) = df787b5

%description %{common_description}

%prep
%autosetup -n oc-%{commit} -a 1

%build
# Build the oc binary
%make_build build SOURCE_GIT_TAG='%{version}-%{release}' SOURCE_GIT_COMMIT='%{commit}' SOURCE_GIT_TREE_STATE='clean' GO_BUILD_BINDIR='./bin' GO_BUILD_PACKAGES='./cmd/oc'

# Build genman for oc
%make_build build GO_BUILD_PACKAGES='./tools/genman'

# Build genman for kubectl
pushd kubernetes-%{kubernetes_version}
    %make_build genman
popd

%install
install -m 0755 -vd                     %{buildroot}%{_bindir}

# Install for the local platform
install -m 0755 -vp ./bin/oc    %{buildroot}%{_bindir}/
ln -s ./oc %{buildroot}%{_bindir}/kubectl

# Install man1 man pages
install -d -m 0755 %{buildroot}%{_mandir}/man1
./genman %{buildroot}%{_mandir}/man1 oc
./kubernetes-%{kubernetes_version}/_output/bin/genman %{buildroot}%{_mandir}/man1 kubectl

# Install bash completions
install -d -m 0755 %{buildroot}%{_sysconfdir}/bash_completion.d/
for bin in oc kubectl
do
  echo "+++ INSTALLING BASH COMPLETIONS FOR ${bin} "
  %{buildroot}%{_bindir}/${bin} completion bash > %{buildroot}%{_sysconfdir}/bash_completion.d/${bin}
  chmod 644 %{buildroot}%{_sysconfdir}/bash_completion.d/${bin}
done

%if %{with check}
%check
%gocheck
%endif

%files
%license LICENSE
%doc README.md
%{_bindir}/oc
%{_bindir}/kubectl
%{_sysconfdir}/bash_completion.d/oc
%{_sysconfdir}/bash_completion.d/kubectl
%dir %{_mandir}/man1/
%{_mandir}/man1/oc*
%{_mandir}/man1/kubectl*

%changelog
* Wed Oct 05 2022 Luca Magrone <luca@magrone.cc> - 4.10.0-3.20221003git442535c
- Generate man pages for kubectl

* Tue Oct 04 2022 Luca Magrone <luca@magrone.cc> - 4.10.0-2.20221003git442535c
- Add vendor2provides.py to the source package

* Tue Oct 04 2022 Luca Magrone <luca@magrone.cc> - 4.10.0-1.20221003git442535c
- Initial package