Add operator resource pool configuration commands
This commit is contained in:
+61
-2
@@ -49,7 +49,7 @@ type options struct {
|
||||
json, source, noOpen, yes, allow, createOnly, force, wait bool
|
||||
version, expected, limit, recoverySequence, retryVisit int
|
||||
recoveryRun int64
|
||||
recoveryStage, resource string
|
||||
recoveryStage, resource, poolFile string
|
||||
timeout, waitTimeout time.Duration
|
||||
stageModels stageModelFlags
|
||||
}
|
||||
@@ -193,6 +193,11 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
|
||||
f.StringVar(&o.actor, "actor", "operator", "Bounded operator identity")
|
||||
f.BoolVar(&o.allow, "no-mutating-action", false, "Evidence explicitly records that no mutating action occurred")
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm reconciliation without prompting")
|
||||
case "resource-pool-inspect":
|
||||
f.StringVar(&o.resource, "pool", "", "Resource pool name")
|
||||
case "resource-pool-configure":
|
||||
f.StringVar(&o.poolFile, "file", "", "JSON pool declaration, or - for stdin")
|
||||
f.BoolVar(&o.yes, "yes", false, "Confirm this mutation without prompting")
|
||||
case "debug":
|
||||
f.StringVar(&o.harness, "harness", "", "Debugging harness: configured opencode/pi, or nvim")
|
||||
f.BoolVar(&o.yes, "yes", false, "Approve opening a debugging session without prompting")
|
||||
@@ -479,7 +484,7 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
requestTimeout = 30 * time.Second
|
||||
}
|
||||
connectURL := o.url
|
||||
if command == "resource-inspect" || command == "resource-reconcile" {
|
||||
if command == "resource-inspect" || command == "resource-reconcile" || command == "resource-pool-inspect" || command == "resource-pool-configure" {
|
||||
var transportErr error
|
||||
connectURL, transportErr = operatorTransportURL(o.url)
|
||||
if transportErr != nil {
|
||||
@@ -966,6 +971,60 @@ func (a App) Run(ctx context.Context, args []string) error {
|
||||
}
|
||||
_, err = fmt.Fprintf(a.Out, "Reconciled resource %s for run #%d\n", pos[0], runID)
|
||||
return err
|
||||
case "resource-pool-inspect":
|
||||
if len(pos) > 1 {
|
||||
return fmt.Errorf("resource-pool-inspect takes one pool name")
|
||||
}
|
||||
if o.resource == "" && len(pos) == 1 {
|
||||
o.resource = pos[0]
|
||||
}
|
||||
if strings.TrimSpace(o.resource) == "" {
|
||||
return fmt.Errorf("resource-pool-inspect requires a pool name")
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.InspectResourcePool, Resource: o.resource})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if r.ResourcePool == nil {
|
||||
return fmt.Errorf("server did not return resource pool")
|
||||
}
|
||||
return a.output(r.ResourcePool)
|
||||
case "resource-pool-configure":
|
||||
if len(pos) > 1 {
|
||||
return fmt.Errorf("resource-pool-configure takes one JSON file")
|
||||
}
|
||||
file := o.poolFile
|
||||
if file == "" && len(pos) == 1 {
|
||||
file = pos[0]
|
||||
}
|
||||
if file == "" {
|
||||
return fmt.Errorf("resource-pool-configure requires a JSON file")
|
||||
}
|
||||
var data []byte
|
||||
if file == "-" {
|
||||
data, err = io.ReadAll(a.In)
|
||||
} else {
|
||||
data, err = os.ReadFile(file)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var pool protocol.ResourcePool
|
||||
if err := json.Unmarshal(data, &pool); err != nil {
|
||||
return fmt.Errorf("invalid resource pool JSON: %w", err)
|
||||
}
|
||||
if err := a.confirmAction(fmt.Sprintf("Configure resource pool %s?", pool.Name), o.yes); err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := call(protocol.Message{Type: protocol.ConfigureResourcePool, ResourcePool: &pool})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if o.json {
|
||||
return a.output(r)
|
||||
}
|
||||
_, err = fmt.Fprintf(a.Out, "Configured resource pool %s\n", pool.Name)
|
||||
return err
|
||||
case "inspect", "cancel", "retry":
|
||||
value, err := one()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user