diff --git a/pkg/templater/repositories/apk.go b/pkg/templater/repo-apk.go similarity index 95% rename from pkg/templater/repositories/apk.go rename to pkg/templater/repo-apk.go index e8e3e8a..c43cd4c 100644 --- a/pkg/templater/repositories/apk.go +++ b/pkg/templater/repo-apk.go @@ -43,8 +43,8 @@ func (hr *APKRepository) Delete() error { return err } lines := strings.Split(string(fileBytes), "\n") - for i, line := range lines { - + for _, line := range lines { + fmt.Println(line) } return nil } diff --git a/pkg/templater/repositories/deb.go b/pkg/templater/repo-deb.go similarity index 90% rename from pkg/templater/repositories/deb.go rename to pkg/templater/repo-deb.go index d0644c1..4f1adba 100644 --- a/pkg/templater/repositories/deb.go +++ b/pkg/templater/repo-deb.go @@ -18,7 +18,7 @@ func (hr *DebRepository) Add() error { //deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted data := fmt.Sprintf("deb %s", hr.URL) - if err := os.WriteFile("/etc/apt/source.list.d", []byte(data)); err != nil { + if err := os.WriteFile("/etc/apt/source.list.d", []byte(data), 0600); err != nil { return err } diff --git a/pkg/templater/repositories/helm.go b/pkg/templater/repo-helm.go similarity index 100% rename from pkg/templater/repositories/helm.go rename to pkg/templater/repo-helm.go diff --git a/pkg/templater/repositories/main.go b/pkg/templater/repo.go similarity index 100% rename from pkg/templater/repositories/main.go rename to pkg/templater/repo.go diff --git a/pkg/templater/services.go b/pkg/templater/services.go index e2a03a9..ace465d 100644 --- a/pkg/templater/services.go +++ b/pkg/templater/services.go @@ -4,6 +4,8 @@ import ( "encoding/json" "fmt" "path/filepath" + + "github.com/mitchellh/mapstructure" ) type Service struct { @@ -11,10 +13,29 @@ type Service struct { Vars map[string]interface{} `json:"Vars"` Daemons map[string]SystemService `json:"Daemons"` Users map[string]SystemUser `json:"Users"` + Repos map[string]interface{} `json:"Repositories"` Packages map[string]SystemPackage `json:"Packages"` } +func (s *Service) manageRepo(repo interface{}) error { + fmt.Printf("%v\n", repo) + if repo["type"] == "helm" { + var rp HelmRepository + mapstructure.Decode(repo, rp) + } + + return nil +} + func (s *Service) Manage(templateDir string) error { + + for _, repo := range s.Repos { + if err := s.manageRepo(repo); err != nil { + return err + } + + } + // Manage system packages for _, pack := range s.Packages { err := pack.Manage()