Skip to content

Commit 3a9ee3e

Browse files
committed
fix missing parameter resolution in apply; update README
1 parent 7acacea commit 3a9ee3e

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ Please see [the documentation section in doc/](doc/) for more details on command
2828
```
2929
# cat >/tmp/ipvsconf <<EOF
3030
services:
31-
- address: tcp://${host.eth0}:80
31+
- address: tcp://\${host.eth0}:7656
3232
sched: rr
3333
destinations:
34-
- address: 10.50.0.1:${env.MYPORT}
34+
- address: 10.50.0.1:\${env.MYPORT}
3535
forward: nat
36-
- address: 10.50.0.2:${env.MYPORT}
36+
- address: 10.50.0.2:\${env.MYPORT}
3737
forward: nat
3838
EOF
3939
40-
# MYPORT=8080 ipvsctl apply -f /tmp/ipvsconf
40+
# MYPORT=8080 ipvsctl --params-network --params-env apply -f /tmp/ipvsconf
4141
42-
# ipvsctl get
42+
# ipvsctl geti
4343
services:
44-
- address: tcp://10.1.2.3:80
44+
- address: tcp://10.1.2.3:7656
4545
sched: rr
4646
destinations:
4747
- address: 10.50.0.2:8080
@@ -53,7 +53,7 @@ services:
5353
IP Virtual Server version 1.2.1 (size=4096)
5454
Prot LocalAddress:Port Scheduler Flags
5555
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
56-
TCP 10.1.2.3:80 rr
56+
TCP 10.1.2.3:7656 rr
5757
-> 10.50.0.1:8080 Masq 0 0 0
5858
-> 10.50.0.2:8080 Masq 0 0 0
5959
@@ -77,7 +77,9 @@ INFO Updated weight to 100 for service tcp://10.1.2.3:80/10.50.0.1:8080
7777
This project builds correctly for Linux only.
7878

7979
```bash
80-
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o release/ipvsctl ipvsctl.go
80+
$ make
81+
$ release/ipvsctl --version
82+
0.2.1
8183
```
8284

8385
## Test
@@ -112,4 +114,4 @@ $ bats .
112114
## License
113115

114116
(C) 2019 @aschmidt75, Apache 2.0 license
115-
except package ipvs, integrated from https://github.com/docker/libnetwork (C) 2015 Docker, Inc. Apache 2.0 license
117+
except package ipvs, integrated from https://github.com/docker/libnetwork (C) 2015 Docker, Inc. Apache 2.0 license

cmd/apply.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,14 @@ Default * for all actions.
6969

7070
log.WithField("newconfig", newConfig).Debugf("read")
7171

72+
resolvedConfig, err := resolveParams(newConfig)
73+
if err != nil {
74+
log.Error(err)
75+
os.Exit(exitParamErr)
76+
}
77+
7278
// validate model before applying
73-
err = newConfig.Validate()
79+
err = resolvedConfig.Validate()
7480
if err != nil {
7581
log.Error(err)
7682
os.Exit(exitValidateErr)
@@ -84,7 +90,7 @@ Default * for all actions.
8490
log.WithField("allowedActions", allowedSet).Trace("parsed")
8591

8692
// apply new configuration
87-
err = MustGetCurrentConfig().Apply(newConfig, integration.ApplyOpts{
93+
err = MustGetCurrentConfig().Apply(resolvedConfig, integration.ApplyOpts{
8894
KeepWeights: *keepWeights,
8995
AllowedActions: allowedSet,
9096
})

0 commit comments

Comments
 (0)