Exemple #1
0
// Default prints the configuration compared to its default values.
//
func Default(build cftype.Builder, showAll bool) {
	cols := []tablist.ColInfo{
		tablist.NewColLeft(0, "Type"),
		tablist.NewColLeft(0, "Name"),
	}

	if showAll {
		cols = append(cols,
			tablist.NewColLeft(0, "Default"),
		)
	}
	cols = append(cols,
		tablist.NewColLeft(0, "Current"),
	)

	lf := &lineFeed{
		TableFormater: *tablist.NewFormater(cols...),
	}
	if showAll {
		lf.valuePrint = lf.valueDefault
		build.KeyWalk(lf.Add)
	} else {
		build.KeyWalk(lf.addTest)
	}

	lf.Print()

	if lf.countChanged > 0 {
		build.Log().Info("changed", lf.countChanged, "/", lf.countChangeable)
	} else {
		build.Log().Info("nothing changed")
	}
}
Exemple #2
0
func countChanged(t *testing.T, build cftype.Builder) int {
	count := 0
	build.KeyWalk(func(key *cftype.Key) {
		lold, e := key.Storage().Default(key.Group, key.Name) // TODO: should crash with vstorage.
		assert.NoError(t, e, "get storage default", key.Group, key.Name)
		if e == nil && key.ValueState(lold).IsChanged() {
			count++
		}
	})
	return count
}
Exemple #3
0
// Updated prints the configuration compared to its storage values.
//
func Updated(build cftype.Builder) {
	// build.Log().DEV("save to virtual")
	lf := &lineFeed{
		TableFormater: *tablist.NewFormater(
			tablist.NewColLeft(0, "Type"),
			tablist.NewColLeft(0, "Name"),
			tablist.NewColLeft(0, "Old value"),
			tablist.NewColLeft(0, "New value"),
		),
	}
	lf.valuePrint = lf.valueUpdated

	build.KeyWalk(lf.Add)
	lf.Print()

	if lf.countChanged > 0 {
		build.Log().Info("changed", lf.countChanged, "/", lf.countChangeable)
	} else {
		build.Log().Info("nothing changed")
	}
}