Add config export
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package shared
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
@@ -38,6 +39,19 @@ type ConfigOptions struct {
|
||||
Rules []Rule `json:"rules"`
|
||||
}
|
||||
|
||||
func BuildConfigJson(configOpt ConfigOptions, input option.Options) (string, error) {
|
||||
options := BuildConfig(configOpt, input)
|
||||
var buffer bytes.Buffer
|
||||
json.NewEncoder(&buffer)
|
||||
encoder := json.NewEncoder(&buffer)
|
||||
encoder.SetIndent("", " ")
|
||||
err := encoder.Encode(options)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return buffer.String(), nil
|
||||
}
|
||||
|
||||
// TODO include selectors
|
||||
func BuildConfig(configOpt ConfigOptions, input option.Options) option.Options {
|
||||
if configOpt.ExecuteAsIs {
|
||||
|
||||
Reference in New Issue
Block a user