Merge pull request #115 from richardxz/master
don't return default value when varible is null, and change service type as k8s display
This commit is contained in:
@@ -43,8 +43,6 @@ func (ctl *DaemonsetCtl) generateObject(item v1.DaemonSet) *Daemonset {
|
|||||||
|
|
||||||
if len(release) > 0 && len(chart) > 0 {
|
if len(release) > 0 && len(chart) > 0 {
|
||||||
app = release + "/" + chart
|
app = release + "/" + chart
|
||||||
} else {
|
|
||||||
app = "-"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if createTime.IsZero() {
|
if createTime.IsZero() {
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ func (ctl *DeploymentCtl) generateObject(item v1.Deployment) *Deployment {
|
|||||||
|
|
||||||
if len(release) > 0 && len(chart) > 0 {
|
if len(release) > 0 && len(chart) > 0 {
|
||||||
app = release + "/" + chart
|
app = release + "/" + chart
|
||||||
} else {
|
|
||||||
app = "-"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, conditon := range item.Status.Conditions {
|
for _, conditon := range item.Status.Conditions {
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ import (
|
|||||||
func (ctl *IngressCtl) generateObject(item v1beta1.Ingress) *Ingress {
|
func (ctl *IngressCtl) generateObject(item v1beta1.Ingress) *Ingress {
|
||||||
name := item.Name
|
name := item.Name
|
||||||
namespace := item.Namespace
|
namespace := item.Namespace
|
||||||
ip := "-"
|
var ip, tls string
|
||||||
tls := "-"
|
|
||||||
createTime := item.CreationTimestamp.Time
|
createTime := item.CreationTimestamp.Time
|
||||||
if createTime.IsZero() {
|
if createTime.IsZero() {
|
||||||
createTime = time.Now()
|
createTime = time.Now()
|
||||||
|
|||||||
@@ -75,6 +75,9 @@ func (ctl *PodCtl) delAnnotationFromPvc(item v1.Pod) {
|
|||||||
if pvc != nil {
|
if pvc != nil {
|
||||||
name := pvc.ClaimName
|
name := pvc.ClaimName
|
||||||
Pvc, _ := ctl.K8sClient.CoreV1().PersistentVolumeClaims(item.Namespace).Get(name, metaV1.GetOptions{})
|
Pvc, _ := ctl.K8sClient.CoreV1().PersistentVolumeClaims(item.Namespace).Get(name, metaV1.GetOptions{})
|
||||||
|
if Pvc.Annotations == nil {
|
||||||
|
Pvc.Annotations = make(map[string]string)
|
||||||
|
}
|
||||||
annotation := Pvc.Annotations
|
annotation := Pvc.Annotations
|
||||||
var pods []string
|
var pods []string
|
||||||
json.Unmarshal([]byte(annotation[inUse]), pods)
|
json.Unmarshal([]byte(annotation[inUse]), pods)
|
||||||
|
|||||||
@@ -29,14 +29,12 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
const creator = "creator"
|
|
||||||
|
|
||||||
func (ctl *PvcCtl) generateObject(item *v1.PersistentVolumeClaim) *Pvc {
|
func (ctl *PvcCtl) generateObject(item *v1.PersistentVolumeClaim) *Pvc {
|
||||||
name := item.Name
|
name := item.Name
|
||||||
namespace := item.Namespace
|
namespace := item.Namespace
|
||||||
status := fmt.Sprintf("%s", item.Status.Phase)
|
status := fmt.Sprintf("%s", item.Status.Phase)
|
||||||
createTime := item.CreationTimestamp.Time
|
createTime := item.CreationTimestamp.Time
|
||||||
capacity := "-"
|
var capacity, storageClass, accessModeStr string
|
||||||
|
|
||||||
if createTime.IsZero() {
|
if createTime.IsZero() {
|
||||||
createTime = time.Now()
|
createTime = time.Now()
|
||||||
@@ -46,7 +44,6 @@ func (ctl *PvcCtl) generateObject(item *v1.PersistentVolumeClaim) *Pvc {
|
|||||||
capacity = storage.String()
|
capacity = storage.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
storageClass := "-"
|
|
||||||
if len(item.Annotations["volume.beta.kubernetes.io/storage-class"]) > 0 {
|
if len(item.Annotations["volume.beta.kubernetes.io/storage-class"]) > 0 {
|
||||||
storageClass = item.Annotations["volume.beta.kubernetes.io/storage-class"]
|
storageClass = item.Annotations["volume.beta.kubernetes.io/storage-class"]
|
||||||
}
|
}
|
||||||
@@ -54,8 +51,6 @@ func (ctl *PvcCtl) generateObject(item *v1.PersistentVolumeClaim) *Pvc {
|
|||||||
storageClass = *item.Spec.StorageClassName
|
storageClass = *item.Spec.StorageClassName
|
||||||
}
|
}
|
||||||
|
|
||||||
accessModeStr := "-"
|
|
||||||
|
|
||||||
var accessModeList []string
|
var accessModeList []string
|
||||||
for _, accessMode := range item.Status.AccessModes {
|
for _, accessMode := range item.Status.AccessModes {
|
||||||
accessModeList = append(accessModeList, string(accessMode))
|
accessModeList = append(accessModeList, string(accessMode))
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 The KubeSphere Authors.
|
Copyright 2018 The KubeSphere Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -31,12 +28,6 @@ import (
|
|||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
headlessSelector = "Headless(Selector)"
|
|
||||||
headlessExternal = "Headless(ExternalName)"
|
|
||||||
virtualIp = "Virtual IP"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (ctl *ServiceCtl) loadBalancerStatusStringer(item v1.Service) string {
|
func (ctl *ServiceCtl) loadBalancerStatusStringer(item v1.Service) string {
|
||||||
ingress := item.Status.LoadBalancer.Ingress
|
ingress := item.Status.LoadBalancer.Ingress
|
||||||
result := sets.NewString()
|
result := sets.NewString()
|
||||||
@@ -85,7 +76,7 @@ func (ctl *ServiceCtl) generateObject(item v1.Service) *Service {
|
|||||||
namespace := item.Namespace
|
namespace := item.Namespace
|
||||||
createTime := item.CreationTimestamp.Time
|
createTime := item.CreationTimestamp.Time
|
||||||
externalIp := ctl.getExternalIp(item)
|
externalIp := ctl.getExternalIp(item)
|
||||||
serviceType := virtualIp
|
serviceType := item.Spec.Type
|
||||||
vip := item.Spec.ClusterIP
|
vip := item.Spec.ClusterIP
|
||||||
ports := ""
|
ports := ""
|
||||||
var nodePorts []string
|
var nodePorts []string
|
||||||
@@ -94,14 +85,6 @@ func (ctl *ServiceCtl) generateObject(item v1.Service) *Service {
|
|||||||
createTime = time.Now()
|
createTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Spec.ClusterIP == "None" {
|
|
||||||
serviceType = headlessSelector
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(item.Spec.ExternalName) > 0 {
|
|
||||||
serviceType = headlessExternal
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(item.Spec.ExternalIPs) > 0 {
|
if len(item.Spec.ExternalIPs) > 0 {
|
||||||
externalIp = strings.Join(item.Spec.ExternalIPs, ",")
|
externalIp = strings.Join(item.Spec.ExternalIPs, ",")
|
||||||
}
|
}
|
||||||
@@ -126,7 +109,7 @@ func (ctl *ServiceCtl) generateObject(item v1.Service) *Service {
|
|||||||
object := &Service{
|
object := &Service{
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
Name: name,
|
Name: name,
|
||||||
ServiceType: serviceType,
|
ServiceType: string(serviceType),
|
||||||
ExternalIp: externalIp,
|
ExternalIp: externalIp,
|
||||||
VirtualIp: vip,
|
VirtualIp: vip,
|
||||||
CreateTime: createTime,
|
CreateTime: createTime,
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ func (ctl *StatefulsetCtl) generateObject(item v1.StatefulSet) *Statefulset {
|
|||||||
|
|
||||||
if len(release) > 0 && len(chart) > 0 {
|
if len(release) > 0 && len(chart) > 0 {
|
||||||
app = release + "/" + chart
|
app = release + "/" + chart
|
||||||
} else {
|
|
||||||
app = "-"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if item.Annotations["state"] == "stop" {
|
if item.Annotations["state"] == "stop" {
|
||||||
|
|||||||
Reference in New Issue
Block a user