Skip to content

Commit 3b60d6d

Browse files
committed
add goreleaser, docs
1 parent 580ab0c commit 3b60d6d

File tree

7 files changed

+49
-9
lines changed

7 files changed

+49
-9
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
- run:
1616
name: build
17-
command: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o release/ipvsctl ipvsctl.go
17+
command: GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -v -o release/ipvsctl ipvsctl.go
1818

1919
- save_cache:
2020
key: go-mod-v4-{{ checksum "go.sum" }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313

1414
*.code-workspace
1515
*.sh
16+
dist/
1617
release/
1718
.vscode/

.goreleaser.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
before:
2+
hooks:
3+
- go mod download
4+
builds:
5+
- goos:
6+
- linux
7+
archives:
8+
- replacements:
9+
linux: Linux
10+
386: i386
11+
amd64: x86_64
12+
checksum:
13+
name_template: 'checksums.txt'
14+
snapshot:
15+
name_template: "{{ .Tag }}-next"
16+
changelog:
17+
sort: asc
18+
filters:
19+
exclude:
20+
- '^docs:'
21+
- '^test:'
22+
- '^tests:'

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
VERSION := `cat VERSION`
21
SOURCES ?= $(shell find . -name "*.go" -type f)
32
BINARY_NAME = ipvsctl
43

54
all: clean lint build
65

76
.PHONY: build
87
build:
9-
GOOS=linux GOARCH=amd64 go build -o release/${BINARY_NAME} -ldflags="-X main.version=${VERSION}" ipvsctl.go
8+
GOOS=linux GOARCH=amd64 go build -o dist/${BINARY_NAME} ipvsctl.go
109

1110
lint:
1211
@for file in ${SOURCES} ; do \
@@ -24,6 +23,9 @@ cover:
2423

2524
.PHONY: clean
2625
clean:
27-
@rm -rf release/*
26+
@rm -rf dist/*
2827
@rm -f cover.out
2928

29+
.PHONY: release
30+
release:
31+
goreleaser --snapshot --rm-dist

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,27 @@ INFO Updated weight to 100 for service tcp://10.1.2.3:80/10.50.0.1:8080
7373
* Linux
7474
* ipvs kernel modules installed and loaded
7575

76+
## Install
77+
78+
You can build this as describe below or install one of the versions under the `releases` tab.
79+
`ipvsctl` makes modifications to the ipvs tables, so it either needs to be run as root or equipped
80+
with the appropriate capabilities, e.g.:
81+
82+
```bash
83+
$ chmod +x ipvsctl
84+
$ sudo cp ipvsctl /usr/local/bin
85+
$ sudo setcap 'cap_net_admin+eip' /usr/local/bin/ipvsctl
86+
```
87+
88+
Caution as this allows any user to modify ipvs tables! Please evaluate whether `sudo` or `setcap` is the right approach for you.
89+
7690
## Build
7791

7892
This project builds correctly for Linux only.
7993

8094
```bash
8195
$ make
82-
$ release/ipvsctl --version
96+
$ dist/ipvsctl --version
8397
0.2.1
8498
```
8599

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

ipvsctl.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import (
1111
)
1212

1313
var (
14-
version string
14+
version = "dev"
15+
commit = "none"
16+
date = "unknown"
1517
)
1618

1719
func main() {
@@ -27,9 +29,9 @@ func main() {
2729
verbose := app.BoolOpt("v verbose", c.Verbose, "Show information. Default: false. False equals to being quiet")
2830
paramsHostNetwork := app.BoolOpt("params-network", c.ParamsHostNetwork, "Dynamic parameters. Add every network interface name as resolvable ip address, e.g. net.eth0")
2931
paramsHostEnv := app.BoolOpt("params-env", c.ParamsHostNetwork, "Dynamic parameters. Add every environment entry, e.g. env.port=<ENV VAR \"port\">")
30-
paramsFiles := make([]string,10)
32+
paramsFiles := make([]string, 10)
3133
app.StringsOptPtr(&paramsFiles, "params-file", []string{c.ParamsFilesFromEnv}, "Dynamic parameters. Add parameters from yaml or json file.")
32-
paramsURLs := make([]string,10)
34+
paramsURLs := make([]string, 10)
3335
app.StringsOptPtr(&paramsURLs, "params-url", []string{c.ParamsURLsFromEnv}, "Dynamic parameters. Add parameters from yaml or json resource given by URL.")
3436

3537
app.Command("get", "retrieve ipvs configuration and returns as yaml", cmd.Get)

0 commit comments

Comments
 (0)