mirror of
https://github.com/mudler/luet.git
synced 2025-09-04 16:50:50 +00:00
Repository now support Revision and LastUpdate
This commit is contained in:
@@ -56,7 +56,14 @@ type LuetRepository struct {
|
|||||||
Priority int `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority"`
|
Priority int `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority"`
|
||||||
Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"`
|
Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"`
|
||||||
Authentication map[string]string `json:"auth,omitempty" yaml:"auth,omitempty" mapstructure:"auth,omitempty"`
|
Authentication map[string]string `json:"auth,omitempty" yaml:"auth,omitempty" mapstructure:"auth,omitempty"`
|
||||||
TreePath string `json:"tree_path,omitempty" yaml::"tree_path,omitempty" mapstructure:"tree_path"`
|
TreePath string `json:"tree_path,omitempty" yaml:"tree_path,omitempty" mapstructure:"tree_path"`
|
||||||
|
|
||||||
|
// Serialized options not used in repository configuration
|
||||||
|
|
||||||
|
// Incremented value that identify revision of the repository in a user-friendly way.
|
||||||
|
Revision int `json:"revision,omitempty" yaml:"-,omitempty" mapstructure:"-,omitempty"`
|
||||||
|
// Epoch time in seconds
|
||||||
|
LastUpdate string `json:"last_update,omitempty" yaml:"-,omitempty" mapstructure:"-,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLuetRepository(name, t, descr string, urls []string, priority int, enable bool) *LuetRepository {
|
func NewLuetRepository(name, t, descr string, urls []string, priority int, enable bool) *LuetRepository {
|
||||||
|
@@ -21,7 +21,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/mudler/luet/pkg/installer/client"
|
"github.com/mudler/luet/pkg/installer/client"
|
||||||
|
|
||||||
@@ -49,6 +51,8 @@ type LuetSystemRepositorySerialized struct {
|
|||||||
Priority int `json:"priority"`
|
Priority int `json:"priority"`
|
||||||
Index []*compiler.PackageArtifact `json:"index"`
|
Index []*compiler.PackageArtifact `json:"index"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
|
Revision int `json:"revision,omitempty"`
|
||||||
|
LastUpdate string `json:"last_update,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateRepository(name, descr, t string, urls []string, priority int, src, treeDir string, db pkg.PackageDatabase) (Repository, error) {
|
func GenerateRepository(name, descr, t string, urls []string, priority int, src, treeDir string, db pkg.PackageDatabase) (Repository, error) {
|
||||||
@@ -98,6 +102,12 @@ func NewLuetSystemRepositoryFromYaml(data []byte, db pkg.PackageDatabase) (Repos
|
|||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
if p.Revision > 0 {
|
||||||
|
r.Revision = p.Revision
|
||||||
|
}
|
||||||
|
if p.LastUpdate != "" {
|
||||||
|
r.LastUpdate = p.LastUpdate
|
||||||
|
}
|
||||||
i := compiler.ArtifactIndex{}
|
i := compiler.ArtifactIndex{}
|
||||||
for _, ii := range p.Index {
|
for _, ii := range p.Index {
|
||||||
i = append(i, ii)
|
i = append(i, ii)
|
||||||
@@ -185,6 +195,8 @@ func (r *LuetSystemRepository) Write(dst string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
r.Index = r.Index.CleanPath()
|
r.Index = r.Index.CleanPath()
|
||||||
|
r.LastUpdate = strconv.FormatInt(time.Now().Unix(), 10)
|
||||||
|
r.Revision++
|
||||||
|
|
||||||
data, err := yaml.Marshal(r)
|
data, err := yaml.Marshal(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user