forked from docker/compose-on-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs.go
55 lines (44 loc) · 1.7 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package registry
import (
"context"
"net/http"
"github.com/docker/compose-on-kubernetes/api/compose/latest"
log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/runtime"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/registry/rest"
restclient "k8s.io/client-go/rest"
)
type stackLogRest struct {
config *restclient.Config
}
var _ rest.Storage = &stackLogRest{}
var _ rest.Connecter = &stackLogRest{}
// NewStackLogRest returns a rest storage for log subresource
func NewStackLogRest(config *restclient.Config) rest.Storage {
return &stackLogRest{config: config}
}
func (s *stackLogRest) New() runtime.Object {
return &latest.Stack{} // Not used here, but needs to be a valid and registered type.
}
// ProducesMIMETypes returns a list of the MIME types the specified HTTP verb (GET, POST, DELETE,
// PATCH) can respond with.
func (s *stackLogRest) ProducesMIMETypes(verb string) []string {
return []string{"application/octet-stream"}
}
// ProducesObject returns an object the specified HTTP verb respond with. It will overwrite storage object if
// it is not nil. Only the type of the return object matters, the value will be ignored.
func (s *stackLogRest) ProducesObject(verb string) interface{} {
return nil
}
func (s *stackLogRest) ConnectMethods() []string {
return []string{"GET"}
}
func (s *stackLogRest) NewConnectOptions() (runtime.Object, bool, string) {
return nil, false, ""
}
func (s *stackLogRest) Connect(ctx context.Context, name string, options runtime.Object, r rest.Responder) (http.Handler, error) {
namespace, _ := genericapirequest.NamespaceFrom(ctx)
log.Infof("log connect %s/%s", namespace, name)
return &logStreamer{s.config, namespace, name}, nil
}