Skip to content

Commit c007659

Browse files
committed
Move LogRequestor into k8s package
This allows the code to be vendored into the openfaas-operator. Tested with go build. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 31b00df commit c007659

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

handlers/log.go renamed to k8s/log.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright 2019 OpenFaaS Author(s)
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
package handlers
4+
package k8s
55

66
import (
77
"context"
88
"log"
99

10-
"github.com/openfaas/faas-netes/k8s"
1110
"github.com/openfaas/faas-provider/logs"
1211
"k8s.io/client-go/kubernetes"
1312
)
@@ -30,13 +29,13 @@ func NewLogRequestor(client kubernetes.Interface, functionNamespace string) *Log
3029
// This implementation ignores the r.Limit value because the OF-Provider already handles server side
3130
// line limits.
3231
func (l LogRequestor) Query(ctx context.Context, r logs.Request) (<-chan logs.Message, error) {
33-
logStream, err := k8s.GetLogs(ctx, l.client, r.Name, l.functionNamespace, int64(r.Tail), r.Since, r.Follow)
32+
logStream, err := GetLogs(ctx, l.client, r.Name, l.functionNamespace, int64(r.Tail), r.Since, r.Follow)
3433
if err != nil {
3534
log.Printf("LogRequestor: get logs failed: %s\n", err)
3635
return nil, err
3736
}
3837

39-
msgStream := make(chan logs.Message, k8s.LogBufferSize)
38+
msgStream := make(chan logs.Message, LogBufferSize)
4039
go func() {
4140
defer close(msgStream)
4241
// here we depend on the fact that logStream will close when the context is cancelled,

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func main() {
107107
HealthHandler: handlers.MakeHealthHandler(),
108108
InfoHandler: handlers.MakeInfoHandler(version.BuildVersion(), version.GitCommit),
109109
SecretHandler: handlers.MakeSecretHandler(functionNamespace, clientset),
110-
LogHandler: logs.NewLogHandlerFunc(handlers.NewLogRequestor(clientset, functionNamespace), cfg.FaaSConfig.WriteTimeout),
110+
LogHandler: logs.NewLogHandlerFunc(k8s.NewLogRequestor(clientset, functionNamespace), cfg.FaaSConfig.WriteTimeout),
111111
ListNamespaceHandler: handlers.MakeNamespacesLister(functionNamespace, clientset),
112112
}
113113

0 commit comments

Comments
 (0)