Skip to content

Commit

Permalink
Merge branch 'main' into hotrod-client
Browse files Browse the repository at this point in the history
  • Loading branch information
graphaelli committed Feb 13, 2023
2 parents 09ef24b + 5cef48e commit c95524a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@3ebbd71c74ef574dbc558c82f70e52732c8b44fe
uses: github/codeql-action/init@17573ee1cc1b9d061760f3a006fc4aac4f944fd5
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -49,7 +49,7 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Autobuild
uses: github/codeql-action/autobuild@3ebbd71c74ef574dbc558c82f70e52732c8b44fe
uses: github/codeql-action/autobuild@17573ee1cc1b9d061760f3a006fc4aac4f944fd5

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3ebbd71c74ef574dbc558c82f70e52732c8b44fe
uses: github/codeql-action/analyze@17573ee1cc1b9d061760f3a006fc4aac4f944fd5
14 changes: 14 additions & 0 deletions cmd/query/app/mocks/Watcher.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions pkg/config/tlscfg/cert_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (

"github.com/fsnotify/fsnotify"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/pkg/fswatcher"
)

// certWatcher watches filesystem changes on certificates supplied via Options
Expand All @@ -37,7 +39,7 @@ type certWatcher struct {
mu sync.RWMutex
opts Options
logger *zap.Logger
watcher *fsnotify.Watcher
watcher fswatcher.Watcher
cert *tls.Certificate
caHash string
clientCAHash string
Expand All @@ -58,7 +60,7 @@ func newCertWatcher(opts Options, logger *zap.Logger) (*certWatcher, error) {
cert = &c
}

watcher, err := fsnotify.NewWatcher()
watcher, err := fswatcher.NewWatcher()
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -148,7 +150,7 @@ func (w *certWatcher) setupWatchedPaths() error {
func (w *certWatcher) watchChangesLoop(rootCAs, clientCAs *x509.CertPool) {
for {
select {
case event, ok := <-w.watcher.Events:
case event, ok := <-w.watcher.Events():
if !ok {
return // channel closed means the watcher is closed
}
Expand All @@ -158,7 +160,7 @@ func (w *certWatcher) watchChangesLoop(rootCAs, clientCAs *x509.CertPool) {
event.Op&fsnotify.Remove == fsnotify.Remove {
w.attemptReload(rootCAs, clientCAs)
}
case err, ok := <-w.watcher.Errors:
case err, ok := <-w.watcher.Errors():
if !ok {
return // channel closed means the watcher is closed
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/tlscfg/cert_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import (
"testing"
"time"

"github.com/fsnotify/fsnotify"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest/observer"

"github.com/jaegertracing/jaeger/pkg/fswatcher"
)

const (
Expand Down Expand Up @@ -340,7 +341,7 @@ func createTimestampDir(t *testing.T, dir string, ca, cert, key string) {
}

func TestAddCertsToWatch_err(t *testing.T) {
watcher, err := fsnotify.NewWatcher()
watcher, err := fswatcher.NewWatcher()
require.NoError(t, err)
defer watcher.Close()
w := &certWatcher{
Expand Down
6 changes: 6 additions & 0 deletions pkg/fswatcher/fs_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import "github.com/fsnotify/fsnotify"
// Primarily used for mocking the fsnotify lib.
type Watcher interface {
Add(name string) error
Close() error
Events() chan fsnotify.Event
Errors() chan error
}
Expand All @@ -34,6 +35,11 @@ func (f *fsnotifyWatcherWrapper) Add(name string) error {
return f.fsnotifyWatcher.Add(name)
}

// Close closes the watcher.
func (f *fsnotifyWatcherWrapper) Close() error {
return f.fsnotifyWatcher.Close()
}

// Events returns the fsnotify.Watcher's Events chan.
func (f *fsnotifyWatcherWrapper) Events() chan fsnotify.Event {
return f.fsnotifyWatcher.Events
Expand Down
3 changes: 3 additions & 0 deletions pkg/fswatcher/fs_watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ func TestFsWatcher(t *testing.T) {
err = w.Add("../../cmd/query/app/fixture/ui-config.json")
assert.NoError(t, err)

err = w.Close()
assert.NoError(t, err)

events := w.Events()
assert.NotZero(t, events)

Expand Down

0 comments on commit c95524a

Please sign in to comment.