Skip to content

Commit

Permalink
fix(image): only use numerical IDs for label auto-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
phm07 committed Sep 6, 2024
1 parent 311642e commit abb85da
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/hcapi2/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit abb85da

Please sign in to comment.