Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
36ecc33c
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36ecc33c
编写于
3月 08, 2016
作者:
P
Piotr Bryk
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #500 from maciaszczykm/go-report-card
Add go report card and gofmt files
上级
c9976697
d56d326e
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
54 addition
and
48 deletion
+54
-48
README.md
README.md
+1
-1
src/app/backend/apihandler.go
src/app/backend/apihandler.go
+8
-5
src/app/backend/apiserverclient.go
src/app/backend/apiserverclient.go
+1
-1
src/app/backend/events.go
src/app/backend/events.go
+7
-7
src/app/backend/eventscommon.go
src/app/backend/eventscommon.go
+1
-1
src/app/backend/heapsterclient.go
src/app/backend/heapsterclient.go
+8
-8
src/app/backend/logs.go
src/app/backend/logs.go
+3
-3
src/app/backend/namespaces.go
src/app/backend/namespaces.go
+4
-4
src/app/backend/replicationcontrollercommon.go
src/app/backend/replicationcontrollercommon.go
+1
-0
src/app/backend/replicationcontrollerdetail.go
src/app/backend/replicationcontrollerdetail.go
+4
-4
src/app/backend/replicationcontrollerlist.go
src/app/backend/replicationcontrollerlist.go
+2
-2
src/app/backend/validateimagereference.go
src/app/backend/validateimagereference.go
+1
-1
src/app/backend/validateprotocol.go
src/app/backend/validateprotocol.go
+6
-4
src/test/backend/deploy_test.go
src/test/backend/deploy_test.go
+2
-2
src/test/backend/replicationcontrollerdetail_test.go
src/test/backend/replicationcontrollerdetail_test.go
+2
-2
src/test/backend/validateimagereference_test.go
src/test/backend/validateimagereference_test.go
+3
-3
未找到文件。
README.md
浏览文件 @
36ecc33c
# Kubernetes Dashboard
[
![Build Status
](
https://travis-ci.org/kubernetes/dashboard.svg?branch=master
)
](https://travis-ci.org/kubernetes/dashboard)
[
![Coverage Status
](
https://codecov.io/github/bryk/dashboard/coverage.svg?branch=master
)
](https://codecov.io/github/bryk/dashboard?branch=master)
[
![Go Report Card
](
https://goreportcard.com/badge/github.com/kubernetes/dashboard
)
](https://goreportcard.com/badge/github.com/kubernetes/dashboard)
Kubernetes Dashboard is a general purpose, web-based UI for Kubernetes clusters. It allows users to
manage applications running in the cluster and troubleshoot them, as well as manage the cluster
...
...
src/app/backend/apihandler.go
浏览文件 @
36ecc33c
...
...
@@ -26,7 +26,10 @@ import (
)
const
(
// RequestLogString is a template for request log message.
RequestLogString
=
"Incoming %s %s %s request from %s"
// ResponseLogString is a template for response log message.
ResponseLogString
=
"Outcoming response to %s with %d status code"
)
...
...
@@ -37,7 +40,7 @@ func wsLogger(req *restful.Request, resp *restful.Response, chain *restful.Filte
log
.
Printf
(
FormatResponseLog
(
resp
,
req
))
}
// Formats request log string.
// Format
RequestLog format
s request log string.
// TODO(maciaszczykm): Display request body.
func
FormatRequestLog
(
req
*
restful
.
Request
)
string
{
reqURI
:=
""
...
...
@@ -49,13 +52,13 @@ func FormatRequestLog(req *restful.Request) string {
reqURI
,
req
.
Request
.
RemoteAddr
)
}
// Formats response log string.
// Format
ResponseLog format
s response log string.
// TODO(maciaszczykm): Display response content.
func
FormatResponseLog
(
resp
*
restful
.
Response
,
req
*
restful
.
Request
)
string
{
return
fmt
.
Sprintf
(
ResponseLogString
,
req
.
Request
.
RemoteAddr
,
resp
.
StatusCode
())
}
// Creates a new HTTP handler that handles all requests to the API of the backend.
// Create
HttpApiHandler create
s a new HTTP handler that handles all requests to the API of the backend.
func
CreateHttpApiHandler
(
client
*
client
.
Client
,
heapsterClient
HeapsterClient
,
clientConfig
clientcmd
.
ClientConfig
)
http
.
Handler
{
...
...
@@ -252,13 +255,13 @@ func (apiHandler *ApiHandler) handleNameValidity(request *restful.Request, respo
}
// Handles image reference validation API call.
func
(
ApiHandler
*
ApiHandler
)
handleImageReferenceValidity
(
request
*
restful
.
Request
,
response
*
restful
.
Response
){
func
(
ApiHandler
*
ApiHandler
)
handleImageReferenceValidity
(
request
*
restful
.
Request
,
response
*
restful
.
Response
)
{
spec
:=
new
(
ImageReferenceValiditySpec
)
if
err
:=
request
.
ReadEntity
(
spec
);
err
!=
nil
{
handleInternalError
(
response
,
err
)
return
}
validity
,
err
:=
ValidateImageReference
(
spec
)
if
err
!=
nil
{
handleInternalError
(
response
,
err
)
...
...
src/app/backend/apiserverclient.go
浏览文件 @
36ecc33c
...
...
@@ -29,7 +29,7 @@ import (
// apiserverHost param is in the format of protocol://address:port/pathPrefix, e.g.,
// http://localhost:8001.
//
//
R
eturns created client and its configuration.
//
CreateApiserverClient r
eturns created client and its configuration.
func
CreateApiserverClient
(
apiserverHost
string
)
(
*
client
.
Client
,
clientcmd
.
ClientConfig
,
error
)
{
overrides
:=
&
clientcmd
.
ConfigOverrides
{}
...
...
src/app/backend/events.go
浏览文件 @
36ecc33c
...
...
@@ -33,7 +33,7 @@ type Events struct {
Events
[]
Event
`json:"events"`
}
//
S
ingle event representation.
//
Event is a s
ingle event representation.
type
Event
struct
{
// A human-readable description of the status of related object.
Message
string
`json:"message"`
...
...
@@ -67,7 +67,7 @@ type Event struct {
Type
string
`json:"type"`
}
//
Return
events for particular namespace and replication controller or error if occurred.
//
GetEvents returns
events for particular namespace and replication controller or error if occurred.
func
GetEvents
(
client
*
client
.
Client
,
namespace
,
replicationControllerName
string
)
(
*
Events
,
error
)
{
log
.
Printf
(
"Getting events related to %s replication controller in %s namespace"
,
replicationControllerName
,
namespace
)
...
...
@@ -103,7 +103,7 @@ func GetEvents(client *client.Client, namespace, replicationControllerName strin
return
&
events
,
nil
}
// Gets events associated to replication controller.
// Get
ReplicationControllerEvents get
s events associated to replication controller.
func
GetReplicationControllerEvents
(
client
*
client
.
Client
,
namespace
,
replicationControllerName
string
)
([]
api
.
Event
,
error
)
{
fieldSelector
,
err
:=
fields
.
ParseSelector
(
"involvedObject.name="
+
replicationControllerName
)
...
...
@@ -124,7 +124,7 @@ func GetReplicationControllerEvents(client *client.Client, namespace, replicatio
return
list
.
Items
,
nil
}
// Gets events associated to pods in replication controller.
// Get
ReplicationControllerPodsEvents get
s events associated to pods in replication controller.
func
GetReplicationControllerPodsEvents
(
client
*
client
.
Client
,
namespace
,
replicationControllerName
string
)
([]
api
.
Event
,
error
)
{
replicationController
,
err
:=
client
.
ReplicationControllers
(
namespace
)
.
Get
(
replicationControllerName
)
...
...
@@ -151,7 +151,7 @@ func GetReplicationControllerPodsEvents(client *client.Client, namespace, replic
return
events
,
nil
}
// Gets events associated to given list of pods
// Get
PodsEvents get
s events associated to given list of pods
// TODO(floreks): refactor this to make single API call instead of N api calls
func
GetPodsEvents
(
client
*
client
.
Client
,
pods
*
api
.
PodList
)
([]
api
.
Event
,
error
)
{
events
:=
make
([]
api
.
Event
,
0
,
0
)
...
...
@@ -172,7 +172,7 @@ func GetPodsEvents(client *client.Client, pods *api.PodList) ([]api.Event, error
return
events
,
nil
}
// Gets events associated to given pod
// Get
PodEvents get
s events associated to given pod
func
GetPodEvents
(
client
client
.
Interface
,
pod
api
.
Pod
)
(
*
api
.
EventList
,
error
)
{
fieldSelector
,
err
:=
fields
.
ParseSelector
(
"involvedObject.name="
+
pod
.
Name
)
...
...
@@ -192,7 +192,7 @@ func GetPodEvents(client client.Interface, pod api.Pod) (*api.EventList, error)
return
list
,
nil
}
// Appends events from source slice to target events representation.
// Append
Events append
s events from source slice to target events representation.
func
AppendEvents
(
source
[]
api
.
Event
,
target
Events
)
Events
{
for
_
,
event
:=
range
source
{
target
.
Events
=
append
(
target
.
Events
,
Event
{
...
...
src/app/backend/eventscommon.go
浏览文件 @
36ecc33c
...
...
@@ -119,7 +119,7 @@ func isFailedReason(reason string, partials ...string) bool {
// Based on event Reason fills event Type in order to allow correct filtering by Type.
func
fillEventsType
(
events
[]
api
.
Event
)
[]
api
.
Event
{
for
i
,
_
:=
range
events
{
for
i
:=
range
events
{
if
isFailedReason
(
events
[
i
]
.
Reason
,
FailedReasonPartials
...
)
{
events
[
i
]
.
Type
=
api
.
EventTypeWarning
}
else
{
...
...
src/app/backend/heapsterclient.go
浏览文件 @
36ecc33c
...
...
@@ -60,13 +60,13 @@ func CreateHeapsterRESTClient(heapsterHost string, apiclient *client.Client) (
if
heapsterHost
==
""
{
log
.
Printf
(
"Creating in-cluster Heapster client"
)
return
InClusterHeapsterClient
{
client
:
apiclient
},
nil
}
else
{
cfg
:=
&
client
.
Config
{
Host
:
heapsterHost
}
restClient
,
err
:=
client
.
New
(
cfg
)
if
err
!=
nil
{
return
nil
,
err
}
log
.
Printf
(
"Creating remote Heapster client for %s"
,
heapsterHost
)
return
RemoteHeapsterClient
{
client
:
restClient
.
RESTClient
},
nil
}
cfg
:=
&
client
.
Config
{
Host
:
heapsterHost
}
restClient
,
err
:=
client
.
New
(
cfg
)
if
err
!=
nil
{
return
nil
,
err
}
log
.
Printf
(
"Creating remote Heapster client for %s"
,
heapsterHost
)
return
RemoteHeapsterClient
{
client
:
restClient
.
RESTClient
},
nil
}
src/app/backend/logs.go
浏览文件 @
36ecc33c
...
...
@@ -24,7 +24,7 @@ import (
client
"k8s.io/kubernetes/pkg/client/unversioned"
)
// Log
response structure
// Log
s is a representation of logs response structure.
type
Logs
struct
{
// Pod name.
PodId
string
`json:"podId"`
...
...
@@ -39,8 +39,8 @@ type Logs struct {
Container
string
`json:"container"`
}
//
Return logs for particular pod and container or error when occurred. When container is null,
// logs for the first one are returned.
//
GetPodLogs returns logs for particular pod and container or error when occurred. When container
//
is null,
logs for the first one are returned.
func
GetPodLogs
(
client
*
client
.
Client
,
namespace
,
podId
string
,
container
string
)
(
*
Logs
,
error
)
{
log
.
Printf
(
"Getting logs from %s container from %s pod in %s namespace"
,
container
,
podId
,
namespace
)
...
...
src/app/backend/namespaces.go
浏览文件 @
36ecc33c
...
...
@@ -23,19 +23,19 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
//
Specification of namespace to be created
.
//
NamespaceSpec is a specification of namespace to create
.
type
NamespaceSpec
struct
{
// Name of the namespace.
Name
string
`json:"name"`
}
//
List of N
amespaces in the cluster.
//
NamespaceList is a list of n
amespaces in the cluster.
type
NamespaceList
struct
{
// Unordered list of Namespaces.
Namespaces
[]
string
`json:"namespaces"`
}
// Creates namespace based on given specification.
// Create
Namespace create
s namespace based on given specification.
func
CreateNamespace
(
spec
*
NamespaceSpec
,
client
*
client
.
Client
)
error
{
log
.
Printf
(
"Creating namespace %s"
,
spec
.
Name
)
...
...
@@ -50,7 +50,7 @@ func CreateNamespace(spec *NamespaceSpec, client *client.Client) error {
return
err
}
//
R
eturns a list of all namespaces in the cluster.
//
GetNamespaceList r
eturns a list of all namespaces in the cluster.
func
GetNamespaceList
(
client
*
client
.
Client
)
(
*
NamespaceList
,
error
)
{
log
.
Printf
(
"Getting namespace list"
)
...
...
src/app/backend/replicationcontrollercommon.go
浏览文件 @
36ecc33c
...
...
@@ -22,6 +22,7 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
// ReplicationControllerWithPods is a structure representing replication controller and its pods.
type
ReplicationControllerWithPods
struct
{
ReplicationController
*
api
.
ReplicationController
Pods
*
api
.
PodList
...
...
src/app/backend/replicationcontrollerdetail.go
浏览文件 @
36ecc33c
...
...
@@ -55,7 +55,7 @@ type ReplicationControllerDetail struct {
HasMetrics
bool
`json:"hasMetrics"`
}
//
Detailed information about
a Pod that belongs to a Replication Controller.
//
ReplicationControllerPod is a representation of
a Pod that belongs to a Replication Controller.
type
ReplicationControllerPod
struct
{
// Name of the Pod.
Name
string
`json:"name"`
...
...
@@ -79,7 +79,7 @@ type ReplicationControllerPod struct {
Metrics
*
PodMetrics
`json:"metrics"`
}
//
Detailed information about
a Service connected to Replication Controller.
//
ServiceDetail is a representation of
a Service connected to Replication Controller.
type
ServiceDetail
struct
{
// Name of the service.
Name
string
`json:"name"`
...
...
@@ -98,7 +98,7 @@ type ServiceDetail struct {
Selector
map
[
string
]
string
`json:"selector"`
}
//
Port and protocol pair of, e.g.,
a service endpoint.
//
ServicePort is a pair of port and protocol, e.g.
a service endpoint.
type
ServicePort
struct
{
// Positive port number.
Port
int
`json:"port"`
...
...
@@ -107,7 +107,7 @@ type ServicePort struct {
Protocol
api
.
Protocol
`json:"protocol"`
}
//
D
escribes an endpoint that is host and a list of available ports for that host.
//
Endpoint d
escribes an endpoint that is host and a list of available ports for that host.
type
Endpoint
struct
{
// Hostname, either as a domain name or IP address.
Host
string
`json:"host"`
...
...
src/app/backend/replicationcontrollerlist.go
浏览文件 @
36ecc33c
...
...
@@ -24,10 +24,10 @@ import (
"k8s.io/kubernetes/pkg/labels"
)
//
Callback function in order to get the pod status errors
//
GetPodsEventWarningsFunc is a callback function used to get the pod status errors.
type
GetPodsEventWarningsFunc
func
(
pods
[]
api
.
Pod
)
([]
Event
,
error
)
//
Callback function in order to get node by name
.
//
GetNodeFunc is a callback function used to get nodes by names
.
type
GetNodeFunc
func
(
nodeName
string
)
(
*
api
.
Node
,
error
)
// ReplicationControllerList contains a list of Replication Controllers in the cluster.
...
...
src/app/backend/validateimagereference.go
浏览文件 @
36ecc33c
...
...
@@ -15,8 +15,8 @@
package
main
import
(
"log"
distreference
"github.com/docker/distribution/reference"
"log"
)
// Specification for image referecne validation request.
...
...
src/app/backend/validateprotocol.go
浏览文件 @
36ecc33c
...
...
@@ -20,7 +20,7 @@ import (
"k8s.io/kubernetes/pkg/api"
)
//
Specification for
protocol validation request.
//
ProtocolValiditySpec is a specification of
protocol validation request.
type
ProtocolValiditySpec
struct
{
// Protocol type
Protocol
api
.
Protocol
`json:"protocol"`
...
...
@@ -29,15 +29,17 @@ type ProtocolValiditySpec struct {
IsExternal
bool
`json:"isExternal"`
}
//
D
escribes validity of the protocol.
//
ProtocolValidity d
escribes validity of the protocol.
type
ProtocolValidity
struct
{
// True when the selected protocol is valid for selected service type.
Valid
bool
`json:"valid"`
}
// Validates protocol based on whether created service is set to NodePort or NodeBalancer type.
// ValidateProtocol validates protocol based on whether created service is set to NodePort or
// NodeBalancer type.
func
ValidateProtocol
(
spec
*
ProtocolValiditySpec
)
*
ProtocolValidity
{
log
.
Printf
(
"Validating %s protocol for service with external set to %v"
,
spec
.
Protocol
,
spec
.
IsExternal
)
log
.
Printf
(
"Validating %s protocol for service with external set to %v"
,
spec
.
Protocol
,
spec
.
IsExternal
)
isValid
:=
true
...
...
src/test/backend/deploy_test.go
浏览文件 @
36ecc33c
...
...
@@ -123,9 +123,9 @@ func TestDeployShouldPopulateEnvVars(t *testing.T) {
rc
:=
createAction
.
GetObject
()
.
(
*
api
.
ReplicationController
)
container
:=
rc
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
if
!
reflect
.
DeepEqual
(
container
.
Env
,
[]
api
.
EnvVar
{
api
.
EnvVar
{
Name
:
"foo"
,
Value
:
"bar"
}})
{
if
!
reflect
.
DeepEqual
(
container
.
Env
,
[]
api
.
EnvVar
{{
Name
:
"foo"
,
Value
:
"bar"
}})
{
t
.
Errorf
(
"Expected environment variables to be %#v but got %#v"
,
[]
api
.
EnvVar
{
api
.
EnvVar
{
Name
:
"foo"
,
Value
:
"bar"
}},
container
.
Env
)
[]
api
.
EnvVar
{{
Name
:
"foo"
,
Value
:
"bar"
}},
container
.
Env
)
}
}
...
...
src/test/backend/replicationcontrollerdetail_test.go
浏览文件 @
36ecc33c
...
...
@@ -518,7 +518,7 @@ func TestGetLocalhostEndpoints(t *testing.T) {
Host
:
"localhost"
,
Ports
:
[]
ServicePort
{
{
Port
:
30100
,
Port
:
30100
,
Protocol
:
"TCP"
,
},
},
...
...
@@ -527,7 +527,7 @@ func TestGetLocalhostEndpoints(t *testing.T) {
Host
:
"localhost"
,
Ports
:
[]
ServicePort
{
{
Port
:
30101
,
Port
:
30101
,
Protocol
:
"TCP"
,
},
},
...
...
src/test/backend/validateimagereference_test.go
浏览文件 @
36ecc33c
...
...
@@ -20,8 +20,8 @@ import (
func
TestValidateImageReference
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
reference
string
expected
bool
reference
string
expected
bool
}{
{
"test"
,
...
...
@@ -86,7 +86,7 @@ func TestValidateImageReference(t *testing.T) {
{
"test image:1"
,
false
,
},
},
}
for
_
,
c
:=
range
cases
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录