Skip to content

Commit

Permalink
Merge pull request #497 from gliderlabs/master
Browse files Browse the repository at this point in the history
release 3.2.13
  • Loading branch information
michaelshobbs committed Nov 26, 2020
2 parents fdc00f0 + 99f410a commit e1467ec
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 31 deletions.
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ linters:
- gochecknoglobals
- funlen
- gochecknoinits
- godot
- wsl
- nolintlint
- testpackage
- dupl
- goerr113

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
Expand All @@ -71,7 +77,7 @@ run:
# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.27.x # use the fixed version to not introduce new linters unexpectedly
prepare:
- echo "here I can run custom commands, but no preparation needed for this repo"

11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ All notable changes to this project will be documented in this file.

### Changed


## [v3.2.13] - 2020-11-26
### Changed
- @michaelshobbs bump golangci-lint to 1.27 and fix lintballs

### Fixed
- @michaelshobbs fix backlog() logic and add tests

## [v3.2.12] - 2020-10-22
### Changed
- @michaelshobbs bump alpine to 3.12
Expand Down Expand Up @@ -247,7 +255,8 @@ All notable changes to this project will be documented in this file.
- Base container is now Alpine
- Moved to gliderlabs organization

[unreleased]: https://github.com/gliderlabs/logspout/compare/v3.2.12...HEAD
[unreleased]: https://github.com/gliderlabs/logspout/compare/v3.2.13...HEAD
[v3.2.13]: https://github.com/gliderlabs/logspout/compare/v3.2.12...v3.2.13
[v3.2.12]: https://github.com/gliderlabs/logspout/compare/v3.2.11...v3.2.12
[v3.2.11]: https://github.com/gliderlabs/logspout/compare/v3.2.10...v3.2.11
[v3.2.10]: https://github.com/gliderlabs/logspout/compare/v3.2.9...v3.2.10
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ VERSION=$(shell cat VERSION)
MAX_IMAGE_SIZE := 40000000

GOBIN := $(shell go env GOPATH | awk -F ":" '{ print $$1 }')/bin
GOLANGCI_LINT_VERSION := v1.18.0
GOLANGCI_LINT_VERSION := v1.27.0

