File grpcurl.spec of Package grpcurl

#
# spec file for package grpcurl
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

%define _config_dir %{_sysconfdir}/%{name}
Name:           grpcurl
Version:        1.9.1
Release:        0
Summary:	Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
# FIXME: Select a correct license from https://github.com/openSUSE/spec-cleaner#spdx-licenses
License:        MIT
URL:            https://github.com/fullstorydev/grpcurl
Source:         %{name}-%{version}.tar.xz
Source1:	vendor.tar.gz
BuildRequires:  golang-packaging
BuildRequires:  golang(API) >= 1.21


%description
grpcurl is a command-line tool that lets you interact with gRPC servers. It's
basically curl for gRPC servers.

The main purpose for this tool is to invoke RPC methods on a gRPC server from
the command-line. gRPC servers use a binary encoding on the wire (protocol
buffers, or "protobufs" for short). So they are basically impossible to
interact with using regular curl (and older versions of curl that do not
support HTTP/2 are of course non-starters). This program accepts messages using
JSON encoding, which is much more friendly for both humans and scripts.

With this tool you can also browse the schema for gRPC services, either by
querying a server that supports server reflection, by reading proto source
files, or by loading in compiled "protoset" files (files that contain encoded
file descriptor protos). In fact, the way the tool transforms JSON request data
into a binary encoded protobuf is using that very same schema. So, if the
server you interact with does not support reflection, you will either need the
proto source files that define the service or need protoset files that grpcurl
can use.

%prep
%autosetup -a 1

%build
# Build the binary.
go build -mod=vendor -buildmode=pie \
	-ldflags '-X "main.version=dev build %{version}"' -o bin/ ./...

%install
# Install the binary.
install -D -m 0755 bin/%{name} "%{buildroot}/%{_bindir}/%{name}"

%post
%postun

%files
%license LICENSE
%doc README.md
%{_bindir}/%{name}

%changelog

openSUSE Build Service is sponsored by