Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Kt Connect
Commits
c827ca71
Commit
c827ca71
authored
5 years ago
by
yunlzheng
Browse files
Options
Download
Email Patches
Plain Diff
add .pre-commit-commit.yaml
parent
f4427203
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.pre-commit-config.yaml
+6
-0
.pre-commit-config.yaml
docs/developer/pre-commit.md
+20
-0
docs/developer/pre-commit.md
pkg/apiserver/controllers/cluster.go
+13
-1
pkg/apiserver/controllers/cluster.go
with
39 additions
and
1 deletion
+39
-1
.pre-commit-config.yaml
0 → 100644
+
6
-
0
View file @
c827ca71
-
repo
:
git://github.com/dnephin/pre-commit-golang
rev
:
master
hooks
:
-
id
:
go-fmt
-
id
:
go-lint
-
id
:
go-imports
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/developer/pre-commit.md
0 → 100644
+
20
-
0
View file @
c827ca71
Pre Commit
---
> https://pre-commit.com/
## Install
Install pre-commit:
```
pip install pre-commit
# or
brew install pre-commit
```
Apply to local
```
pre-commit install
```
This diff is collapsed.
Click to expand it.
pkg/apiserver/controllers/cluster.go
+
13
-
1
View file @
c827ca71
...
...
@@ -13,10 +13,12 @@ import (
"k8s.io/apimachinery/pkg/labels"
)
// ClusterController provide kubernetes cluster api
type
ClusterController
struct
{
Context
common
.
Context
}
// Namespaces list namespaces
func
(
c
*
ClusterController
)
Namespaces
(
context
*
gin
.
Context
)
{
namespaces
,
err
:=
c
.
Context
.
NamespaceLister
()
.
List
(
labels
.
Everything
())
if
err
!=
nil
{
...
...
@@ -28,6 +30,7 @@ func (c *ClusterController) Namespaces(context *gin.Context) {
context
.
JSON
(
200
,
namespaces
)
}
// Services list services
func
(
c
*
ClusterController
)
Services
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
services
,
err
:=
c
.
Context
.
ServiceLister
()
.
Services
(
namespace
)
.
List
(
labels
.
Everything
())
...
...
@@ -40,19 +43,21 @@ func (c *ClusterController) Services(context *gin.Context) {
context
.
JSON
(
200
,
services
)
}
// Service get service instance
func
(
c
*
ClusterController
)
Service
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
name
:=
context
.
Param
(
"name"
)
service
,
err
:=
c
.
Context
.
Client
()
.
CoreV1
()
.
Services
(
namespace
)
.
Get
(
name
,
metav1
.
GetOptions
{})
if
err
!=
nil
{
context
.
JSON
(
500
,
gin
.
H
{
"message"
:
"fail get service
"
,
"message"
:
"fail get service
"
+
name
,
})
return
}
context
.
JSON
(
200
,
service
)
}
// Endpoints list endpoints
func
(
c
*
ClusterController
)
Endpoints
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
endpoints
,
err
:=
c
.
Context
.
EndpointsLister
()
.
Endpoints
(
namespace
)
.
List
(
labels
.
Everything
())
...
...
@@ -65,6 +70,7 @@ func (c *ClusterController) Endpoints(context *gin.Context) {
context
.
JSON
(
200
,
endpoints
)
}
// Endpoint get endpoint instance
func
(
c
*
ClusterController
)
Endpoint
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
name
:=
context
.
Param
(
"name"
)
...
...
@@ -78,6 +84,7 @@ func (c *ClusterController) Endpoint(context *gin.Context) {
context
.
JSON
(
200
,
endpoint
)
}
// Deployments list deployments
func
(
c
*
ClusterController
)
Deployments
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
selector
:=
context
.
Query
(
"selector"
)
...
...
@@ -106,6 +113,7 @@ func (c *ClusterController) Deployments(context *gin.Context) {
context
.
JSON
(
200
,
resource
)
}
// Deployment get deployment instance
func
(
c
*
ClusterController
)
Deployment
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
name
:=
context
.
Param
(
"name"
)
...
...
@@ -119,6 +127,7 @@ func (c *ClusterController) Deployment(context *gin.Context) {
context
.
JSON
(
200
,
resource
)
}
// ReplicaSet get replicaSet instance
func
(
c
*
ClusterController
)
ReplicaSet
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
name
:=
context
.
Param
(
"name"
)
...
...
@@ -132,6 +141,7 @@ func (c *ClusterController) ReplicaSet(context *gin.Context) {
context
.
JSON
(
200
,
resource
)
}
// Pods list pods
func
(
c
*
ClusterController
)
Pods
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
selector
:=
context
.
Query
(
"selector"
)
...
...
@@ -156,6 +166,7 @@ func (c *ClusterController) Pods(context *gin.Context) {
context
.
JSON
(
200
,
pods
)
}
// Pod get pod instance
func
(
c
*
ClusterController
)
Pod
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
name
:=
context
.
Param
(
"name"
)
...
...
@@ -170,6 +181,7 @@ func (c *ClusterController) Pod(context *gin.Context) {
context
.
JSON
(
200
,
pod
)
}
// PodLog get pod log
func
(
c
*
ClusterController
)
PodLog
(
context
*
gin
.
Context
)
{
namespace
:=
context
.
Param
(
"namespace"
)
podID
:=
context
.
Param
(
"name"
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help