kubelet: Move pod name helpers to pkg/kubelet/container/runtime.go

This commit is contained in:
Yifan Gu
2015-03-23 10:14:30 -07:00
parent 13250c904f
commit 31bb11ac2a
13 changed files with 99 additions and 100 deletions

View File

@@ -16,12 +16,7 @@ limitations under the License.
package kubelet
import (
"fmt"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
)
import "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
const ConfigSourceAnnotationKey = "kubernetes.io/config.source"
const ConfigMirrorAnnotationKey = "kubernetes.io/config.mirror"
@@ -71,24 +66,3 @@ type PodUpdate struct {
Op PodOperation
Source string
}
// GetPodFullName returns a name that uniquely identifies a pod.
func GetPodFullName(pod *api.Pod) string {
// Use underscore as the delimiter because it is not allowed in pod name
// (DNS subdomain format), while allowed in the container name format.
return fmt.Sprintf("%s_%s", pod.Name, pod.Namespace)
}
// Build the pod full name from pod name and namespace.
func BuildPodFullName(name, namespace string) string {
return name + "_" + namespace
}
// Parse the pod full name.
func ParsePodFullName(podFullName string) (string, string, error) {
parts := strings.Split(podFullName, "_")
if len(parts) != 2 {
return "", "", fmt.Errorf("failed to parse the pod full name %q", podFullName)
}
return parts[0], parts[1], nil
}