up
This commit is contained in:
parent
8173e1ba42
commit
4a265ca4af
|
@ -10,11 +10,17 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
"github.com/Masterminds/semver/v3"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"slices"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type localItem struct {
|
||||||
|
Name string `yaml:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
func isYAMLFileName(path string) bool {
|
func isYAMLFileName(path string) bool {
|
||||||
return strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")
|
return strings.HasSuffix(path, ".yaml") || strings.HasSuffix(path, ".yml")
|
||||||
}
|
}
|
||||||
|
@ -214,9 +220,22 @@ func (h *Hub) itemVisit(path string, f os.DirEntry, err error) error {
|
||||||
|
|
||||||
_, fileName := filepath.Split(path)
|
_, fileName := filepath.Split(path)
|
||||||
|
|
||||||
|
item := localItem{}
|
||||||
|
itemContent, err := os.ReadFile(path)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to read %s: %w", path, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = yaml.Unmarshal(itemContent, &item)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to unmarshal %s: %w", path, err)
|
||||||
|
}
|
||||||
|
|
||||||
h.Items[info.ftype][info.fname] = &Item{
|
h.Items[info.ftype][info.fname] = &Item{
|
||||||
hub: h,
|
hub: h,
|
||||||
Name: info.fname,
|
Name: item.Name,
|
||||||
Stage: info.stage,
|
Stage: info.stage,
|
||||||
Installed: true,
|
Installed: true,
|
||||||
Type: info.ftype,
|
Type: info.ftype,
|
||||||
|
|
Loading…
Reference in a new issue