This commit is contained in:
Philippe Caseiro 2022-06-29 12:13:32 +02:00
parent eb50773656
commit 1a180113cb
5 changed files with 24 additions and 3 deletions

View File

@ -43,8 +43,8 @@ func (hr *APKRepository) Delete() error {
return err return err
} }
lines := strings.Split(string(fileBytes), "\n") lines := strings.Split(string(fileBytes), "\n")
for i, line := range lines { for _, line := range lines {
fmt.Println(line)
} }
return nil return nil
} }

View File

@ -18,7 +18,7 @@ func (hr *DebRepository) Add() error {
//deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted //deb http://fr.archive.ubuntu.com/ubuntu/ focal main restricted
data := fmt.Sprintf("deb %s", hr.URL) 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 return err
} }

View File

@ -4,6 +4,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"path/filepath" "path/filepath"
"github.com/mitchellh/mapstructure"
) )
type Service struct { type Service struct {
@ -11,10 +13,29 @@ type Service struct {
Vars map[string]interface{} `json:"Vars"` Vars map[string]interface{} `json:"Vars"`
Daemons map[string]SystemService `json:"Daemons"` Daemons map[string]SystemService `json:"Daemons"`
Users map[string]SystemUser `json:"Users"` Users map[string]SystemUser `json:"Users"`
Repos map[string]interface{} `json:"Repositories"`
Packages map[string]SystemPackage `json:"Packages"` 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 { func (s *Service) Manage(templateDir string) error {
for _, repo := range s.Repos {
if err := s.manageRepo(repo); err != nil {
return err
}
}
// Manage system packages // Manage system packages
for _, pack := range s.Packages { for _, pack := range s.Packages {
err := pack.Manage() err := pack.Manage()