forked from juju/juju
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reload.go
52 lines (43 loc) · 1.3 KB
/
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
44
45
46
47
48
49
50
51
52
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package space
import (
"strings"
"github.com/juju/cmd/v3"
"github.com/juju/errors"
jujucmd "github.com/DavinZhang/juju/cmd"
"github.com/DavinZhang/juju/cmd/juju/block"
"github.com/DavinZhang/juju/cmd/modelcmd"
)
// NewListCommand returns a command used to list spaces.
func NewReloadCommand() modelcmd.ModelCommand {
return modelcmd.Wrap(&ReloadCommand{})
}
// listCommand displays a list of all spaces known to Juju.
type ReloadCommand struct {
SpaceCommandBase
}
const ReloadCommandDoc = `
Reloades spaces and subnets from substrate
`
// Info is defined on the cmd.Command interface.
func (c *ReloadCommand) Info() *cmd.Info {
return jujucmd.Info(&cmd.Info{
Name: "reload-spaces",
Purpose: "Reloads spaces and subnets from substrate.",
Doc: strings.TrimSpace(ReloadCommandDoc),
})
}
// Run implements Command.Run.
func (c *ReloadCommand) Run(ctx *cmd.Context) error {
return c.RunWithSpaceAPI(ctx, func(api SpaceAPI, ctx *cmd.Context) error {
err := api.ReloadSpaces()
if err != nil {
if errors.IsNotSupported(err) {
ctx.Infof("cannot reload spaces: %v", err)
}
return block.ProcessBlockedError(errors.Annotate(err, "could not reload spaces"), block.BlockChange)
}
return nil
})
}