ifeq ($(shell uname), Darwin)
XARGS_ARG="-L1"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ The standard distribution of logspout comes with all modules defined in this rep
* [logspout-redis-logstash](https://github.com/rtoma/logspout-redis-logstash)
* [logspout-gelf](https://github.com/micahhausler/logspout-gelf) for Graylog
* [logspout-fluentd](https://github.com/dsouzajude/logspout-fluentd) for fluentd or fluent-bit - instead of using fluentd log driver

* [logspout-slack](https://github.com/kalisio/logspout-slack) for [Slack](https://slack.com/) notifications

### Loggly support

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.2.12
v3.2.13
19 changes: 10 additions & 9 deletions adapters/multiline/multiline.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (
)

const (
matchFirst = "first"
matchLast = "last"
matchNonFirst = "nonfirst"
matchNonLast = "nonlast"
matchFirst = "first"
matchLast = "last"
matchNonFirst = "nonfirst"
matchNonLast = "nonlast"
defaultFlushAfter = 500 * time.Millisecond
)

func init() {
Expand Down Expand Up @@ -89,7 +90,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
return nil, errors.New("multiline: invalid value for MULTILINE_MATCH (must be one of first|last|nonfirst|nonlast): " + matchType)
}

flushAfter := 500 * time.Millisecond
flushAfter := defaultFlushAfter
flushAfterStr := os.Getenv("MULTILINE_FLUSH_AFTER")
if flushAfterStr != "" {
timeoutMS, errConv := strconv.Atoi(flushAfterStr)
Expand All @@ -100,7 +101,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
}

parts := strings.SplitN(route.Adapter, "+", 2)
if len(parts) != 2 {
if len(parts) != 2 { //nolint:gomnd
return nil, errors.New("multiline: adapter must have a sub-adapter, eg: multiline+raw+tcp")
}

Expand All @@ -117,7 +118,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
route.Adapter = originalAdapter

out := make(chan *router.Message)
checkInterval := flushAfter / 2
checkInterval := flushAfter / 2 //nolint:gomnd

return &Adapter{
out: out,
Expand All @@ -135,7 +136,7 @@ func NewMultilineAdapter(route *router.Route) (a router.LogAdapter, err error) {
}

// Stream sends log data to the next adapter
func (a *Adapter) Stream(logstream chan *router.Message) { //nolint:gocyclo
func (a *Adapter) Stream(logstream chan *router.Message) { //nolint:gocyclo,gocognit
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
Expand Down Expand Up @@ -165,7 +166,7 @@ func (a *Adapter) Stream(logstream chan *router.Message) { //nolint:gocyclo

cID := message.Container.ID
old, oldExists := a.buffers[cID]
if a.isFirstLine(message) {
if a.isFirstLine(message) { //nolint:nestif
if oldExists {
a.out <- old
}
Expand Down
12 changes: 7 additions & 5 deletions httpstream/httpstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"github.com/gliderlabs/logspout/router"
)

const maxRouteIDLen = 12

func init() {
router.HTTPHandlers.Register(LogStreamer, "logs")
}
Expand All @@ -35,8 +37,8 @@ func LogStreamer() http.Handler {
switch params["predicate"] {
case "id":
route.FilterID = params["value"]
if len(route.ID) > 12 {
route.FilterID = route.FilterID[:12]
if len(route.ID) > maxRouteIDLen {
route.FilterID = route.FilterID[:maxRouteIDLen]
}
case "name":
route.FilterName = params["value"]
Expand Down Expand Up @@ -83,10 +85,10 @@ func (c Colorizer) Get(key string) string {
i = c[key]
}
bright := "1;"
if i%14 > 6 {
if i%14 > 6 { //nolint:gomnd
bright = ""
}
return "\x1b[" + bright + "3" + strconv.Itoa(7-(i%7)) + "m"
return "\x1b[" + bright + "3" + strconv.Itoa(7-(i%7)) + "m" //nolint:gomnd
}

func marshal(obj interface{}) []byte {
Expand Down Expand Up @@ -134,7 +136,7 @@ func httpStreamer(w http.ResponseWriter, req *http.Request, logstream chan *rout
if req.URL.Query().Get("sources") != "" && logline.Source != req.URL.Query().Get("sources") {
continue
}
if usejson {
if usejson { //nolint:nestif
w.Write(append(marshal(logline), '\n'))
} else {
if multi {
Expand Down
2 changes: 1 addition & 1 deletion router/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (fs RouteFileStore) GetAll() ([]*Route, error) {

// Add writes a marshaled *Route to the RouteFileStore
func (fs RouteFileStore) Add(route *Route) error {
return ioutil.WriteFile(fs.Filename(route.ID), marshal(route), 0644)
return ioutil.WriteFile(fs.Filename(route.ID), marshal(route), 0600)
}

// Remove removes route from the RouteFileStore based on id
Expand Down
17 changes: 9 additions & 8 deletions router/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
pumpEventStatusRenameName = "rename"
pumpEventStatusDieName = "die"
trueString = "true"
pumpMaxIDLen = 12
)

var (
Expand All @@ -45,7 +46,7 @@ func debug(v ...interface{}) {
}

func backlog() bool {
return os.Getenv("BACKLOG") == "false"
return os.Getenv("BACKLOG") == trueString
}

func setAllowTTY() {
Expand All @@ -66,8 +67,8 @@ func normalName(name string) string {
}

func normalID(id string) string {
if len(id) > 12 {
return id[:12]
if len(id) > pumpMaxIDLen {
return id[:pumpMaxIDLen]
}
return id
}
Expand Down Expand Up @@ -101,7 +102,7 @@ func ignoreContainer(container *docker.Container) bool {
for _, label := range excludeLabelArr {
labelParts := strings.Split(label, ":")

if len(labelParts) == 2 {
if len(labelParts) == 2 { //nolint:gomnd
excludeLabel = labelParts[0]
excludeValue = labelParts[1]
}
Expand Down Expand Up @@ -321,8 +322,8 @@ func (p *LogsPump) Route(route *Route, logstream chan *Message) {
if route.MatchContainer(
normalID(pump.container.ID),
normalName(pump.container.Name),
pump.container.Config.Labels) {

pump.container.Config.Labels,
) {
pump.add(logstream, route)
defer pump.remove(logstream)
}
Expand All @@ -344,8 +345,8 @@ func (p *LogsPump) Route(route *Route, logstream chan *Message) {
if route.MatchContainer(
normalID(event.pump.container.ID),
normalName(event.pump.container.Name),
event.pump.container.Config.Labels) {

event.pump.container.Config.Labels,
) {
event.pump.add(logstream, route)
defer event.pump.remove(logstream)
}
Expand Down
19 changes: 19 additions & 0 deletions router/pump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,22 @@ func TestPumpRoutingFrom(t *testing.T) {
t.Errorf("expected RoutingFrom to return 'false'")
}
}

func TestPumpBacklog(t *testing.T) {
os.Unsetenv("BACKLOG")
if backlog() != false {
t.Errorf("expected backlog() to return 'false'")
}
os.Setenv("BACKLOG", "false")
if backlog() != false {
t.Errorf("expected backlog() to return 'false'")
}
os.Setenv("BACKLOG", "true")
if backlog() != true {
t.Errorf("expected backlog() to return 'true'")
}
os.Unsetenv("BACKLOG")
if backlog() != false {
t.Errorf("expected backlog() to return 'false'")
}
}
2 changes: 1 addition & 1 deletion transports/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func createTLSConfig() (tlsConfig *tls.Config, err error) {
tlsConfig = &tls.Config{}

// use stronger TLS settings if enabled
// TODO: perhaps this should be default setting
// perhaps this should be default setting @gbolo
if os.Getenv(envTLSHardening) == trueString {
tlsConfig.InsecureSkipVerify = false
tlsConfig.MinVersion = hardenedMinVersion
Expand Down
2 changes: 0 additions & 2 deletions transports/tls/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ func TestEmptyTrustStore(t *testing.T) {
if numOfTrustedCerts != 0 {
t.Fatalf("expected 0 RootCAs but got: %d", numOfTrustedCerts)
}

}

// TestSingleCustomCA should test the behavior of loading
Expand All @@ -52,7 +51,6 @@ func TestSingleCustomCA(t *testing.T) {
if !bytes.Contains(testTLSConfig.RootCAs.Subjects()[0], []byte(caRootCertSubjectCN)) {
t.Errorf("failed to load custom root CA into trust store: %s", caRootCertFileLocation)
}

}

// TestMultipleCustomCAs should test the behavior of loading
Expand Down

0 comments on commit e1467ec

Please sign in to comment.