-
Notifications
You must be signed in to change notification settings - Fork 17
/
config_log.go
37 lines (32 loc) · 983 Bytes
/
config_log.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
package devices
import (
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/foundriesio/fioctl/client"
"github.com/foundriesio/fioctl/subcommands"
)
func init() {
logConfigCmd := &cobra.Command{
Use: "log <device>",
Short: "Show a changelog of device's configuration",
Run: doConfigLog,
Args: cobra.ExactArgs(1),
}
configCmd.AddCommand(logConfigCmd)
logConfigCmd.Flags().IntP("limit", "n", 0, "Limit the number of results displayed.")
}
func doConfigLog(cmd *cobra.Command, args []string) {
factory := viper.GetString("factory")
device := args[0]
listLimit, _ := cmd.Flags().GetInt("limit")
logrus.Debugf("Showing device config log for %s", device)
subcommands.LogConfigs(&subcommands.LogConfigsOptions{
Limit: listLimit,
ShowAppliedAt: true,
ListFunc: func() (*client.DeviceConfigList, error) {
return api.DeviceListConfig(factory, device)
},
ListContFunc: api.DeviceListConfigCont,
})
}