1 Star 0 Fork 0

zhuchance/kubernetes

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
Godeps
api/swagger-spec
build
cluster
cmd
contrib
docs
examples
federation
hack
hooks
logo
pkg
admission
api
apimachinery
apis
apiserver
auth
capabilities
client
cloudprovider
controller
conversion
credentialprovider
dns
fieldpath
fields
genericapiserver
healthz
httplog
hyperkube
kubectl
kubelet
kubemark
labels
master
metrics
probe
proxy
quota
registry
authorization
cachesize
certificates
clusterrole
clusterrolebinding
componentstatus
configmap
controller
daemonset
deployment
endpoint
event
experimental/controller/etcd
generic
horizontalpodautoscaler
ingress
job
limitrange
namespace
networkpolicy
node
persistentvolume
persistentvolumeclaim
petset
pod
etcd
rest
log.go
log_test.go
subresources.go
doc.go
strategy.go
strategy_test.go
poddisruptionbudget
podsecuritypolicy
podtemplate
rangeallocation
registrytest
replicaset
resourcequota
role
rolebinding
scheduledjob
secret
service
serviceaccount
storageclass
thirdpartyresource
thirdpartyresourcedata
tokenreview
OWNERS
doc.go
runtime
security
securitycontext
selection
serviceaccount
ssh
storage
types
ui
util
version
volume
watch
OWNERS
plugin
release
staging
test
third_party
vendor
www
.generated_docs
.gitignore
CHANGELOG.md
CONTRIB.md
CONTRIBUTING.md
DESIGN.md
LICENSE
Makefile
Makefile.generated_files
OWNERS
README.md
Vagrantfile
code-of-conduct.md
labels.yaml
克隆/下载
log.go 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package rest
import (
"fmt"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/api/rest"
"k8s.io/kubernetes/pkg/api/validation"
"k8s.io/kubernetes/pkg/kubelet/client"
"k8s.io/kubernetes/pkg/registry/generic/registry"
genericrest "k8s.io/kubernetes/pkg/registry/generic/rest"
"k8s.io/kubernetes/pkg/registry/pod"
"k8s.io/kubernetes/pkg/runtime"
)
// LogREST implements the log endpoint for a Pod
type LogREST struct {
KubeletConn client.ConnectionInfoGetter
Store *registry.Store
}
// LogREST implements GetterWithOptions
var _ = rest.GetterWithOptions(&LogREST{})
// New creates a new Pod log options object
func (r *LogREST) New() runtime.Object {
// TODO - return a resource that represents a log
return &api.Pod{}
}
// LogREST implements StorageMetadata
func (r *LogREST) ProducesMIMETypes(verb string) []string {
// Since the default list does not include "plain/text", we need to
// explicitly override ProducesMIMETypes, so that it gets added to
// the "produces" section for pods/{name}/log
return []string{
"text/plain",
}
}
// Get retrieves a runtime.Object that will stream the contents of the pod log
func (r *LogREST) Get(ctx api.Context, name string, opts runtime.Object) (runtime.Object, error) {
logOpts, ok := opts.(*api.PodLogOptions)
if !ok {
return nil, fmt.Errorf("invalid options object: %#v", opts)
}
if errs := validation.ValidatePodLogOptions(logOpts); len(errs) > 0 {
return nil, errors.NewInvalid(api.Kind("PodLogOptions"), name, errs)
}
location, transport, err := pod.LogLocation(r.Store, r.KubeletConn, ctx, name, logOpts)
if err != nil {
return nil, err
}
return &genericrest.LocationStreamer{
Location: location,
Transport: transport,
ContentType: "text/plain",
Flush: logOpts.Follow,
ResponseChecker: genericrest.NewGenericHttpResponseChecker(api.Resource("pods/log"), name),
}, nil
}
// NewGetOptions creates a new options object
func (r *LogREST) NewGetOptions() (runtime.Object, bool, string) {
return &api.PodLogOptions{}, false, ""
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/meoom/kubernetes.git
git@gitee.com:meoom/kubernetes.git
meoom
kubernetes
kubernetes
v1.4.5

搜索帮助