// flags adds the meta flags to the given FlagSet. func (m *Meta) flagSet(n string) *flag.FlagSet { f := flag.NewFlagSet(n, flag.ContinueOnError) f.BoolVar(&m.input, "input", true, "input") f.Var((*variables.Flag)(&m.variables), "var", "variables") f.Var((*variables.FlagFile)(&m.variables), "var-file", "variable file") f.Var((*FlagStringSlice)(&m.targets), "target", "resource to target") if m.autoKey != "" { f.Var((*variables.FlagFile)(&m.autoVariables), m.autoKey, "variable file") } // Advanced (don't need documentation, or unlikely to be set) f.BoolVar(&m.shadow, "shadow", true, "shadow graph") // Experimental features experiment.Flag(f) // Create an io.Writer that writes to our Ui properly for errors. // This is kind of a hack, but it does the job. Basically: create // a pipe, use a scanner to break it into lines, and output each line // to the UI. Do this forever. errR, errW := io.Pipe() errScanner := bufio.NewScanner(errR) go func() { for errScanner.Scan() { m.Ui.Error(errScanner.Text()) } }() f.SetOutput(errW) // Set the default Usage to empty f.Usage = func() {} return f }
func TestMain(m *testing.M) { experiment.Flag(flag.CommandLine) flag.Parse() if testing.Verbose() { // if we're verbose, use the logging requested by TF_LOG logging.SetOutput() } else { // otherwise silence all logs log.SetOutput(ioutil.Discard) } // Make sure shadow operations fail our real tests contextFailOnShadowError = true // Always DeepCopy the Diff on every Plan during a test contextTestDeepCopyOnPlan = true os.Exit(m.Run()) }