Skip to content

Commit 2d29476

Browse files
authored
fix issue with egg features (#97)
Resolves and issue with egg features when the panel returns an empty array and not an object. php why are you like this?
1 parent 3a2a206 commit 2d29476

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

server/configuration.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server
22

33
import (
4+
"encoding/json"
45
"sync"
56

67
"github.com/pelican-dev/wings/environment"
@@ -20,6 +21,34 @@ type EggConfiguration struct {
2021
Features map[string][]string `json:"features"`
2122
}
2223

24+
func (egg *EggConfiguration) UnmarshalJSON(b []byte) (err error) {
25+
var eggConfiguration struct {
26+
// The internal UUID of the Egg on the Panel.
27+
ID string `json:"id"`
28+
29+
// Maintains a list of files that are blacklisted for opening/editing/downloading
30+
// or basically any type of access on the server by any user. This is NOT the same
31+
// as a per-user denylist, this is defined at the Egg level.
32+
FileDenylist []string `json:"file_denylist"`
33+
34+
// Features is a map of feature identifiers to a list of console output strings
35+
// that should trigger a match (e.g., for things like EULA prompts).
36+
Features map[string][]string `json:"features"`
37+
}
38+
39+
// try unmarshalling first
40+
if err := json.Unmarshal(b, &eggConfiguration); err != nil {
41+
egg.Features = nil
42+
} else {
43+
egg.Features = eggConfiguration.Features
44+
}
45+
46+
egg.ID = eggConfiguration.ID
47+
egg.FileDenylist = eggConfiguration.FileDenylist
48+
49+
return nil
50+
}
51+
2352
type ConfigurationMeta struct {
2453
Name string `json:"name"`
2554
Description string `json:"description"`

0 commit comments

Comments
 (0)