func (t *YAMLTransformer) Write(dest io.Writer) error {
	if !t.initialized {
		return fmt.Errorf(nonInitTransformerError)
	}
	c := t.config.AllSettings()
	bs, err := yaml.Marshal(c)
	if err != nil {
		return fmt.Errorf("unable to marshal config to YAML: %v", err)
	}
	_, err = dest.Write(bs)
	return err
}
Write outputs the yaml to the io.Writer
package config
import (
	"fmt"
	"io"
	"github.com/spf13/viper"
	yaml "gopkg.in/yaml.v2"
)
const (
	nonInitTransformerError = "cannot transform uninitialized transformer"
)
type YAMLTransformer struct {
	config      *viper.Viper
	initialized bool
}
func NewYAMLTransformer() Transformer {
	cfg := viper.New()
	cfg.SetConfigType("yaml")
	return &YAMLTransformer{
		config:      cfg,
		initialized: false,
	}
}
func (t *YAMLTransformer) Read(source io.Reader) error {
	err := t.config.ReadConfig(source)
	if err != nil {
		return err
	}
	t.initialized = true
	return nil
}