-
Notifications
You must be signed in to change notification settings - Fork 24
/
search.go
41 lines (32 loc) · 843 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package images
import (
"strconv"
"github.com/containers/podman-tui/pdcs/registry"
"github.com/containers/podman/v5/pkg/bindings/images"
"github.com/rs/zerolog/log"
)
// Search search repostiroy for images matche the search term.
func Search(term string) ([][]string, error) {
log.Debug().Msgf("pdcs: podman image search %s", term)
report := make([][]string, 0)
conn, err := registry.GetConnection()
if err != nil {
return report, err
}
response, err := images.Search(conn, term, new(images.SearchOptions))
if err != nil {
return report, err
}
for _, sReport := range response {
report = append(report, []string{
sReport.Index,
sReport.Name,
sReport.Description,
strconv.Itoa(sReport.Stars),
sReport.Official,
sReport.Automated,
})
}
log.Debug().Msgf("pdcs: %s", report)
return report, nil
}