Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
k8s-ingress
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-ingress
Commits
720ad2f6
Commit
720ad2f6
authored
Jun 12, 2020
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a String() method to vcl.Address.
parent
a5c865d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
8 deletions
+9
-8
varnish.go
pkg/varnish/varnish.go
+3
-4
varnish_test.go
pkg/varnish/varnish_test.go
+1
-4
spec.go
pkg/varnish/vcl/spec.go
+5
-0
No files found.
pkg/varnish/varnish.go
View file @
720ad2f6
...
...
@@ -40,7 +40,6 @@ import (
"os"
"reflect"
"regexp"
"strconv"
"strings"
"sync"
"time"
...
...
@@ -451,7 +450,7 @@ func (vc *Controller) updateVarnishSvcAddrs(key string, addrs []vcl.Address,
updateAddrs
:=
make
(
map
[
string
]
struct
{})
prevAddrs
:=
make
(
map
[
string
]
*
varnishInst
)
for
_
,
addr
:=
range
addrs
{
key
:=
addr
.
IP
+
":"
+
strconv
.
Itoa
(
int
(
addr
.
Port
)
)
key
:=
addr
.
String
(
)
updateAddrs
[
key
]
=
struct
{}{}
}
for
_
,
inst
:=
range
svc
.
instances
{
...
...
@@ -532,7 +531,7 @@ func (vc *Controller) AddOrUpdateVarnishSvc(key string, addrs []vcl.Address,
var
instances
[]
*
varnishInst
svc
=
&
varnishSvc
{}
for
_
,
addr
:=
range
addrs
{
admAddr
:=
addr
.
IP
+
":"
+
strconv
.
Itoa
(
int
(
addr
.
Port
)
)
admAddr
:=
addr
.
String
(
)
instance
:=
&
varnishInst
{
addr
:
admAddr
,
admMtx
:
&
sync
.
Mutex
{},
...
...
@@ -717,7 +716,7 @@ func (vc *Controller) HasConfig(svcKey string, addrs []vcl.Address,
}
newAddrs
:=
make
(
map
[
string
]
struct
{})
for
_
,
addr
:=
range
addrs
{
a
:=
addr
.
IP
+
":"
+
strconv
.
Itoa
(
int
(
addr
.
Port
)
)
a
:=
addr
.
String
(
)
newAddrs
[
a
]
=
struct
{}{}
}
curAddrs
:=
make
(
map
[
string
]
struct
{})
...
...
pkg/varnish/varnish_test.go
View file @
720ad2f6
...
...
@@ -30,7 +30,6 @@ package varnish
import
(
"fmt"
"strconv"
"strings"
"testing"
...
...
@@ -220,9 +219,7 @@ func TestHasConfig(t *testing.T) {
}
instances
:=
make
([]
*
varnishInst
,
len
(
svcAddrs
))
for
i
,
addr
:=
range
svcAddrs
{
instances
[
i
]
=
&
varnishInst
{
addr
:
addr
.
IP
+
":"
+
strconv
.
Itoa
(
int
(
addr
.
Port
)),
}
instances
[
i
]
=
&
varnishInst
{
addr
:
addr
.
String
()}
}
vSvc
:=
varnishSvc
{
spec
:
&
spec
,
...
...
pkg/varnish/vcl/spec.go
View file @
720ad2f6
...
...
@@ -35,6 +35,7 @@ import (
"math"
"math/big"
"sort"
"strconv"
)
func
hashUint16
(
u16
uint16
,
hash
hash
.
Hash
)
{
...
...
@@ -51,6 +52,10 @@ type Address struct {
Port
int32
}
func
(
addr
Address
)
String
()
string
{
return
addr
.
IP
+
":"
+
strconv
.
Itoa
(
int
(
addr
.
Port
))
}
func
(
addr
Address
)
hash
(
hash
hash
.
Hash
)
{
portBytes
:=
make
([]
byte
,
4
)
binary
.
BigEndian
.
PutUint32
(
portBytes
,
uint32
(
addr
.
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