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

refactor(cloud): update to support buf lint and generation automation #413

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions buf.work.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ directories:
- inventory
- security
# - storage
- network/opinetcommon
# - network/cloud
- network/opinetcommon
- network/cloud
- network/evpn-gw
# - network/k8s
# - network/telco
25 changes: 13 additions & 12 deletions network/cloud/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@
# Copyright (C) 2022 Intel Corporation
# Copyright (c) 2022 Dell Inc, or its subsidiaries.

all:
all: buflint doc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments to
#411


doc:
rm -rf ./google
rm -rf ./v1alpha1/{autogen.md,gen,google}
mkdir -p ./v1alpha1/gen/{go,cpp,python,java}
rm -rf ./v1alpha1/{autogen.md}
mkdir -p ./v1alpha1

# protoc doesn't include annotation and http googleapis, so we have to get them here
curl -kL https://github.com/googleapis/googleapis/archive/master.tar.gz | tar --strip=1 -zxvf - googleapis-master/google/api

docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common -i /opinetcommon --lint -d v1alpha1 -l go -o ./v1alpha1/gen/go/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common -i /opinetcommon --lint -d v1alpha1 -l cpp -o ./v1alpha1/gen/cpp/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common -i /opinetcommon --lint -d v1alpha1 -l python -o ./v1alpha1/gen/python/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v ${PWD}/google/api:/opt/include/google/api namely/protoc-all:1.51_2 -i /common -i /opinetcommon --lint -d v1alpha1 -l java -o ./v1alpha1/gen/java/ --go-source-relative
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v "${PWD}"/v1alpha1/:/out -w /out -v "${PWD}":/protos pseudomuto/protoc-gen-doc:1.5.1 -c "protoc -I /common -I /opinetcommon -I /protos --doc_out=/out --doc_opt=markdown,autogen.md /protos/*.proto /common/*.proto"

rm -rf "${PWD}"/google


mv google "${PWD}"/v1alpha1/
buflint:
docker run --rm -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinnetcommon -v "${PWD}":/out -w /out bufbuild/buf lint

docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v "${PWD}"/v1alpha1/:/out -w /out -v "${PWD}"/v1alpha1:/protos pseudomuto/protoc-gen-doc:1.5.1 -c "protoc -I /common -I /opinetcommon -I /protos --doc_out=/out --doc_opt=markdown,autogen.md /protos/*.proto /common/*.proto"
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v "${PWD}"/v1alpha1/:/out -w /out ghcr.io/docker-multiarch/google-api-linter:1.59.2 -c "api-linter -I /common -I /opinetcommon /out/*.proto --output-format summary"
docker run --user=$$(id -u):$$(id -g) --rm --entrypoint=sh -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinetcommon -v "${PWD}"/v1alpha1/:/out -w /out ghcr.io/docker-multiarch/google-api-linter:1.59.2 -c "api-linter -I /common -I /opinetcommon /out/[!oc]*.proto --output-format github --disable-rule=core::0123 --disable-rule=core::0203 --disable-rule=core::0216 --set-exit-status"
rm -rf "${PWD}"/v1alpha1/google
bufgen:
docker run --rm -v "${PWD}/../../common/v1":/common -v "${PWD}/../opinetcommon":/opinnetcommon -v "${PWD}/../..":/base -v "${PWD}":/out -w /out msandersdell/bufbuild-go-gen:1.1.0 generate --template /base/buf.gen.yaml -o v1alpha1
72 changes: 36 additions & 36 deletions network/cloud/v1alpha1/bgp.proto → network/cloud/bgp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ message BGPPeerSpec {
// send extended community attributes to neighbor
bool send_ext_comm = 6;
// peer is a route reflector client
BGPPeerRRClient rr_client = 7;
BGPPeerRR rr_client = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usualally RR Client is different than RR; not sure about the reason behind this name change, and if this was linting related or something done for improving brevity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add the Client back to the enum and the parameter. It was the linting checking on the enum definitions that resulted in the change.

// BGP session connect-retry timer in seconds
int32 connect_retry = 8;
// BGP session configured holdtime timer in seconds
Expand Down Expand Up @@ -279,10 +279,10 @@ message BGPPeerAfStatus {
// send a Route Refresh request to the peer for this AFI/SAFI.
bool route_refresh = 3;
//The BGP additional path capability negotiated with this peer for this AFI/SAFI.
BgpAddPathCapNegCap add_path_cap_neg = 4;
BgpAddPathCapNeg add_path_cap_neg = 4;
// This value indicates whether the given peer is a reflector client of this
// router for this AFI/SAFI, or not
BGPPeerRRClient reflector_client = 5;
BGPPeerRR reflector_client = 5;
}

// BGP NLRI prefix object, this object is not conifgured by the user
Expand Down Expand Up @@ -354,7 +354,7 @@ message BGPNLRIPrefixStatus {
int32 flap_starttime = 19;
// If bgpNlriPrefixBest is 'true', then this field is set to 'routeIsBest'.
// Otherwise, it reports the stage in the decision process when the route was determined to be non-best.
BGPRsnNotBest reason_not_best = 20;
BGPRouteReason reason_not_best = 20;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could consider renaming the member as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could consider renaming the member as well

We could change it to route_reason = 20; as an option. The intent is to report the reason for not having the best route which really is the reason for the particular route selection where one of the reason's is "Route is best". I will let @jainvipin respond on the changing since the elements are from his contribution and his input on the enum and parameter should be considered on this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @artek-koltun - we should change the field/member name as well to reflect its intent; thanks for fixing this.

// The extended community membership associated with the route after import policy has been applied.
repeated bytes ext_comm = 21;
// The community list associated with the route after import policy has been applied.
Expand Down Expand Up @@ -455,14 +455,14 @@ enum BGPSafi {
BGP_SAFI_EVPN = 70;
}

// BGP peer RR client
enum BGPPeerRRClient {
// BGP peer Route Reflector client
enum BGPPeerRR {
// RR_UNSPECIFIED
BGP_PEER_RR_CLIENT_UNSPECIFIED = 0;
BGP_PEER_RR_UNSPECIFIED = 0;
// RR_CLIENT
BGP_PEER_RR_CLIENT = 1;
BGP_PEER_RR_CLIENT = 1;
// RR_MESHED_CLIENT
BGP_PEER_RR_MESHED_CLIENT = 2;
BGP_PEER_RR_MESHED_CLIENT = 2;
}

// BGP peer session's last_state
Expand Down Expand Up @@ -558,21 +558,21 @@ enum BGPOperState {
}

// bgp add path capability negotiation
enum BgpAddPathCapNegCap {
enum BgpAddPathCapNeg {
// disabled
// (-- api-linter: core::0126::unspecified=disabled
// aip.dev/not-precedent: zero is disabled, not unspecified. --)
BGP_ADD_PATH_SR_DISABLE = 0;
BGP_ADD_PATH_CAP_NEG_SR_DISABLE = 0;
// receive
BGP_ADD_PATH_SR_RECEIVE = 1;
BGP_ADD_PATH_CAP_NEG_SR_RECEIVE = 1;
// send
BGP_ADD_PATH_SR_SEND = 2;
BGP_ADD_PATH_CAP_NEG_SR_SEND = 2;
// both
BGP_ADD_PATH_SR_BOTH = 3;
BGP_ADD_PATH_CAP_NEG_SR_BOTH = 3;
// inherit
BGP_ADD_PATH_SR_INHERIT = 4;
BGP_ADD_PATH_CAP_NEG_SR_INHERIT = 4;
// uknown
BGP_ADD_PATH_SR_UNKNOWN = 5;
BGP_ADD_PATH_CAP_NEG_SR_UNKNOWN = 5;
}

// clear route request's options
Expand Down Expand Up @@ -614,49 +614,49 @@ enum BgpNlriIsActive {
}

// BGP Reason for not best route
enum BGPRsnNotBest {
enum BGPRouteReason {
// not considered
// (-- api-linter: core::0126::unspecified=disabled
// aip.dev/not-precedent: zero is not-considered, not unspecified. --)
BGP_REASON_NOT_CONSIDERED = 0;
BGP_ROUTE_REASON_NOT_CONSIDERED = 0;
// route is best
BGP_REASON_ROUTE_IS_BEST = 1;
BGP_ROUTE_REASON_ROUTE_IS_BEST = 1;
// weight based
BGP_REASON_WEIGHT = 2;
BGP_ROUTE_REASON_WEIGHT = 2;
// local preference
BGP_REASON_LOCAL_PREF = 3;
BGP_ROUTE_REASON_LOCAL_PREF = 3;
// local origin preferred
BGP_REASON_LCL_ORIG_PRFRRED = 4;
BGP_ROUTE_REASON_LCL_ORIG_PRFRRED = 4;
// as path lengt
BGP_REASON_AS_PATH_LEN = 5;
BGP_ROUTE_REASON_AS_PATH_LEN = 5;
// origin based
BGP_REASON_ORIGIN = 6;
BGP_ROUTE_REASON_ORIGIN = 6;
// med
BGP_REASON_MED = 7;
BGP_ROUTE_REASON_MED = 7;
// origin tie
BGP_REASON_LOCAL_ORIG_TIE = 8;
BGP_ROUTE_REASON_LOCAL_ORIG_TIE = 8;
// ebpg vs. ibgp peer
BGP_REASON_EBGP_V_IBGP_PEER = 9;
BGP_ROUTE_REASON_EBGP_V_IBGP_PEER = 9;
// admin distance
BGP_REASON_ADMIN_DISTANCE = 10;
BGP_ROUTE_REASON_ADMIN_DISTANCE = 10;
// path next to cst
BGP_REASON_PATH_TO_NEXT_CST = 11;
BGP_ROUTE_REASON_PATH_TO_NEXT_CST = 11;
// preferenc existing
BGP_REASON_PREF_EXISTING = 12;
BGP_ROUTE_REASON_PREF_EXISTING = 12;
// reason identifier
// (-- api-linter: core::0140::abbreviations=disabled
// aip.dev/not-precedent: --)
BGP_REASON_IDENTIFIER = 13;
BGP_ROUTE_REASON_IDENTIFIER = 13;
// cluster length
BGP_REASON_CLUSTER_LEN = 14;
BGP_ROUTE_REASON_CLUSTER_LEN = 14;
// peer address type
BGP_REASON_PEER_ADDR_TYPE = 15;
BGP_ROUTE_REASON_PEER_ADDR_TYPE = 15;
// peer address
BGP_REASON_PEER_ADDR = 16;
BGP_ROUTE_REASON_PEER_ADDR = 16;
// peer port
BGP_REASON_PEER_PORT = 17;
BGP_ROUTE_REASON_PEER_PORT = 17;
// path id
BGP_REASON_PATH_ID = 18;
BGP_ROUTE_REASON_PATH_ID = 18;
}

// bgp origin attribute
Expand Down
13 changes: 9 additions & 4 deletions network/cloud/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
commit: b30c5775bfb3485d9da2e87b26590ac9
digest: shake256:9d0caaf056949a0e1c883b9849d8a2fa66e22f18a2a48f867d1a8c700aa22abee50ad3ef0d8171637457cadc43c584998bdf3adac55da0f9e4614c72686b057d
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: f460f71081c14a80b66cc72526e0b322
digest: shake256:122def85e91fc3ef4ab351680060b8f70e9d09a7ae6d1412aeb2bddfeee5c4d3fc8819da33fef56192cec0a817ac0c3e6d49bb2acf02eb5c9e9131739a60ddfc
commit: 3f42134f4c564983838425bc43c7a65f
digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92
- remote: buf.build
owner: opiproject
repository: opinetcommon
commit: 9779e55c83de44b3a14925b8195cf7e7
digest: shake256:20d43132a22c5d3341919f5167669f137b79b23e807a5c34a3168216a28e07a114f3f7a94b73925f824befd5862ac354d5ad45a3136761ca429f041286657524
13 changes: 11 additions & 2 deletions network/cloud/buf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
version: v1beta1
version: v1
name: buf.build/opiproject/cloud
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway

- buf.build/opiproject/opinetcommon
lint:
except:
- PACKAGE_DIRECTORY_MATCH
# Don't check standard name as that causes google aip issues
- RPC_RESPONSE_STANDARD_NAME
# Allow same name used in request/response type for multiple RPCs
- RPC_REQUEST_RESPONSE_UNIQUE
- ENUM_ZERO_VALUE_SUFFIX

Loading
Loading