mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
【修改】k8s 配置
This commit is contained in:
40
apps/devops/services/k8s/configmap/configmap_common.go
Normal file
40
apps/devops/services/k8s/configmap/configmap_common.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package configmap
|
||||
|
||||
import (
|
||||
api "k8s.io/api/core/v1"
|
||||
"pandax/apps/devops/services/k8s/dataselect"
|
||||
)
|
||||
|
||||
// The code below allows to perform complex data section on []api.ConfigMap
|
||||
|
||||
type ConfigMapCell api.ConfigMap
|
||||
|
||||
func (self ConfigMapCell) GetProperty(name dataselect.PropertyName) dataselect.ComparableValue {
|
||||
switch name {
|
||||
case dataselect.NameProperty:
|
||||
return dataselect.StdComparableString(self.ObjectMeta.Name)
|
||||
case dataselect.CreationTimestampProperty:
|
||||
return dataselect.StdComparableTime(self.ObjectMeta.CreationTimestamp.Time)
|
||||
case dataselect.NamespaceProperty:
|
||||
return dataselect.StdComparableString(self.ObjectMeta.Namespace)
|
||||
default:
|
||||
// if name is not supported then just return a constant dummy value, sort will have no effect.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func toCells(std []api.ConfigMap) []dataselect.DataCell {
|
||||
cells := make([]dataselect.DataCell, len(std))
|
||||
for i := range std {
|
||||
cells[i] = ConfigMapCell(std[i])
|
||||
}
|
||||
return cells
|
||||
}
|
||||
|
||||
func fromCells(cells []dataselect.DataCell) []api.ConfigMap {
|
||||
std := make([]api.ConfigMap, len(cells))
|
||||
for i := range std {
|
||||
std[i] = api.ConfigMap(cells[i].(ConfigMapCell))
|
||||
}
|
||||
return std
|
||||
}
|
||||
Reference in New Issue
Block a user