Skip to content

Commit 9714f4a

Browse files
committed
fix: Syslog client is not available on windows
1 parent 8ca4326 commit 9714f4a

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

pkg/containerengine/docker.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import (
4343

4444
type docker struct {
4545
cli *client.Client
46-
syslog *localSyslog
46+
logger ContainerLogger
4747
}
4848

4949
var _ ContainerEngine = &docker{}
@@ -287,10 +287,9 @@ func (d *docker) ContainerExec(containerName string, cmd []string, workingDir st
287287
}
288288

289289
func (d *docker) Logger(stackPath string) ContainerLogger {
290-
if d.syslog == nil {
291-
d.syslog = &localSyslog{
292-
logPath: path.Join(utils.NitricLogDir(stackPath), "run.log"),
293-
}
290+
if d.logger != nil {
291+
return d.logger
294292
}
295-
return d.syslog
293+
d.logger = newSyslog(path.Join(utils.NitricLogDir(stackPath), "run.log"))
294+
return d.logger
296295
}

pkg/containerengine/syslog.go renamed to pkg/containerengine/syslog_other.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17+
// +build !windows
18+
1719
package containerengine
1820

1921
import (
@@ -38,6 +40,10 @@ type localSyslog struct {
3840
server *syslog.Server
3941
}
4042

43+
func newSyslog(logPath string) ContainerLogger {
44+
return &localSyslog{logPath: logPath}
45+
}
46+
4147
func (s *localSyslog) Stop() error {
4248
errList := utils.NewErrorList()
4349

pkg/containerengine/syslog_windows.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright Nitric Pty Ltd.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at:
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing, software
12+
// distributed under the License is distributed on an "AS IS" BASIS,
13+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
// See the License for the specific language governing permissions and
15+
// limitations under the License.
16+
17+
// +build windows
18+
19+
package containerengine
20+
21+
import (
22+
"github.com/docker/docker/api/types/container"
23+
)
24+
25+
type nullLogger struct {
26+
}
27+
28+
func newSyslog(logPath string) ContainerLogger {
29+
return &nullLogger{}
30+
}
31+
32+
func (n *nullLogger) Config() *container.LogConfig {
33+
return &container.LogConfig{}
34+
}
35+
36+
func (n *nullLogger) Stop() error { return nil }
37+
func (n *nullLogger) Start() error { return nil }

0 commit comments

Comments
 (0)