Use unified type for the namespaced object names

This commit is contained in:
Murat Kabilov
2017-05-12 11:41:34 +02:00
parent 79fdba4ac7
commit 08c0e3b6dd
10 changed files with 69 additions and 85 deletions
+5 -8
View File
@@ -11,7 +11,6 @@ import (
"github.bus.zalan.do/acid/postgres-operator/pkg/spec"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/pkg/types"
"strings"
)
@@ -30,24 +29,22 @@ func RandomPassword(n int) string {
return string(b)
}
func NameFromMeta(meta v1.ObjectMeta) types.NamespacedName {
obj := types.NamespacedName{
func NameFromMeta(meta v1.ObjectMeta) spec.NamespacedName {
return spec.NamespacedName{
Namespace: meta.Namespace,
Name: meta.Name,
}
return obj
}
func PodClusterName(pod *v1.Pod) spec.ClusterName {
func PodClusterName(pod *v1.Pod) spec.NamespacedName {
if name, ok := pod.Labels["spilo-cluster"]; ok {
return spec.ClusterName{
return spec.NamespacedName{
Namespace: pod.Namespace,
Name: name,
}
}
return spec.ClusterName{}
return spec.NamespacedName{}
}
func PodSpiloRole(pod *v1.Pod) string {