Labels sorting by default and enhancements
Faster building, disable API fix.
This commit is contained in:
parent
2f4203e7c3
commit
58495d59c1
28
Makefile
28
Makefile
@ -1,4 +1,4 @@
|
|||||||
VERSION=1.0
|
VERSION=1.1
|
||||||
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
@ -12,25 +12,39 @@ clean:
|
|||||||
test:
|
test:
|
||||||
go test -v server/*.go
|
go test -v server/*.go
|
||||||
|
|
||||||
.PHONY: build
|
init:
|
||||||
build: test clean
|
|
||||||
mkdir -p ./bin
|
mkdir -p ./bin
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: test clean init linux-amd64 linux-arm linux-arm64 darwin-amd64 darwin-arm64
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: linux-amd64
|
||||||
|
linux-amd64: clean init
|
||||||
# linux amd64
|
# linux amd64
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyd-${VERSION}-linux-amd64 daemon/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyd-${VERSION}-linux-amd64 daemon/*.go
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyctl-${VERSION}-linux-amd64 ctl/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyctl-${VERSION}-linux-amd64 ctl/*.go
|
||||||
|
|
||||||
|
.PHONY: linux-arm
|
||||||
|
linux-arm: clean init
|
||||||
# linux arm
|
# linux arm
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o ./bin/lobbyd-${VERSION}-linux-arm daemon/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o ./bin/lobbyd-${VERSION}-linux-arm daemon/*.go
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o ./bin/lobbyctl-${VERSION}-linux-arm ctl/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o ./bin/lobbyctl-${VERSION}-linux-arm ctl/*.go
|
||||||
|
|
||||||
|
.PHONY: linux-arm64
|
||||||
|
linux-arm64: clean init
|
||||||
# linux arm64
|
# linux arm64
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyd-${VERSION}-linux-arm64 daemon/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyd-${VERSION}-linux-arm64 daemon/*.go
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyctl-${VERSION}-linux-arm64 ctl/*.go
|
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyctl-${VERSION}-linux-arm64 ctl/*.go
|
||||||
|
|
||||||
|
.PHONY: darwin-amd64
|
||||||
|
darwin-amd64: clean init
|
||||||
# darwin amd64
|
# darwin amd64
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyd-${VERSION}-darwin-amd64 daemon/*.go
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./bin/lobbyd-${VERSION}-darwin-amd64 daemon/*.go
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/lobbyctl-${VERSION}-darwin-amd64 ctl/*.go
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./bin/lobbyctl-${VERSION}-darwin-amd64 ctl/*.go
|
||||||
|
|
||||||
|
.PHONY: darwin-arm64
|
||||||
|
darwin-arm64: clean init
|
||||||
# darwin arm64
|
# darwin arm64
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyd-${VERSION}-darwin-arm64 daemon/*.go
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./bin/lobbyd-${VERSION}-darwin-arm64 daemon/*.go
|
||||||
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o ./bin/lobbyctl-${VERSION}-darwin-arm64 ctl/*.go
|
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./bin/lobbyctl-${VERSION}-darwin-arm64 ctl/*.go
|
||||||
|
@ -163,7 +163,7 @@ func main() {
|
|||||||
e.Use(middleware.Recover())
|
e.Use(middleware.Recover())
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
if config.DisableAPI {
|
if !config.DisableAPI {
|
||||||
e.GET("/", listHandler)
|
e.GET("/", listHandler)
|
||||||
e.GET("/v1/discovery", getIdentificationHandler)
|
e.GET("/v1/discovery", getIdentificationHandler)
|
||||||
e.GET("/v1/discoveries", listHandler)
|
e.GET("/v1/discoveries", listHandler)
|
||||||
|
@ -3,6 +3,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -56,6 +57,18 @@ func (d *Discovery) FindLabels(prefix string) Labels {
|
|||||||
return labels
|
return labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *Discovery) SortLabels() {
|
||||||
|
labelStrings := d.Labels.StringSlice()
|
||||||
|
sort.Strings(labelStrings)
|
||||||
|
|
||||||
|
labels := Labels{}
|
||||||
|
for _, label := range labelStrings {
|
||||||
|
labels = append(labels, Label(label))
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Labels = labels
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------
|
// -----------------
|
||||||
// Discovery storage
|
// Discovery storage
|
||||||
// -----------------
|
// -----------------
|
||||||
|
@ -138,6 +138,7 @@ func (l *LocalHost) GetIdentification() (Discovery, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
discovery.Labels = append(l.InitialLabels, localLabels...)
|
discovery.Labels = append(l.InitialLabels, localLabels...)
|
||||||
|
discovery.SortLabels()
|
||||||
|
|
||||||
return discovery, nil
|
return discovery, nil
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func TestGetIdentification(t *testing.T) {
|
|||||||
discovery, err = localHost.GetIdentification()
|
discovery, err = localHost.GetIdentification()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
|
||||||
assert.Equal(t, Label("public_ip:1.2.3.4"), discovery.Labels[3])
|
assert.Equal(t, Label("test:1"), discovery.Labels[3])
|
||||||
|
|
||||||
os.RemoveAll(tmpPath)
|
os.RemoveAll(tmpPath)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user