From 333a6b4496b35f6710ed7638b1e2e9e3296a605a Mon Sep 17 00:00:00 2001
From: Lantao Liu <lantaol@google.com>
Date: Thu, 8 Nov 2018 18:21:28 -0800
Subject: [PATCH] Use metadata to filter instead of using labels.

Signed-off-by: Lantao Liu <lantaol@google.com>
---
 cmd/crictl/container.go | 2 +-
 cmd/crictl/sandbox.go   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/crictl/container.go b/cmd/crictl/container.go
index 9d3fdde5fc..44d3f049b1 100644
--- a/cmd/crictl/container.go
+++ b/cmd/crictl/container.go
@@ -624,7 +624,7 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
 	}
 	for _, c := range r.Containers {
 		// Filter by pod name/namespace regular expressions.
-		if !matchesRegex(opts.nameRegexp, c.Labels[kubeContainerNameLabel]) {
+		if !matchesRegex(opts.nameRegexp, c.Metadata.Name) {
 			continue
 		}
 		if opts.quiet {
diff --git a/cmd/crictl/sandbox.go b/cmd/crictl/sandbox.go
index e79396a657..209240d56a 100644
--- a/cmd/crictl/sandbox.go
+++ b/cmd/crictl/sandbox.go
@@ -434,10 +434,10 @@ func ListPodSandboxes(client pb.RuntimeServiceClient, opts listOptions) error {
 	}
 	for _, pod := range r.Items {
 		// Filter by pod name/namespace regular expressions.
-		if !matchesRegex(opts.nameRegexp, pod.Labels[kubePodNameLabel]) {
+		if !matchesRegex(opts.nameRegexp, pod.Metadata.Name) {
 			continue
 		}
-		if !matchesRegex(opts.podNamespaceRegexp, pod.Labels[kubePodNamespaceLabel]) {
+		if !matchesRegex(opts.podNamespaceRegexp, pod.Metadata.Namespace) {
 			continue
 		}