Skip adding function if GetFunction returns error

When ListFunctions populate it's function map, it should not add
functions that GetFunction returned error.

Signed-off-by: Carlos de Paula <me@carlosedp.com>
This commit is contained in:
Carlos de Paula 2020-03-06 20:44:35 -03:00 committed by Alex Ellis
parent 9dcdbfb7e3
commit 667d74aaf7

View File

@ -33,7 +33,11 @@ func ListFunctions(client *containerd.Client) (map[string]Function, error) {
containers, _ := client.Containers(ctx)
for _, k := range containers {
name := k.ID()
functions[name], _ = GetFunction(client, name)
f, err := GetFunction(client, name)
if err != nil {
continue
}
functions[name] = f
}
return functions, nil
}
@ -44,7 +48,6 @@ func GetFunction(client *containerd.Client, name string) (Function, error) {
c, err := client.LoadContainer(ctx, name)
if err == nil {
image, _ := c.Image(ctx)
containerName := c.ID()