Bound pool declaration reads and document operator commands
This commit is contained in:
+14
-2
@@ -1002,13 +1002,25 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
}
|
||||
var data []byte
|
||||
if file == "-" {
|
||||
data, err = io.ReadAll(a.In)
|
||||
input := a.In
|
||||
if input == nil {
|
||||
input = os.Stdin
|
||||
}
|
||||
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
|
||||
} else {
|
||||
data, err = os.ReadFile(file)
|
||||
var input *os.File
|
||||
input, err = os.Open(file)
|
||||
if err == nil {
|
||||
data, err = io.ReadAll(io.LimitReader(input, 256*1024+1))
|
||||
_ = input.Close()
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(data) > 256*1024 {
|
||||
return fmt.Errorf("resource pool input exceeds 262144 bytes")
|
||||
}
|
||||
var pool protocol.ResourcePool
|
||||
if err := json.Unmarshal(data, &pool); err != nil {
|
||||
return fmt.Errorf("invalid resource pool JSON: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user