Skip to content

Commit

Permalink
Add go generation rules (envoyproxy#204)
Browse files Browse the repository at this point in the history
Signed-off-by: Kuat Yessenov <[email protected]>
  • Loading branch information
kyessenov authored and htuch committed Oct 25, 2017
1 parent f2c1dc9 commit a039871
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 5 deletions.
3 changes: 3 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
load("@io_bazel_rules_go//go:def.bzl", "go_prefix")

go_prefix("github.com/envoyproxy/data-plane-api")
10 changes: 10 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ new_http_archive(
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
)

git_repository(
name = "io_bazel_rules_go",
remote = "https://github.com/bazelbuild/rules_go.git",
commit = "4374be38e9a75ff5957c3922adb155d32086fe14",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
load("@io_bazel_rules_go//proto:def.bzl", "proto_register_toolchains")
proto_register_toolchains()
49 changes: 48 additions & 1 deletion api/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
load("//bazel:api_build_system.bzl", "api_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_grpc_library")

licenses(["notice"]) # Apache 2

# Go proto library dislikes proto libraries with no sources and only deps
proto_library(
name = "go_protos",
srcs = [
"accesslog.proto",
"address.proto",
"base.proto",
"bootstrap.proto",
"cds.proto",
"discovery.proto",
"eds.proto",
"hds.proto",
"health_check.proto",
"lds.proto",
"protocol.proto",
"rds.proto",
"rls.proto",
"sds.proto",
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@googleapis//:http_api_protos_lib",
],
)

go_grpc_library(
name = "go_default_library",
importpath = "api",
proto = ":go_protos",
visibility = ["//visibility:public"],
deps = [
"@com_github_golang_protobuf//ptypes/any:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
"@com_github_golang_protobuf//ptypes/struct:go_default_library",
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
"@org_golang_google_genproto//googleapis/api/annotations:go_default_library",
],
)

api_proto_library(
name = "address",
srcs = ["address.proto"],
Expand Down Expand Up @@ -124,7 +171,7 @@ proto_library(
deps = [
":cds",
":eds",
":rds",
":lds",
":rds",
],
)
1 change: 1 addition & 0 deletions api/base.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package envoy.api.v2;
option go_package = "api";

import "api/address.proto";

Expand Down
23 changes: 23 additions & 0 deletions api/filter/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
load("//bazel:api_build_system.bzl", "api_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

licenses(["notice"]) # Apache 2

# Go proto library dislikes proto libraries with no sources and only deps
proto_library(
name = "go_protos",
srcs = [
"fault.proto",
],
visibility = ["//visibility:public"],
deps = [
"@com_google_protobuf//:duration_proto",
],
)

go_proto_library(
name = "go_default_library",
importpath = "api/filter",
proto = ":go_protos",
visibility = ["//visibility:public"],
deps = [
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
],
)

api_proto_library(
name = "fault",
srcs = ["fault.proto"],
Expand Down
1 change: 1 addition & 0 deletions api/filter/fault.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package envoy.api.v2.filter;
option go_package = "filter";

import "google/protobuf/duration.proto";

Expand Down
45 changes: 45 additions & 0 deletions api/filter/http/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
load("//bazel:api_build_system.bzl", "api_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

licenses(["notice"]) # Apache 2

# Go proto library dislikes proto libraries with no sources and only deps
proto_library(
name = "go_protos",
srcs = [
"buffer.proto",
"fault.proto",
"health_check.proto",
"http_connection_manager.proto",
"ip_tagging.proto",
"rate_limit.proto",
"router.proto",
"transcoder.proto",
],
visibility = ["//visibility:public"],
deps = [
"//api:go_protos",
"//api/filter:go_protos",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@googleapis//:http_api_protos_lib",
],
)

go_proto_library(
name = "go_default_library",
importpath = "api/filter/http",
proto = ":go_protos",
visibility = ["//visibility:public"],
deps = [
"//api:go_default_library",
"//api/filter:go_default_library",
"@com_github_golang_protobuf//ptypes/any:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
"@com_github_golang_protobuf//ptypes/struct:go_default_library",
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
"@org_golang_google_genproto//googleapis/api/annotations:go_default_library",
],
)

api_proto_library(
name = "http_connection_manager",
srcs = ["http_connection_manager.proto"],
Expand Down
1 change: 1 addition & 0 deletions api/filter/http/http_connection_manager.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package envoy.api.v2.filter.http;
option go_package = "http";

import "api/base.proto";
import "api/protocol.proto";
Expand Down
42 changes: 42 additions & 0 deletions api/filter/network/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,49 @@
load("//bazel:api_build_system.bzl", "api_proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

licenses(["notice"]) # Apache 2

# Go proto library dislikes proto libraries with no sources and only deps
proto_library(
name = "go_protos",
srcs = [
"client_ssl_auth.proto",
"mongo_proxy.proto",
"rate_limit.proto",
"redis_proxy.proto",
"tcp_proxy.proto",
],
visibility = ["//visibility:public"],
deps = [
"//api:go_protos",
"//api/filter:go_protos",
"@com_google_protobuf//:any_proto",
"@com_google_protobuf//:descriptor_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:struct_proto",
"@com_google_protobuf//:timestamp_proto",
"@com_google_protobuf//:wrappers_proto",
"@googleapis//:http_api_protos_lib",
],
)

go_proto_library(
name = "go_default_library",
importpath = "api/filter/network",
proto = ":go_protos",
visibility = ["//visibility:public"],
deps = [
"//api:go_default_library",
"//api/filter:go_default_library",
"@com_github_golang_protobuf//ptypes/any:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
"@com_github_golang_protobuf//ptypes/struct:go_default_library",
"@com_github_golang_protobuf//ptypes/timestamp:go_default_library",
"@com_github_golang_protobuf//ptypes/wrappers:go_default_library",
"@org_golang_google_genproto//googleapis/api/annotations:go_default_library",
],
)

api_proto_library(
name = "mongo_proxy",
srcs = ["mongo_proxy.proto"],
Expand Down
1 change: 1 addition & 0 deletions api/filter/network/tcp_proxy.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package envoy.api.v2.filter.network;
option go_package = "network";

import "google/protobuf/duration.proto";

Expand Down
9 changes: 5 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
GOOGLEAPIS_SHA = "5c6df0cd18c6a429eab739fb711c27f6e1393366" # May 14, 2017

def api_dependencies():
native.new_git_repository(
native.new_http_archive(
name = "googleapis",
# Head of master at 5/14.
commit = "5c6df0cd18c6a429eab739fb711c27f6e1393366",
remote = "https://github.com/googleapis/googleapis.git",
strip_prefix = "googleapis-" + GOOGLEAPIS_SHA,
url = "https://github.com/googleapis/googleapis/archive/" + GOOGLEAPIS_SHA + ".tar.gz",
build_file_content = """
load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")
Expand Down

0 comments on commit a039871

Please sign in to comment.