Add "gocage get all myjail"
This commit is contained in:
parent
19dd2dfb33
commit
285229009f
@ -29,6 +29,12 @@ func GetJailProperties(args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isStringInArray(props, "all") {
|
||||||
|
var result []string
|
||||||
|
result = getStructFieldNames(jail, result, "")
|
||||||
|
props = result
|
||||||
|
}
|
||||||
|
|
||||||
for _, p := range props {
|
for _, p := range props {
|
||||||
v, err := getJailProperty(&jail, p)
|
v, err := getJailProperty(&jail, p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -112,7 +112,8 @@ Multiples properties can be specified, separated with space (Ex: gocage set allo
|
|||||||
Use: "get",
|
Use: "get",
|
||||||
Short: "Get a jail property",
|
Short: "Get a jail property",
|
||||||
Long: `Get jail property value. Specify property, end command with jail name.
|
Long: `Get jail property value. Specify property, end command with jail name.
|
||||||
Multiples properties can be specified, separated with space (Ex: gocage get allow_mlock boot myjail)`,
|
Multiples properties can be specified, separated with space (Ex: gocage get allow_mlock boot myjail)
|
||||||
|
For all properties specify "all" (Ex: gocage get all myjail)`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
// Get the inventory
|
// Get the inventory
|
||||||
ListJails(args, false)
|
ListJails(args, false)
|
||||||
@ -201,7 +202,6 @@ func initConfig() {
|
|||||||
func cleanAfterRun() {
|
func cleanAfterRun() {
|
||||||
for _, j := range gJails {
|
for _, j := range gJails {
|
||||||
if j.ConfigUpdated {
|
if j.ConfigUpdated {
|
||||||
//fmt.Printf("Config for jail %s will be updated\n", j.Name)
|
|
||||||
marshaled, err := json.MarshalIndent(j.Config, "", " ")
|
marshaled, err := json.MarshalIndent(j.Config, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR marshaling config: %s\n", err.Error())
|
fmt.Printf("ERROR marshaling config: %s\n", err.Error())
|
||||||
|
13
cmd/utils.go
13
cmd/utils.go
@ -1431,4 +1431,17 @@ func (ms *multiSorter) Less(i, j int) bool {
|
|||||||
return ms.less[k](p, q)
|
return ms.less[k](p, q)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* Generic utilities
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
func isStringInArray(strarr []string, searched string) bool {
|
||||||
|
for _, s := range strarr {
|
||||||
|
if strings.EqualFold(s, searched) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user