mirror of
https://github.com/mudler/luet.git
synced 2025-06-26 23:39:55 +00:00
Use filename instead of name on repo specs
This commit is contained in:
parent
dd91a61caf
commit
454e9d934e
@ -40,9 +40,9 @@ var createrepoCmd = &cobra.Command{
|
||||
viper.BindPFlag("urls", cmd.Flags().Lookup("urls"))
|
||||
viper.BindPFlag("type", cmd.Flags().Lookup("type"))
|
||||
viper.BindPFlag("tree-compression", cmd.Flags().Lookup("tree-compression"))
|
||||
viper.BindPFlag("tree-name", cmd.Flags().Lookup("tree-name"))
|
||||
viper.BindPFlag("tree-filename", cmd.Flags().Lookup("tree-filename"))
|
||||
viper.BindPFlag("meta-compression", cmd.Flags().Lookup("meta-compression"))
|
||||
viper.BindPFlag("meta-name", cmd.Flags().Lookup("meta-name"))
|
||||
viper.BindPFlag("meta-filename", cmd.Flags().Lookup("meta-filename"))
|
||||
viper.BindPFlag("reset-revision", cmd.Flags().Lookup("reset-revision"))
|
||||
viper.BindPFlag("repo", cmd.Flags().Lookup("repo"))
|
||||
},
|
||||
@ -59,9 +59,9 @@ var createrepoCmd = &cobra.Command{
|
||||
t := viper.GetString("type")
|
||||
reset := viper.GetBool("reset-revision")
|
||||
treetype := viper.GetString("tree-compression")
|
||||
treeName := viper.GetString("tree-name")
|
||||
treeName := viper.GetString("tree-filename")
|
||||
metatype := viper.GetString("meta-compression")
|
||||
metaName := viper.GetString("meta-name")
|
||||
metaName := viper.GetString("meta-filename")
|
||||
source_repo := viper.GetString("repo")
|
||||
|
||||
treeFile := installer.NewDefaultTreeRepositoryFile()
|
||||
@ -104,7 +104,7 @@ var createrepoCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
if treeName != "" {
|
||||
treeFile.SetName(treeName)
|
||||
treeFile.SetFileName(treeName)
|
||||
}
|
||||
|
||||
if metatype != "" {
|
||||
@ -112,7 +112,7 @@ var createrepoCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
if metaName != "" {
|
||||
metaFile.SetName(metaName)
|
||||
metaFile.SetFileName(metaName)
|
||||
}
|
||||
|
||||
repo.SetRepositoryFile(installer.REPOFILE_TREE_KEY, treeFile)
|
||||
@ -141,9 +141,9 @@ func init() {
|
||||
createrepoCmd.Flags().String("repo", "", "Use repository defined in configuration.")
|
||||
|
||||
createrepoCmd.Flags().String("tree-compression", "none", "Compression alg: none, gzip")
|
||||
createrepoCmd.Flags().String("tree-name", installer.TREE_TARBALL, "Repository tree filename")
|
||||
createrepoCmd.Flags().String("tree-filename", installer.TREE_TARBALL, "Repository tree filename")
|
||||
createrepoCmd.Flags().String("meta-compression", "none", "Compression alg: none, gzip")
|
||||
createrepoCmd.Flags().String("meta-name", installer.REPOSITORY_METAFILE+".tar", "Repository metadata filename")
|
||||
createrepoCmd.Flags().String("meta-filename", installer.REPOSITORY_METAFILE+".tar", "Repository metadata filename")
|
||||
|
||||
RootCmd.AddCommand(createrepoCmd)
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ const (
|
||||
)
|
||||
|
||||
type LuetRepositoryFile struct {
|
||||
Name string `json:"name"`
|
||||
FileName string `json:"filename"`
|
||||
CompressionType compiler.CompressionImplementation `json:"compressiontype,omitempty"`
|
||||
Checksums compiler.Checksums `json:"checksums,omitempty"`
|
||||
}
|
||||
@ -145,23 +145,23 @@ func (m *LuetSystemRepositoryMetadata) ToArtificatIndex() (ans compiler.Artifact
|
||||
|
||||
func NewDefaultTreeRepositoryFile() LuetRepositoryFile {
|
||||
return LuetRepositoryFile{
|
||||
Name: TREE_TARBALL,
|
||||
FileName: TREE_TARBALL,
|
||||
CompressionType: compiler.GZip,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefaultMetaRepositoryFile() LuetRepositoryFile {
|
||||
return LuetRepositoryFile{
|
||||
Name: REPOSITORY_METAFILE + ".tar",
|
||||
FileName: REPOSITORY_METAFILE + ".tar",
|
||||
CompressionType: compiler.None,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *LuetRepositoryFile) SetName(n string) {
|
||||
f.Name = n
|
||||
func (f *LuetRepositoryFile) SetFileName(n string) {
|
||||
f.FileName = n
|
||||
}
|
||||
func (f *LuetRepositoryFile) GetName() string {
|
||||
return f.Name
|
||||
func (f *LuetRepositoryFile) GetFileName() string {
|
||||
return f.FileName
|
||||
}
|
||||
func (f *LuetRepositoryFile) SetCompressionType(c compiler.CompressionImplementation) {
|
||||
f.CompressionType = c
|
||||
@ -421,7 +421,7 @@ func (r *LuetSystemRepository) Write(dst string, resetRevision bool) error {
|
||||
r.SetRepositoryFile(REPOFILE_TREE_KEY, treeFile)
|
||||
}
|
||||
|
||||
a := compiler.NewPackageArtifact(filepath.Join(dst, treeFile.GetName()))
|
||||
a := compiler.NewPackageArtifact(filepath.Join(dst, treeFile.GetFileName()))
|
||||
a.SetCompressionType(treeFile.GetCompressionType())
|
||||
err = a.Compress(archive, 1)
|
||||
if err != nil {
|
||||
@ -429,7 +429,7 @@ func (r *LuetSystemRepository) Write(dst string, resetRevision bool) error {
|
||||
}
|
||||
|
||||
// Update the tree name with the name created by compression selected.
|
||||
treeFile.SetName(path.Base(a.GetPath()))
|
||||
treeFile.SetFileName(path.Base(a.GetPath()))
|
||||
err = a.Hash()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed generating checksums for tree")
|
||||
@ -460,14 +460,14 @@ func (r *LuetSystemRepository) Write(dst string, resetRevision bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
a = compiler.NewPackageArtifact(filepath.Join(dst, metaFile.GetName()))
|
||||
a = compiler.NewPackageArtifact(filepath.Join(dst, metaFile.GetFileName()))
|
||||
a.SetCompressionType(metaFile.GetCompressionType())
|
||||
err = a.Compress(metaTmpDir, 1)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error met while archiving repository metadata")
|
||||
}
|
||||
|
||||
metaFile.SetName(path.Base(a.GetPath()))
|
||||
metaFile.SetFileName(path.Base(a.GetPath()))
|
||||
r.SetRepositoryFile(REPOFILE_META_KEY, metaFile)
|
||||
err = a.Hash()
|
||||
if err != nil {
|
||||
@ -570,10 +570,10 @@ func (r *LuetSystemRepository) Sync(force bool) (Repository, error) {
|
||||
if !repoUpdated {
|
||||
|
||||
// Get Tree
|
||||
a := compiler.NewPackageArtifact(treeFile.GetName())
|
||||
a := compiler.NewPackageArtifact(treeFile.GetFileName())
|
||||
artifactTree, err := c.DownloadArtifact(a)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "While downloading "+treeFile.GetName())
|
||||
return nil, errors.Wrap(err, "While downloading "+treeFile.GetFileName())
|
||||
}
|
||||
defer os.Remove(artifactTree.GetPath())
|
||||
|
||||
@ -588,10 +588,10 @@ func (r *LuetSystemRepository) Sync(force bool) (Repository, error) {
|
||||
Debug("Tree tarball for the repository " + r.GetName() + " downloaded correctly.")
|
||||
|
||||
// Get Repository Metadata
|
||||
a = compiler.NewPackageArtifact(metaFile.GetName())
|
||||
a = compiler.NewPackageArtifact(metaFile.GetFileName())
|
||||
artifactMeta, err := c.DownloadArtifact(a)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "While downloading "+metaFile.GetName())
|
||||
return nil, errors.Wrap(err, "While downloading "+metaFile.GetFileName())
|
||||
}
|
||||
defer os.Remove(artifactMeta.GetPath())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user