Add server side container label filtering
Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
parent
50cc7ce940
commit
d2cae34243
1 changed files with 8 additions and 1 deletions
|
@ -15,6 +15,7 @@ import (
|
|||
"github.com/opencontainers/runc/libcontainer/label"
|
||||
"github.com/opencontainers/runtime-tools/generate"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
)
|
||||
|
||||
|
@ -419,7 +420,12 @@ func filterContainer(c *pb.Container, filter *pb.ContainerFilter) bool {
|
|||
return false
|
||||
}
|
||||
}
|
||||
// TODO(mrunalp): Add support for label filtering
|
||||
if filter.LabelSelector != nil {
|
||||
sel := fields.SelectorFromSet(filter.LabelSelector)
|
||||
if !sel.Matches(fields.Set(c.Labels)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -473,6 +479,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
|||
Id: &cID,
|
||||
PodSandboxId: &podSandboxID,
|
||||
CreatedAt: int64Ptr(created),
|
||||
Labels: ctr.Labels(),
|
||||
}
|
||||
|
||||
switch cState.Status {
|
||||
|
|
Loading…
Reference in a new issue