Skip to content

Commit

Permalink
fix missing parameter resolution in apply; update README
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmidt75 committed May 22, 2020
1 parent 7acacea commit 3a9ee3e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ Please see [the documentation section in doc/](doc/) for more details on command
```
# cat >/tmp/ipvsconf <<EOF
services:
- address: tcp://${host.eth0}:80
- address: tcp://\${host.eth0}:7656
sched: rr
destinations:
- address: 10.50.0.1:${env.MYPORT}
- address: 10.50.0.1:\${env.MYPORT}
forward: nat
- address: 10.50.0.2:${env.MYPORT}
- address: 10.50.0.2:\${env.MYPORT}
forward: nat
EOF
# MYPORT=8080 ipvsctl apply -f /tmp/ipvsconf
# MYPORT=8080 ipvsctl --params-network --params-env apply -f /tmp/ipvsconf
# ipvsctl get
# ipvsctl geti
services:
- address: tcp://10.1.2.3:80
- address: tcp://10.1.2.3:7656
sched: rr
destinations:
- address: 10.50.0.2:8080
Expand All @@ -53,7 +53,7 @@ services:
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.1.2.3:80 rr
TCP 10.1.2.3:7656 rr
-> 10.50.0.1:8080 Masq 0 0 0
-> 10.50.0.2:8080 Masq 0 0 0
Expand All @@ -77,7 +77,9 @@ INFO Updated weight to 100 for service tcp://10.1.2.3:80/10.50.0.1:8080
This project builds correctly for Linux only.

```bash
$ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o release/ipvsctl ipvsctl.go
$ make
$ release/ipvsctl --version
0.2.1
```

## Test
Expand Down Expand Up @@ -112,4 +114,4 @@ $ bats .
## License

(C) 2019 @aschmidt75, Apache 2.0 license
except package ipvs, integrated from https://github.com/docker/libnetwork (C) 2015 Docker, Inc. Apache 2.0 license
except package ipvs, integrated from https://github.com/docker/libnetwork (C) 2015 Docker, Inc. Apache 2.0 license
10 changes: 8 additions & 2 deletions cmd/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ Default * for all actions.

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

resolvedConfig, err := resolveParams(newConfig)
if err != nil {
log.Error(err)
os.Exit(exitParamErr)
}

// validate model before applying
err = newConfig.Validate()
err = resolvedConfig.Validate()
if err != nil {
log.Error(err)
os.Exit(exitValidateErr)
Expand All @@ -84,7 +90,7 @@ Default * for all actions.
log.WithField("allowedActions", allowedSet).Trace("parsed")

// apply new configuration
err = MustGetCurrentConfig().Apply(newConfig, integration.ApplyOpts{
err = MustGetCurrentConfig().Apply(resolvedConfig, integration.ApplyOpts{
KeepWeights: *keepWeights,
AllowedActions: allowedSet,
})
Expand Down

0 comments on commit 3a9ee3e

Please sign in to comment.