Skip to content

Commit

Permalink
Add ability to update minimums to control.
Browse files Browse the repository at this point in the history
  • Loading branch information
gram-signal authored May 23, 2024
1 parent 1cb2f36 commit a2a320f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions host/cmd/control/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ var (
metrics struct {
updateEnvStats bool
}
updateMinimum struct {
key string
value string
valueEncoding string
}
}
commands = map[string]*command{
"command": &command{
Expand Down Expand Up @@ -119,6 +124,16 @@ var (
return fs
}(),
},
"updateMinimum": &command{
f: updateMinimum,
description: "Update a minimum value",
fs: func() *flag.FlagSet {
fs := flag.NewFlagSet("updateMinimum", flag.ExitOnError)
fs.StringVar(&args.updateMinimum.key, "key", "", "Minimum key to update")
fs.StringVar(&args.updateMinimum.value, "value", "", "Minimum value to update, AS HEX")
return fs
}(),
},
}
)

Expand Down Expand Up @@ -355,3 +370,24 @@ func metrics(cc *client.ControlClient) error {
}
return nil
}

func updateMinimum(cc *client.ControlClient) error {
if args.updateMinimum.key == "" {
return fmt.Errorf("must set --key")
}
if args.updateMinimum.value == "" {
return fmt.Errorf("must set --value")
}
bytes, err := hex.DecodeString(args.updateMinimum.value)
if err != nil {
return fmt.Errorf("decoding hex --value=%q: %w", args.updateMinimum.value, err)
}
_, err = cc.Do(&pb.HostToEnclaveRequest{
Inner: &pb.HostToEnclaveRequest_UpdateMinimums{UpdateMinimums: &pb.MinimumLimits{
Lim: map[string][]byte{
args.updateMinimum.key: bytes,
},
}},
})
return err
}

0 comments on commit a2a320f

Please sign in to comment.