diff --git a/api/entry.go b/api/entry.go index e5f9695..531b14e 100644 --- a/api/entry.go +++ b/api/entry.go @@ -413,30 +413,6 @@ func MAC(mac string) func(proto.Message) error { } } -// ProgrammedIndex NOTE: used for both NH ProgrammedIndex and NHG ProgrammedId -func ProgrammedIndex(pIndex uint64) func(proto.Message) error { - return func(msg proto.Message) error { - if msg == nil { - return ErrInvalidMsgType - } - switch msg := msg.ProtoReflect().Interface().(type) { - case *gribi_aft.Afts_NextHopKey: - if msg.NextHop == nil { - msg.NextHop = new(gribi_aft.Afts_NextHop) - } - msg.NextHop.ProgrammedIndex = &ywrapper.UintValue{Value: pIndex} - case *gribi_aft.Afts_NextHopGroupKey: - if msg.NextHopGroup == nil { - msg.NextHopGroup = new(gribi_aft.Afts_NextHopGroup) - } - msg.NextHopGroup.ProgrammedId = &ywrapper.UintValue{Value: pIndex} - default: - return fmt.Errorf("option ProgrammedIndex: %w: %T", ErrInvalidMsgType, msg) - } - return nil - } -} - func PushedMplsLabelStack(typ string, label uint64) func(proto.Message) error { return func(msg proto.Message) error { if msg == nil { diff --git a/cmd/root.go b/cmd/root.go index 9f7a6fc..1647784 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,7 +15,7 @@ func newRootCmd() *cobra.Command { gApp.RootCmd = &cobra.Command{ Use: "gribic", Short: "run gRIBI RPCs from the terminal", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(cmd *cobra.Command, _ []string) { gApp.Config.SetPersistentFlagsFromFile(cmd) }, PersistentPreRunE: gApp.PreRun, diff --git a/cmd/server.go b/cmd/server.go index 49b1b42..dba1f72 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -1,6 +1,5 @@ /* Copyright © 2022 Karim Radhouani - */ package cmd @@ -13,7 +12,7 @@ func newServerCmd() *cobra.Command { Use: "server", Aliases: []string{"serve", "s"}, Short: "start a gNMI server", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(cmd *cobra.Command, _ []string) { gApp.Config.SetLocalFlagsFromFile(cmd) }, RunE: gApp.RunEServer, diff --git a/cmd/versionUpgrade.go b/cmd/versionUpgrade.go index 6bd5280..1e5137b 100644 --- a/cmd/versionUpgrade.go +++ b/cmd/versionUpgrade.go @@ -13,7 +13,7 @@ func newVersionUpgradeCmd() *cobra.Command { Use: "upgrade", Aliases: []string{"up"}, Short: "upgrade gRIBIc to latest available version", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(cmd *cobra.Command, _ []string) { gApp.Config.SetLocalFlagsFromFile(cmd) }, RunE: gApp.VersionUpgradeRun, diff --git a/cmd/workflow.go b/cmd/workflow.go index 7613930..838e169 100644 --- a/cmd/workflow.go +++ b/cmd/workflow.go @@ -1,6 +1,5 @@ /* Copyright © 2022 NAME HERE - */ package cmd @@ -13,7 +12,7 @@ func newWorkflowCmd() *cobra.Command { Use: "workflow", Aliases: []string{"wf", "w"}, Short: "run a workflow", - PreRun: func(cmd *cobra.Command, args []string) { + PreRun: func(cmd *cobra.Command, _ []string) { gApp.Config.SetLocalFlagsFromFile(cmd) }, PreRunE: gApp.WorkflowPreRunE, diff --git a/config/modify.go b/config/modify.go index a6ca9a8..0dd8e94 100644 --- a/config/modify.go +++ b/config/modify.go @@ -126,7 +126,6 @@ func (o *OperationConfig) CreateAftOper() (*spb.AFTOperation, error) { api.EncapsulateHeader(o.NH.EncapsulateHeader), api.DecapsulateHeader(o.NH.DecapsulateHeader), api.IPAddress(o.NH.IPAddress), - // api.MAC(o.NH.MAC), api.NetworkInstance(o.NH.NetworkInstance), } @@ -145,9 +144,6 @@ func (o *OperationConfig) CreateAftOper() (*spb.AFTOperation, error) { api.IPinIP(o.NH.IPinIP.SRCIP, o.NH.IPinIP.DSTIP), ) } - if o.NH.ProgrammedIndex != nil { - nheOpts = append(nheOpts, api.ProgrammedIndex(*o.NH.ProgrammedIndex)) - } for _, pmls := range o.NH.PushedMPLSLabelStack { nheOpts = append(nheOpts, @@ -167,9 +163,7 @@ func (o *OperationConfig) CreateAftOper() (*spb.AFTOperation, error) { if o.NHG.Color != nil { nhgeOpts = append(nhgeOpts, api.Color(*o.NHG.Color)) } - if o.NHG.ProgrammedID != nil { - nhgeOpts = append(nhgeOpts, api.ProgrammedIndex(*o.NHG.ProgrammedID)) - } + for _, nh := range o.NHG.NextHop { nhgeOpts = append(nhgeOpts, api.NHGNextHop(nh.Index, nh.Weight)) } diff --git a/go.mod b/go.mod index 899ea9d..72fad62 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v1.5.0 github.com/openconfig/gnmi v0.0.0-20220503232738-6eb133c65a13 - github.com/openconfig/gribi v0.1.1-0.20220126144445-1634932f9fd8 + github.com/openconfig/gribi v0.1.1-0.20220622162620-08d53dffce45 github.com/openconfig/gribigo v0.0.0-20220216214442-0aae099db56f github.com/prometheus/client_golang v1.12.2 github.com/sirupsen/logrus v1.8.1 diff --git a/go.sum b/go.sum index c3082eb..615679b 100644 --- a/go.sum +++ b/go.sum @@ -776,8 +776,9 @@ github.com/openconfig/goyang v0.2.9/go.mod h1:vX61x01Q46AzbZUzG617vWqh/cB+aisc+R github.com/openconfig/goyang v1.0.0 h1:nYaFu7BOAk/eQn4CgAUjgYPfp3J6CdXrBryp32E5CjI= github.com/openconfig/goyang v1.0.0/go.mod h1:vX61x01Q46AzbZUzG617vWqh/cB+aisc+RrNkXRd3W8= github.com/openconfig/gribi v0.1.1-0.20210423184541-ce37eb4ba92f/go.mod h1:OoH46A2kV42cIXGyviYmAlGmn6cHjGduyC2+I9d/iVs= -github.com/openconfig/gribi v0.1.1-0.20220126144445-1634932f9fd8 h1:V6QU1cocKPRP1yEfxg0cleaIh95d4yRY572UwKu/W+0= github.com/openconfig/gribi v0.1.1-0.20220126144445-1634932f9fd8/go.mod h1:VFqGH2ZPFIfnKTimP4/AQB4OK0eySW5muJNFxXAwP6k= +github.com/openconfig/gribi v0.1.1-0.20220622162620-08d53dffce45 h1:pmwzRJYdvc+CQDrIw6NF0XBnTng6SvMYBdZz9CeRbCk= +github.com/openconfig/gribi v0.1.1-0.20220622162620-08d53dffce45/go.mod h1:VFqGH2ZPFIfnKTimP4/AQB4OK0eySW5muJNFxXAwP6k= github.com/openconfig/gribigo v0.0.0-20220216214442-0aae099db56f h1:W+4+uRld9Tgji/QK/85Ts1ybHWno0LjiGkOyRBNAWUU= github.com/openconfig/gribigo v0.0.0-20220216214442-0aae099db56f/go.mod h1:udA2WsTVQk9QKDOjNq1UlJ4p5Us8/5HP1bsoYp+ZoKw= github.com/openconfig/grpctunnel v0.0.0-20210610163803-fde4a9dc048d/go.mod h1:x9tAZ4EwqCQ0jI8D6S8Yhw9Z0ee7/BxWQX0k0Uib5Q8=