Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
goSDN
Commits
c38cf281
Commit
c38cf281
authored
4 years ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Revert "some minor adjustments for context keys"
This reverts commit
3cbe1d63
.
parent
3cbe1d63
No related branches found
No related tags found
2 merge requests
!120
Resolve "Code Quality"
,
!90
Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nucleus/gnmi_transport.go
+3
-9
3 additions, 9 deletions
nucleus/gnmi_transport.go
nucleus/integration_test.go
+2
-2
2 additions, 2 deletions
nucleus/integration_test.go
with
5 additions
and
11 deletions
nucleus/gnmi_transport.go
+
3
−
9
View file @
c38cf281
...
@@ -11,16 +11,10 @@ import (
...
@@ -11,16 +11,10 @@ import (
"strings"
"strings"
)
)
// CtxKeyType is a custom type to be used as key in a context.WithValue() or
type
CtxKeyType
string
// context.Value() call. For more information see:
// https://www.calhoun.io/pitfalls-of-context-values-and-how-to-avoid-or-mitigate-them/
type
CtxKeyType
int
const
(
const
(
// CtxKeyOpts context key for gnmi.SubscribeOptions
CtxKeyOpts
CtxKeyType
=
"opts"
CtxKeyOpts
CtxKeyType
=
iota
CtxKeyConfig
=
"config"
// CtxKeyConfig is a context key for gnmi.Config
CtxKeyConfig
)
)
// Gnmi implements the Transport interface and provides an SBI with the
// Gnmi implements the Transport interface and provides an SBI with the
...
...
This diff is collapsed.
Click to expand it.
nucleus/integration_test.go
+
2
−
2
View file @
c38cf281
...
@@ -109,7 +109,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
...
@@ -109,7 +109,7 @@ func TestGnmi_SetIntegration(t *testing.T) {
if
err
!=
nil
&&
tt
.
wantErr
{
if
err
!=
nil
&&
tt
.
wantErr
{
return
return
}
else
if
got
.
Prefix
.
Target
!=
address
||
}
else
if
got
.
Prefix
.
Target
!=
address
||
got
.
Response
[
0
]
.
Op
!=
gpb
.
UpdateResult_UPDATE
{
got
.
Response
[
0
]
.
Op
!=
gpb
.
UpdateResult_UPDATE
{
t
.
Errorf
(
"Set() got = %v, want %v"
,
got
,
tt
.
want
)
t
.
Errorf
(
"Set() got = %v, want %v"
,
got
,
tt
.
want
)
}
}
})
})
...
@@ -271,7 +271,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
...
@@ -271,7 +271,7 @@ func TestGnmi_SubscribeIntegration(t *testing.T) {
t
.
Error
(
err
)
t
.
Error
(
err
)
return
return
}
}
ctx
:=
context
.
WithValue
(
context
.
Background
(),
CtxKeyO
pts
,
tt
.
args
.
opts
)
ctx
:=
context
.
WithValue
(
context
.
Background
(),
"o
pts
"
,
tt
.
args
.
opts
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
go
func
()
{
go
func
()
{
err
=
g
.
Subscribe
(
ctx
)
err
=
g
.
Subscribe
(
ctx
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment