Skip to content

Commit

Permalink
add goreleaser, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmidt75 committed Mar 5, 2021
1 parent 580ab0c commit 3b60d6d
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

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

- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@

*.code-workspace
*.sh
dist/
release/
.vscode/
22 changes: 22 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
before:
hooks:
- go mod download
builds:
- goos:
- linux
archives:
- replacements:
linux: Linux
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- '^tests:'
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
VERSION := `cat VERSION`
SOURCES ?= $(shell find . -name "*.go" -type f)
BINARY_NAME = ipvsctl

all: clean lint build

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

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

.PHONY: clean
clean:
@rm -rf release/*
@rm -rf dist/*
@rm -f cover.out

.PHONY: release
release:
goreleaser --snapshot --rm-dist
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,27 @@ INFO Updated weight to 100 for service tcp://10.1.2.3:80/10.50.0.1:8080
* Linux
* ipvs kernel modules installed and loaded

## Install

You can build this as describe below or install one of the versions under the `releases` tab.
`ipvsctl` makes modifications to the ipvs tables, so it either needs to be run as root or equipped
with the appropriate capabilities, e.g.:

```bash
$ chmod +x ipvsctl
$ sudo cp ipvsctl /usr/local/bin
$ sudo setcap 'cap_net_admin+eip' /usr/local/bin/ipvsctl
```

Caution as this allows any user to modify ipvs tables! Please evaluate whether `sudo` or `setcap` is the right approach for you.

## Build

This project builds correctly for Linux only.

```bash
$ make
$ release/ipvsctl --version
$ dist/ipvsctl --version
0.2.1
```

Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

8 changes: 5 additions & 3 deletions ipvsctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
)

var (
version string
version = "dev"
commit = "none"
date = "unknown"
)

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

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

0 comments on commit 3b60d6d

Please sign in to comment.