Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiffWrapper ¶
func DiffWrapper(w io.Writer, mutator configmaps.Mutator) configmaps.Mutator
DiffWrapper wraps a mutator and prints out the diff between the original object and the one it returns if there's no error.
Example (Changes) ¶
obj := &v1.ConfigMap{}
obj.Data = map[string]string{"some-key": "some-value"}
contents := &bytes.Buffer{}
wrapper := DiffWrapper(contents, func(obj *v1.ConfigMap) error {
obj.Data = map[string]string{"some-key": "new-value"}
return nil
})
fmt.Println("Error:", wrapper(obj))
firstLine := strings.Split(contents.String(), "\n")[0]
fmt.Println("First line:", firstLine)
Output: Error: <nil> First line: ConfigMap Diff (-old +new):
Example (Err) ¶
obj := &v1.ConfigMap{}
wrapper := DiffWrapper(os.Stdout, func(_ *v1.ConfigMap) error {
return errors.New("some-error")
})
fmt.Println(wrapper(obj))
Output: some-error
Example (NoDiff) ¶
obj := &v1.ConfigMap{}
wrapper := DiffWrapper(os.Stdout, func(cm *v1.ConfigMap) error {
// don't mutate the object
return nil
})
wrapper(obj)
Output: No changes
func FormatDiff ¶
FormatDiff creates a diff between two ConfigMaps and writes it to the given writer.
func NewConfigClusterCommand ¶
NewConfigClusterCommand creates a command that can set facets of a Kf cluster.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.