From 8d0a8b0ffa696a3838740fec7accc54ccfb452ab Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 23 Dec 2018 23:12:49 +0900 Subject: make the usage of type name in protobuf consistent Signed-off-by: FUJITA Tomonori --- cmd/gobgp/bmp.go | 2 +- cmd/gobgp/global.go | 20 ++++----- cmd/gobgp/monitor.go | 14 +++---- cmd/gobgp/mrt.go | 4 +- cmd/gobgp/neighbor.go | 38 ++++++++--------- cmd/gobgp/policy.go | 110 +++++++++++++++++++++++++------------------------- cmd/gobgpd/main.go | 2 +- 7 files changed, 95 insertions(+), 95 deletions(-) (limited to 'cmd') diff --git a/cmd/gobgp/bmp.go b/cmd/gobgp/bmp.go index 831f6340..7e9754d9 100644 --- a/cmd/gobgp/bmp.go +++ b/cmd/gobgp/bmp.go @@ -74,7 +74,7 @@ func modBmpServer(cmdType string, args []string) error { _, err = client.AddBmp(ctx, &api.AddBmpRequest{ Address: address, Port: port, - Type: policyType, + Policy: policyType, StatisticsTimeout: int32(statisticsTimeout), }) case cmdDel: diff --git a/cmd/gobgp/global.go b/cmd/gobgp/global.go index 76a87e99..467824a0 100644 --- a/cmd/gobgp/global.go +++ b/cmd/gobgp/global.go @@ -1461,22 +1461,22 @@ usage: %s rib %s key [value ]`, return err } - r := api.Resource_GLOBAL + r := api.TableType_GLOBAL if resource == cmdVRF { - r = api.Resource_VRF + r = api.TableType_VRF } if modtype == cmdAdd { _, err = client.AddPath(ctx, &api.AddPathRequest{ - Resource: r, - VrfId: name, - Path: path, + TableType: r, + VrfId: name, + Path: path, }) } else { _, err = client.DeletePath(ctx, &api.DeletePathRequest{ - Resource: r, - VrfId: name, - Path: path, + TableType: r, + VrfId: name, + Path: path, }) } return err @@ -1595,8 +1595,8 @@ func newGlobalCmd() *cobra.Command { exitWithError(err) } if _, err = client.DeletePath(ctx, &api.DeletePathRequest{ - Resource: api.Resource_GLOBAL, - Family: family, + TableType: api.TableType_GLOBAL, + Family: family, }); err != nil { exitWithError(err) } diff --git a/cmd/gobgp/monitor.go b/cmd/gobgp/monitor.go index 10af9b22..bc31bde9 100644 --- a/cmd/gobgp/monitor.go +++ b/cmd/gobgp/monitor.go @@ -122,9 +122,9 @@ func newMonitorCmd() *cobra.Command { exitWithError(err) } recver, err := client.MonitorTable(ctx, &api.MonitorTableRequest{ - Type: api.Resource_GLOBAL, - Family: family, - Current: current, + TableType: api.TableType_GLOBAL, + Family: family, + Current: current, }) if err != nil { exitWithError(err) @@ -192,10 +192,10 @@ func newMonitorCmd() *cobra.Command { exitWithError(err) } recver, err := client.MonitorTable(ctx, &api.MonitorTableRequest{ - Type: api.Resource_ADJ_IN, - Name: name, - Family: family, - Current: current, + TableType: api.TableType_ADJ_IN, + Name: name, + Family: family, + Current: current, }) if err != nil { exitWithError(err) diff --git a/cmd/gobgp/mrt.go b/cmd/gobgp/mrt.go index ecae7bd0..f03dd41e 100644 --- a/cmd/gobgp/mrt.go +++ b/cmd/gobgp/mrt.go @@ -178,8 +178,8 @@ func injectMrt() error { for paths := range ch { err = stream.Send(&api.AddPathStreamRequest{ - Resource: api.Resource_GLOBAL, - Paths: paths, + TableType: api.TableType_GLOBAL, + Paths: paths, }) if err != nil { return fmt.Errorf("failed to send: %s", err) diff --git a/cmd/gobgp/neighbor.go b/cmd/gobgp/neighbor.go index 05ce21bf..0446b2a0 100644 --- a/cmd/gobgp/neighbor.go +++ b/cmd/gobgp/neighbor.go @@ -732,23 +732,23 @@ func showRibInfo(r, name string) error { return err } - var t api.Resource + var t api.TableType switch r { case cmdGlobal: - t = api.Resource_GLOBAL + t = api.TableType_GLOBAL case cmdLocal: - t = api.Resource_LOCAL + t = api.TableType_LOCAL case cmdAdjIn: - t = api.Resource_ADJ_IN + t = api.TableType_ADJ_IN case cmdAdjOut: - t = api.Resource_ADJ_OUT + t = api.TableType_ADJ_OUT default: return fmt.Errorf("invalid resource to show RIB info: %s", r) } rsp, err := client.GetTable(ctx, &api.GetTableRequest{ - Type: t, - Family: family, - Name: name, + TableType: t, + Family: family, + Name: name, }) if err != nil { @@ -842,28 +842,28 @@ func showNeighborRib(r string, name string, args []string) error { } } - var t api.Resource + var t api.TableType switch r { case cmdGlobal: - t = api.Resource_GLOBAL + t = api.TableType_GLOBAL case cmdLocal: - t = api.Resource_LOCAL + t = api.TableType_LOCAL case cmdAdjIn, cmdAccepted, cmdRejected: - t = api.Resource_ADJ_IN + t = api.TableType_ADJ_IN showIdentifier = bgp.BGP_ADD_PATH_RECEIVE case cmdAdjOut: - t = api.Resource_ADJ_OUT + t = api.TableType_ADJ_OUT showIdentifier = bgp.BGP_ADD_PATH_SEND case cmdVRF: - t = api.Resource_VRF + t = api.TableType_VRF } stream, err := client.ListPath(ctx, &api.ListPathRequest{ - Type: t, - Family: family, - Name: name, - Prefixes: filter, - SortType: api.ListPathRequest_PREFIX, + TableType: t, + Family: family, + Name: name, + Prefixes: filter, + SortType: api.ListPathRequest_PREFIX, }) if err != nil { return err diff --git a/cmd/gobgp/policy.go b/cmd/gobgp/policy.go index 03139c7b..d5fb80d3 100644 --- a/cmd/gobgp/policy.go +++ b/cmd/gobgp/policy.go @@ -106,7 +106,7 @@ func prettyString(v interface{}) string { switch a := v.(type) { case *api.MatchSet: var typ string - switch a.Type { + switch a.MatchType { case api.MatchType_ALL: typ = "all" case api.MatchType_ANY: @@ -117,7 +117,7 @@ func prettyString(v interface{}) string { return fmt.Sprintf("%s %s", typ, a.GetName()) case *api.AsPathLength: var typ string - switch a.Type { + switch a.LengthType { case api.AsPathLengthType_EQ: typ = "=" case api.AsPathLengthType_GE: @@ -129,7 +129,7 @@ func prettyString(v interface{}) string { case *api.CommunityAction: l := regexpCommunityString.ReplaceAllString(strings.Join(a.Communities, ", "), "") var typ string - switch a.Type { + switch a.ActionType { case api.CommunityActionType_COMMUNITY_ADD: typ = "add" case api.CommunityActionType_COMMUNITY_REMOVE: @@ -139,7 +139,7 @@ func prettyString(v interface{}) string { } return fmt.Sprintf("%s[%s]", typ, l) case *api.MedAction: - if a.Type == api.MedActionType_MED_MOD && a.Value > 0 { + if a.ActionType == api.MedActionType_MED_MOD && a.Value > 0 { return fmt.Sprintf("+%d", a.Value) } return fmt.Sprintf("%d", a.Value) @@ -221,8 +221,8 @@ func showDefinedSet(v string, args []string) error { name = args[0] } stream, err := client.ListDefinedSet(ctx, &api.ListDefinedSetRequest{ - Type: typ, - Name: name, + DefinedType: typ, + Name: name, }) if err != nil { return err @@ -295,9 +295,9 @@ func parsePrefixSet(args []string) (*api.DefinedSet, error) { list = []*api.Prefix{prefix} } return &api.DefinedSet{ - Type: api.DefinedType_PREFIX, - Name: name, - Prefixes: list, + DefinedType: api.DefinedType_PREFIX, + Name: name, + Prefixes: list, }, nil } @@ -322,9 +322,9 @@ func parseNeighborSet(args []string) (*api.DefinedSet, error) { } } return &api.DefinedSet{ - Type: api.DefinedType_NEIGHBOR, - Name: name, - List: list, + DefinedType: api.DefinedType_NEIGHBOR, + Name: name, + List: list, }, nil } @@ -341,9 +341,9 @@ func parseAsPathSet(args []string) (*api.DefinedSet, error) { } } return &api.DefinedSet{ - Type: api.DefinedType_AS_PATH, - Name: name, - List: args, + DefinedType: api.DefinedType_AS_PATH, + Name: name, + List: args, }, nil } @@ -359,9 +359,9 @@ func parseCommunitySet(args []string) (*api.DefinedSet, error) { } } return &api.DefinedSet{ - Type: api.DefinedType_COMMUNITY, - Name: name, - List: args, + DefinedType: api.DefinedType_COMMUNITY, + Name: name, + List: args, }, nil } @@ -377,9 +377,9 @@ func parseExtCommunitySet(args []string) (*api.DefinedSet, error) { } } return &api.DefinedSet{ - Type: api.DefinedType_EXT_COMMUNITY, - Name: name, - List: args, + DefinedType: api.DefinedType_EXT_COMMUNITY, + Name: name, + List: args, }, nil } @@ -395,9 +395,9 @@ func parseLargeCommunitySet(args []string) (*api.DefinedSet, error) { } } return &api.DefinedSet{ - Type: api.DefinedType_LARGE_COMMUNITY, - Name: name, - List: args, + DefinedType: api.DefinedType_LARGE_COMMUNITY, + Name: name, + List: args, }, nil } @@ -681,9 +681,9 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.PrefixSet.Type = api.MatchType_ANY + stmt.Conditions.PrefixSet.MatchType = api.MatchType_ANY case "invert": - stmt.Conditions.PrefixSet.Type = api.MatchType_INVERT + stmt.Conditions.PrefixSet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s prefix [{ any | invert }]", usage) } @@ -698,9 +698,9 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.NeighborSet.Type = api.MatchType_ANY + stmt.Conditions.NeighborSet.MatchType = api.MatchType_ANY case "invert": - stmt.Conditions.NeighborSet.Type = api.MatchType_INVERT + stmt.Conditions.NeighborSet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s neighbor [{ any | invert }]", usage) } @@ -715,11 +715,11 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.AsPathSet.Type = api.MatchType_ANY + stmt.Conditions.AsPathSet.MatchType = api.MatchType_ANY case "all": - stmt.Conditions.AsPathSet.Type = api.MatchType_ALL + stmt.Conditions.AsPathSet.MatchType = api.MatchType_ALL case "invert": - stmt.Conditions.AsPathSet.Type = api.MatchType_INVERT + stmt.Conditions.AsPathSet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s as-path [{ any | all | invert }]", usage) } @@ -734,11 +734,11 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.CommunitySet.Type = api.MatchType_ANY + stmt.Conditions.CommunitySet.MatchType = api.MatchType_ANY case "all": - stmt.Conditions.CommunitySet.Type = api.MatchType_ALL + stmt.Conditions.CommunitySet.MatchType = api.MatchType_ALL case "invert": - stmt.Conditions.CommunitySet.Type = api.MatchType_INVERT + stmt.Conditions.CommunitySet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s community [{ any | all | invert }]", usage) } @@ -753,11 +753,11 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.ExtCommunitySet.Type = api.MatchType_ANY + stmt.Conditions.ExtCommunitySet.MatchType = api.MatchType_ANY case "all": - stmt.Conditions.ExtCommunitySet.Type = api.MatchType_ALL + stmt.Conditions.ExtCommunitySet.MatchType = api.MatchType_ALL case "invert": - stmt.Conditions.ExtCommunitySet.Type = api.MatchType_INVERT + stmt.Conditions.ExtCommunitySet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s ext-community [{ any | all | invert }]", usage) } @@ -772,11 +772,11 @@ func modCondition(name, op string, args []string) error { } switch strings.ToLower(args[1]) { case "any": - stmt.Conditions.LargeCommunitySet.Type = api.MatchType_ANY + stmt.Conditions.LargeCommunitySet.MatchType = api.MatchType_ANY case "all": - stmt.Conditions.LargeCommunitySet.Type = api.MatchType_ALL + stmt.Conditions.LargeCommunitySet.MatchType = api.MatchType_ALL case "invert": - stmt.Conditions.LargeCommunitySet.Type = api.MatchType_INVERT + stmt.Conditions.LargeCommunitySet.MatchType = api.MatchType_INVERT default: return fmt.Errorf("%s large-community [{ any | all | invert }]", usage) } @@ -792,11 +792,11 @@ func modCondition(name, op string, args []string) error { stmt.Conditions.AsPathLength.Length = uint32(length) switch strings.ToLower(args[1]) { case "eq": - stmt.Conditions.AsPathLength.Type = api.AsPathLengthType_EQ + stmt.Conditions.AsPathLength.LengthType = api.AsPathLengthType_EQ case "ge": - stmt.Conditions.AsPathLength.Type = api.AsPathLengthType_GE + stmt.Conditions.AsPathLength.LengthType = api.AsPathLengthType_GE case "le": - stmt.Conditions.AsPathLength.Type = api.AsPathLengthType_LE + stmt.Conditions.AsPathLength.LengthType = api.AsPathLengthType_LE default: return fmt.Errorf("%s as-path-length { eq | ge | le }", usage) } @@ -882,11 +882,11 @@ func modAction(name, op string, args []string) error { stmt.Actions.Community.Communities = args[1:] switch strings.ToLower(args[0]) { case "add": - stmt.Actions.Community.Type = api.CommunityActionType_COMMUNITY_ADD + stmt.Actions.Community.ActionType = api.CommunityActionType_COMMUNITY_ADD case "remove": - stmt.Actions.Community.Type = api.CommunityActionType_COMMUNITY_REMOVE + stmt.Actions.Community.ActionType = api.CommunityActionType_COMMUNITY_REMOVE case "replace": - stmt.Actions.Community.Type = api.CommunityActionType_COMMUNITY_REPLACE + stmt.Actions.Community.ActionType = api.CommunityActionType_COMMUNITY_REPLACE default: return fmt.Errorf("%s community { add | remove | replace } ...", usage) } @@ -898,11 +898,11 @@ func modAction(name, op string, args []string) error { stmt.Actions.ExtCommunity.Communities = args[1:] switch strings.ToLower(args[0]) { case "add": - stmt.Actions.ExtCommunity.Type = api.CommunityActionType_COMMUNITY_ADD + stmt.Actions.ExtCommunity.ActionType = api.CommunityActionType_COMMUNITY_ADD case "remove": - stmt.Actions.ExtCommunity.Type = api.CommunityActionType_COMMUNITY_REMOVE + stmt.Actions.ExtCommunity.ActionType = api.CommunityActionType_COMMUNITY_REMOVE case "replace": - stmt.Actions.ExtCommunity.Type = api.CommunityActionType_COMMUNITY_REPLACE + stmt.Actions.ExtCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE default: return fmt.Errorf("%s ext-community { add | remove | replace } ...", usage) } @@ -914,11 +914,11 @@ func modAction(name, op string, args []string) error { stmt.Actions.LargeCommunity.Communities = args[1:] switch strings.ToLower(args[0]) { case "add": - stmt.Actions.LargeCommunity.Type = api.CommunityActionType_COMMUNITY_ADD + stmt.Actions.LargeCommunity.ActionType = api.CommunityActionType_COMMUNITY_ADD case "remove": - stmt.Actions.LargeCommunity.Type = api.CommunityActionType_COMMUNITY_REMOVE + stmt.Actions.LargeCommunity.ActionType = api.CommunityActionType_COMMUNITY_REMOVE case "replace": - stmt.Actions.LargeCommunity.Type = api.CommunityActionType_COMMUNITY_REPLACE + stmt.Actions.LargeCommunity.ActionType = api.CommunityActionType_COMMUNITY_REPLACE default: return fmt.Errorf("%s large-community { add | remove | replace } ...", usage) } @@ -934,12 +934,12 @@ func modAction(name, op string, args []string) error { stmt.Actions.Med.Value = int64(med) switch strings.ToLower(args[0]) { case "add": - stmt.Actions.Med.Type = api.MedActionType_MED_MOD + stmt.Actions.Med.ActionType = api.MedActionType_MED_MOD case "sub": - stmt.Actions.Med.Type = api.MedActionType_MED_MOD + stmt.Actions.Med.ActionType = api.MedActionType_MED_MOD stmt.Actions.Med.Value = -1 * stmt.Actions.Med.Value case "set": - stmt.Actions.Med.Type = api.MedActionType_MED_REPLACE + stmt.Actions.Med.ActionType = api.MedActionType_MED_REPLACE default: return fmt.Errorf("%s med { add | sub | set } ", usage) } diff --git a/cmd/gobgpd/main.go b/cmd/gobgpd/main.go index 5c8f5ac5..15851bd7 100644 --- a/cmd/gobgpd/main.go +++ b/cmd/gobgpd/main.go @@ -218,7 +218,7 @@ func main() { if err := bgpServer.AddBmp(context.Background(), &api.AddBmpRequest{ Address: c.Config.Address, Port: c.Config.Port, - Type: api.AddBmpRequest_MonitoringPolicy(c.Config.RouteMonitoringPolicy.ToInt()), + Policy: api.AddBmpRequest_MonitoringPolicy(c.Config.RouteMonitoringPolicy.ToInt()), StatisticsTimeout: int32(c.Config.StatisticsTimeout), }); err != nil { log.Fatalf("failed to set bmp config: %s", err) -- cgit v1.2.3