feat: added special case for --profile=all
This commit is contained in:
parent
870107d680
commit
2eee847205
2 changed files with 56 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"git.towk2.me/towk/makeshift/internal/archive"
|
||||
|
|
@ -315,6 +316,25 @@ func (s *Service) GetStatus(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (s *Service) loadProfiles(profileIDs []string, store storage.KVStore, errs []error) []error {
|
||||
// check for special case profile ID (e.g. '*' or 'all')
|
||||
useAll := slices.ContainsFunc(profileIDs, func(profileID string) bool {
|
||||
return profileID == "*" || profileID == "all"
|
||||
})
|
||||
if useAll {
|
||||
var (
|
||||
dirpath = s.PathForProfiles()
|
||||
profiles []*makeshift.Profile
|
||||
err error
|
||||
)
|
||||
profiles, err = LoadProfilesFromDir(dirpath)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
return errs
|
||||
}
|
||||
store.Set("profiles", profiles)
|
||||
return nil
|
||||
}
|
||||
|
||||
// load data from profiles into the data store
|
||||
var profiles = make(makeshift.ProfileMap, len(profileIDs))
|
||||
for i, profileID := range profileIDs {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue