Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation to proto files #243

Merged
merged 4 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions protos/hardware/hardware.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions protos/hardware/hardware.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,58 @@ package github.com.tinkerbell.tink.protos.hardware;

import "google/api/annotations.proto";

// The HardwareService provides access to data describing the compute
// and networking profiles of the hardware available to accept workflows.
//
// The API supports adding new entries. While the hardware data is essential,
// not all of the properties are required for every workflow. The choice of
// workflow predicates the level of hardware detail necessary.
//
// Read access to individual hardware profiles is provided through the unique
// ID, MAC, and IP hardware properties.
service HardwareService {
// Push adds a new Hardware profile to the data store.
rpc Push (PushRequest) returns (Empty) {
option (google.api.http) = {
post: "/v1/hardware"
body: "*"
};
};

// ByMac returns the Hardware with the given hardware MAC Address.
rpc ByMAC(GetRequest) returns (Hardware) {
option (google.api.http) = {
post: "/v1/hardware/mac"
body: "*"
};
};

// ByIP returns the Hardware with the given IP Address.
rpc ByIP(GetRequest) returns (Hardware) {
option (google.api.http) = {
post: "/v1/hardware/ip"
body: "*"
};
};

// ByID returns the Hardware with the given ID.
rpc ByID(GetRequest) returns (Hardware) {
option (google.api.http) = {
get: "/v1/hardware/{id}"
};
};

// All returns all of the Hardware profiles.
rpc All(Empty) returns (stream Hardware) {
option (google.api.http) = {
get: "/v1/hardware"
};
};

// Watch watches for events on the given hardware and streams the matching Hardware.
rpc Watch(GetRequest) returns (stream Hardware);

// Delete deletes the given hardware from the data store.
rpc Delete(DeleteRequest) returns (Empty) {
option (google.api.http) = {
delete: "/v1/hardware/{id}"
Expand Down
4 changes: 1 addition & 3 deletions protos/packet/packet.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions protos/protoc.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
#!/usr/bin/env bash

#
# protoc.sh uses the local protoc if installed, otherwise
# docker will be used with a complete environment provided
# by https://github.com/jaegertracing/docker-protobuf.
# Alternative images like grpc/go are very dated and do not
# include the needed plugins and includes.
#
set -e

GOPATH=${GOPATH:-$(go env GOPATH)}

if command -v protoc >/dev/null; then
GW_PATH="$GOPATH"/src/github.com/grpc-ecosystem/grpc-gateway
GO111MODULES=on go get github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
mmlb marked this conversation as resolved.
Show resolved Hide resolved

PROTOC="protoc -I/usr/local/include -I$GW_PATH/third_party/googleapis --plugin=protoc-gen-grpc-gateway=$GOPATH/bin/protoc-gen-grpc-gateway"
else
IMAGE=jaegertracing/protobuf:0.2.0
mmlb marked this conversation as resolved.
Show resolved Hide resolved
BASE=/protos
PROTOC="docker run -v $(pwd):$BASE -w $BASE --rm $IMAGE "
fi

for proto in hardware packet template workflow; do
echo "Generating ${proto}.pb.go..."
protoc -I ./ -I ./common/ -I "$GOPATH"/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis "${proto}/${proto}.proto" --go_out=plugins=grpc:./ --grpc-gateway_out=logtostderr=true:.
$PROTOC -I./ \
-I./common \
--go_opt=paths=source_relative \
--go_out=plugins=grpc:./ \
--grpc-gateway_out=logtostderr=true:. \
"${proto}/${proto}.proto"
done
goimports -w .
12 changes: 5 additions & 7 deletions protos/template/template.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading