fix(forget): populate retention groups for manual runs
CI / Test (store) (pull_request) Successful in 5s
CI / Lint (pull_request) Successful in 10s
CI / Build (windows/amd64) (pull_request) Successful in 7s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Test (rest) (pull_request) Successful in 39s
CI / Test (server-http) (pull_request) Successful in 1m37s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m16s
CI / Test (store) (pull_request) Successful in 5s
CI / Lint (pull_request) Successful in 10s
CI / Build (windows/amd64) (pull_request) Successful in 7s
CI / Build (linux/amd64) (pull_request) Successful in 8s
CI / Build (linux/arm64) (pull_request) Successful in 7s
CI / Test (rest) (pull_request) Successful in 39s
CI / Test (server-http) (pull_request) Successful in 1m37s
e2e / Playwright vs docker-compose (pull_request) Successful in 1m16s
This commit is contained in:
@@ -65,10 +65,32 @@ func (s *Server) handleRunNow(w stdhttp.ResponseWriter, r *stdhttp.Request) {
|
||||
func (s *Server) dispatchJob(ctx context.Context, user *store.User,
|
||||
hostID string, kind api.JobKind, args []string,
|
||||
) (res runNowResponse, status int, code, msg string) {
|
||||
return s.dispatchJobWithPayload(ctx, user, hostID, kind, nil, api.CommandRunPayload{
|
||||
payload := api.CommandRunPayload{
|
||||
Kind: kind,
|
||||
Args: args,
|
||||
})
|
||||
}
|
||||
if kind == api.JobForget {
|
||||
if !validForgetArgs(args) {
|
||||
return res, stdhttp.StatusBadRequest, "invalid_args",
|
||||
"forget accepts no arguments other than --dry-run"
|
||||
}
|
||||
var ok bool
|
||||
var err error
|
||||
payload, ok, err = s.buildForgetPayloadForHost(ctx, hostID)
|
||||
if err != nil {
|
||||
return res, stdhttp.StatusInternalServerError, "internal", ""
|
||||
}
|
||||
if !ok {
|
||||
return res, stdhttp.StatusUnprocessableEntity, "no_retention_policy",
|
||||
"host has no source groups with a retention policy"
|
||||
}
|
||||
payload.Args = args
|
||||
}
|
||||
return s.dispatchJobWithPayload(ctx, user, hostID, kind, nil, payload)
|
||||
}
|
||||
|
||||
func validForgetArgs(args []string) bool {
|
||||
return len(args) == 0 || (len(args) == 1 && args[0] == "--dry-run")
|
||||
}
|
||||
|
||||
// dispatchJobWithPayload is dispatchJob's variant that lets callers
|
||||
|
||||
Reference in New Issue
Block a user