-
Notifications
You must be signed in to change notification settings - Fork 124
/
reload.go
43 lines (32 loc) · 877 Bytes
/
reload.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2021-2024 Zenauth Ltd.
// SPDX-License-Identifier: Apache-2.0
package reload
import (
"context"
"fmt"
"github.com/alecthomas/kong"
cmdclient "github.com/cerbos/cerbos/cmd/cerbosctl/internal/client"
)
const help = `# Reload the store
cerbosctl store reload
# Reload the store and wait until it finishes
cerbosctl store reload --wait`
type Cmd struct {
Wait bool `help:"Wait until the reloading process finishes"`
}
func (c *Cmd) Run(k *kong.Kong, ctx *cmdclient.Context) error {
_, _ = fmt.Fprint(k.Stdout, "Initiated a store reload\n")
err := ctx.AdminClient.ReloadStore(context.Background(), c.Wait)
if err != nil {
return err
}
if c.Wait {
_, _ = fmt.Fprint(k.Stdout, "Successfully reloaded the store\n")
} else {
_, _ = fmt.Fprint(k.Stdout, "Reload request submitted\n")
}
return nil
}
func (c *Cmd) Help() string {
return help
}