Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
15682dfc
Commit
15682dfc
authored
May 19, 2019
by
Andrew Sy Kim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
export serviceKey and realServerKey in fake ipvs for easier test fixtures
Signed-off-by:
Andrew Sy Kim
<
kiman@vmware.com
>
parent
c854f72d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
fake.go
pkg/util/ipvs/testing/fake.go
+14
-12
No files found.
pkg/util/ipvs/testing/fake.go
View file @
15682dfc
...
@@ -27,47 +27,49 @@ import (
...
@@ -27,47 +27,49 @@ import (
//FakeIPVS no-op implementation of ipvs Interface
//FakeIPVS no-op implementation of ipvs Interface
type
FakeIPVS
struct
{
type
FakeIPVS
struct
{
Scheduler
string
Scheduler
string
Services
map
[
s
erviceKey
]
*
utilipvs
.
VirtualServer
Services
map
[
S
erviceKey
]
*
utilipvs
.
VirtualServer
Destinations
map
[
s
erviceKey
][]
*
utilipvs
.
RealServer
Destinations
map
[
S
erviceKey
][]
*
utilipvs
.
RealServer
}
}
type
serviceKey
struct
{
// ServiceKey uniquely identifies a Service for an IPVS virtual server
type
ServiceKey
struct
{
IP
string
IP
string
Port
uint16
Port
uint16
Protocol
string
Protocol
string
}
}
func
(
s
*
s
erviceKey
)
String
()
string
{
func
(
s
*
S
erviceKey
)
String
()
string
{
return
fmt
.
Sprintf
(
"%s:%d/%s"
,
s
.
IP
,
s
.
Port
,
s
.
Protocol
)
return
fmt
.
Sprintf
(
"%s:%d/%s"
,
s
.
IP
,
s
.
Port
,
s
.
Protocol
)
}
}
type
realServerKey
struct
{
// RealServerKey uniquely identifies an Endpoint for an IPVS real server
type
RealServerKey
struct
{
Address
net
.
IP
Address
net
.
IP
Port
uint16
Port
uint16
}
}
func
(
r
*
r
ealServerKey
)
String
()
string
{
func
(
r
*
R
ealServerKey
)
String
()
string
{
return
net
.
JoinHostPort
(
r
.
Address
.
String
(),
strconv
.
Itoa
(
int
(
r
.
Port
)))
return
net
.
JoinHostPort
(
r
.
Address
.
String
(),
strconv
.
Itoa
(
int
(
r
.
Port
)))
}
}
//NewFake creates a fake ipvs implementation - a cache store.
//NewFake creates a fake ipvs implementation - a cache store.
func
NewFake
()
*
FakeIPVS
{
func
NewFake
()
*
FakeIPVS
{
return
&
FakeIPVS
{
return
&
FakeIPVS
{
Services
:
make
(
map
[
s
erviceKey
]
*
utilipvs
.
VirtualServer
),
Services
:
make
(
map
[
S
erviceKey
]
*
utilipvs
.
VirtualServer
),
Destinations
:
make
(
map
[
s
erviceKey
][]
*
utilipvs
.
RealServer
),
Destinations
:
make
(
map
[
S
erviceKey
][]
*
utilipvs
.
RealServer
),
}
}
}
}
func
toServiceKey
(
serv
*
utilipvs
.
VirtualServer
)
s
erviceKey
{
func
toServiceKey
(
serv
*
utilipvs
.
VirtualServer
)
S
erviceKey
{
return
s
erviceKey
{
return
S
erviceKey
{
IP
:
serv
.
Address
.
String
(),
IP
:
serv
.
Address
.
String
(),
Port
:
serv
.
Port
,
Port
:
serv
.
Port
,
Protocol
:
serv
.
Protocol
,
Protocol
:
serv
.
Protocol
,
}
}
}
}
func
toRealServerKey
(
rs
*
utilipvs
.
RealServer
)
*
r
ealServerKey
{
func
toRealServerKey
(
rs
*
utilipvs
.
RealServer
)
*
R
ealServerKey
{
return
&
r
ealServerKey
{
return
&
R
ealServerKey
{
Address
:
rs
.
Address
,
Address
:
rs
.
Address
,
Port
:
rs
.
Port
,
Port
:
rs
.
Port
,
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment