From abb85da372017e86faebd7f33f376c712fe39f89 Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:54:20 +0200 Subject: [PATCH 1/2] fix(image): only use numerical IDs for label auto-completion --- internal/hcapi2/image.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/hcapi2/image.go b/internal/hcapi2/image.go index b668e870..13270d74 100644 --- a/internal/hcapi2/image.go +++ b/internal/hcapi2/image.go @@ -43,11 +43,15 @@ func (c *imageClient) Names() []string { return names } -// ImageLabelKeys returns a slice containing the keys of all labels assigned to -// the Image with the passed idOrName. -func (c *imageClient) LabelKeys(idOrName string) []string { - img, _, err := c.Get(context.Background(), idOrName) - if err != nil || img == nil || len(img.Labels) == 0 { +// LabelKeys returns a slice containing the keys of all labels assigned to +// the Image with the passed id. +func (c *imageClient) LabelKeys(id string) []string { + imgID, err := strconv.ParseInt(id, 10, 64) + if err != nil { + return nil + } + img, _, err := c.GetByID(context.Background(), imgID) + if err != nil || len(img.Labels) == 0 { return nil } return labelKeys(img.Labels) From a138da517b3c8dbdc82e2de15ddbc88dc3f8c093 Mon Sep 17 00:00:00 2001 From: phm07 <22707808+phm07@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:04:49 +0200 Subject: [PATCH 2/2] image might not exist --- internal/hcapi2/image.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/hcapi2/image.go b/internal/hcapi2/image.go index 13270d74..a151768c 100644 --- a/internal/hcapi2/image.go +++ b/internal/hcapi2/image.go @@ -51,7 +51,7 @@ func (c *imageClient) LabelKeys(id string) []string { return nil } img, _, err := c.GetByID(context.Background(), imgID) - if err != nil || len(img.Labels) == 0 { + if err != nil || img == nil || len(img.Labels) == 0 { return nil } return labelKeys(img.Labels)