forked from istio/old_mixer_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
istio_api.bzl
161 lines (148 loc) · 5.78 KB
/
istio_api.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Copyright 2017 Istio Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
#
ISTIO_API_SHA = "0ab63a64b7ce7900de2a95160c13dcf781d04d07"
def go_istio_api_repositories(use_local=False):
ISTIO_API_BUILD_FILE = """
# build protos from istio.io/api repo
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_library")
go_prefix("istio.io/api")
load("@org_pubref_rules_protobuf//gogo:rules.bzl", "gogoslick_proto_library", "gogo_proto_compile")
gogoslick_proto_library(
name = "mixer/v1",
importmap = {
"gogoproto/gogo.proto": "github.com/gogo/protobuf/gogoproto",
"google/rpc/status.proto": "github.com/googleapis/googleapis/google/rpc",
"google/protobuf/timestamp.proto": "github.com/gogo/protobuf/types",
"google/protobuf/duration.proto": "github.com/gogo/protobuf/types",
},
imports = [
"../../external/com_github_gogo_protobuf",
"../../external/com_github_google_protobuf/src",
"../../external/com_github_googleapis_googleapis",
],
inputs = [
"@com_github_google_protobuf//:well_known_protos",
"@com_github_googleapis_googleapis//:status_proto",
"@com_github_gogo_protobuf//gogoproto:go_default_library_protos",
],
protos = [
"mixer/v1/attributes.proto",
"mixer/v1/check.proto",
"mixer/v1/report.proto",
"mixer/v1/service.proto",
],
verbose = 0,
visibility = ["//visibility:public"],
with_grpc = True,
deps = [
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//sortkeys:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
"@com_github_googleapis_googleapis//:google/rpc",
],
)
DESCRIPTOR_FILE_GROUP = [
"mixer/v1/config/descriptor/log_entry_descriptor.proto",
"mixer/v1/config/descriptor/metric_descriptor.proto",
"mixer/v1/config/descriptor/monitored_resource_descriptor.proto",
"mixer/v1/config/descriptor/principal_descriptor.proto",
"mixer/v1/config/descriptor/quota_descriptor.proto",
"mixer/v1/config/descriptor/value_type.proto",
]
# gogoslick_proto_compile cannot be used here. it generates Equal, Size, and
# MarshalTo methods for google.protobuf.Struct, which we then later replace
# with interface{}. This causes compilation issues.
gogo_proto_compile(
name = "mixer/v1/config_gen",
importmap = {
"google/protobuf/struct.proto": "github.com/gogo/protobuf/types",
"mixer/v1/config/descriptor/log_entry_descriptor.proto": "istio.io/api/mixer/v1/config/descriptor",
"mixer/v1/config/descriptor/metric_descriptor.proto": "istio.io/api/mixer/v1/config/descriptor",
"mixer/v1/config/descriptor/monitored_resource_descriptor.proto": "istio.io/api/mixer/v1/config/descriptor",
"mixer/v1/config/descriptor/principal_descriptor.proto": "istio.io/api/mixer/v1/config/descriptor",
"mixer/v1/config/descriptor/quota_descriptor.proto": "istio.io/api/mixer/v1/config/descriptor",
"mixer/v1/config/descriptor/value_type.proto": "istio.io/api/mixer/v1/config/descriptor",
},
imports = [
"../../external/com_github_google_protobuf/src",
],
inputs = DESCRIPTOR_FILE_GROUP + [
"@com_github_google_protobuf//:well_known_protos",
],
protos = [
"mixer/v1/config/cfg.proto",
],
verbose = 0,
visibility = ["//visibility:public"],
with_grpc = False,
)
gogoslick_proto_library(
name = "mixer/v1/config/descriptor",
importmap = {
"google/protobuf/duration.proto": "github.com/gogo/protobuf/types",
},
imports = [
"../../external/com_github_google_protobuf/src",
],
inputs = [
"@com_github_google_protobuf//:well_known_protos",
],
protos = DESCRIPTOR_FILE_GROUP,
verbose = 0,
visibility = ["//visibility:public"],
with_grpc = False,
deps = [
"@com_github_gogo_protobuf//sortkeys:go_default_library",
"@com_github_gogo_protobuf//types:go_default_library",
],
)
filegroup(
name = "mixer/v1/config/descriptor_protos",
srcs = DESCRIPTOR_FILE_GROUP,
visibility = ["//visibility:public"],
)
genrule(
name = "mixer/v1/config_fixed",
srcs = [":mixer/v1/config_gen"],
outs = ["fixed_cfg.pb.go"],
cmd = "sed " +
"-e 's/*google_protobuf.Struct/interface{}/g' " +
"-e 's/ValueType_VALUE_TYPE_UNSPECIFIED/VALUE_TYPE_UNSPECIFIED/g' " +
"$(location :mixer/v1/config_gen) | $(location @org_golang_x_tools_imports//:goimports) > $@",
message = "Applying overrides to cfg proto",
tools = ["@org_golang_x_tools_imports//:goimports"],
)
filegroup(
name = "mixer/v1/attributes_file",
srcs = ["mixer/v1/global_dictionary.yaml"],
visibility = ["//visibility:public"],
)
"""
if use_local:
native.new_local_repository(
name = "com_github_istio_api",
build_file_content = ISTIO_API_BUILD_FILE,
path = "../api",
)
else:
native.new_git_repository(
name = "com_github_istio_api",
build_file_content = ISTIO_API_BUILD_FILE,
commit = ISTIO_API_SHA,
remote = "https://github.com/istio/api.git",
)