Dynamic whitelist for experimental repo
This commit is contained in:
parent
ccad5f6a3a
commit
fe65a0b9eb
@ -4,6 +4,7 @@ import (
|
||||
"brunel/domain"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
@ -43,6 +44,10 @@ type Config struct {
|
||||
ActionsUrl string `json:"actionsUrl"`
|
||||
}
|
||||
|
||||
type expPkgNames struct {
|
||||
PackageNames []string `json:"package_names"`
|
||||
}
|
||||
|
||||
func Init() error {
|
||||
err := loadUsers()
|
||||
if err != nil {
|
||||
@ -103,5 +108,38 @@ func loadConfig() error {
|
||||
|
||||
Configs = config
|
||||
|
||||
xpPkgNames, err := LoadExperimentalPackageNames()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i, pkg := range Configs.ExternalPackageFiles {
|
||||
if pkg.Name == "Debian experimental" {
|
||||
pkg.Whitelist = xpPkgNames
|
||||
pkg.UseWhitelist = true
|
||||
Configs.ExternalPackageFiles[i] = pkg
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadExperimentalPackageNames() ([]string, error) {
|
||||
var epPkgNames expPkgNames
|
||||
response, err := http.Get("https://raw.githubusercontent.com/PikaOS-Linux/pika-base-debian-container/main/exp_pkg_names.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
byteValue, _ := io.ReadAll(response.Body)
|
||||
|
||||
err = json.Unmarshal(byteValue, &epPkgNames)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return epPkgNames.PackageNames, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user