// formatPlanModuleSingle will output the given module and all of its // resources. func formatPlanModuleSingle( buf *bytes.Buffer, m *terraform.ModuleDiff, opts *FormatPlanOpts) { // Ignore empty diffs if m.Empty() { return } moduleName := fmt.Sprintf("module.%s", strings.Join(m.Path[1:], ".")) // Determine the color for the text (green for adding, yellow // for change, red for delete), and symbol, and output the // resource header. color := "yellow" symbol := "~" switch m.ChangeType() { case terraform.DiffCreate: color = "green" symbol = "+" case terraform.DiffDestroy: color = "red" symbol = "-" } buf.WriteString(opts.Color.Color(fmt.Sprintf( "[%s]%s %s\n", color, symbol, moduleName))) buf.WriteString(fmt.Sprintf( " %d resource(s)", len(m.Resources))) buf.WriteString(opts.Color.Color("[reset]\n")) }