Merge pull request #15335 from hashicorp/jbardin/ux-no-plugins

ux with no plugins
This commit is contained in:
James Bardin 2017-06-19 13:00:06 -04:00 committed by GitHub
commit afe891a80e
3 changed files with 24 additions and 18 deletions

View File

@ -155,8 +155,7 @@ func (c *InitCommand) Run(args []string) int {
// in which case we choose not to show this. // in which case we choose not to show this.
if conf.Terraform != nil && conf.Terraform.Backend != nil { if conf.Terraform != nil && conf.Terraform.Backend != nil {
c.Ui.Output(c.Colorize().Color(fmt.Sprintf( c.Ui.Output(c.Colorize().Color(fmt.Sprintf(
"[reset][bold]" + "\n[reset][bold]Initializing the backend...")))
"Initializing the backend...")))
} }
opts := &BackendOpts{ opts := &BackendOpts{
@ -185,10 +184,6 @@ func (c *InitCommand) Run(args []string) int {
return 1 return 1
} }
c.Ui.Output(c.Colorize().Color(
"[reset][bold]Initializing provider plugins...",
))
err = c.getProviders(path, sMgr.State(), flagUpgrade) err = c.getProviders(path, sMgr.State(), flagUpgrade)
if err != nil { if err != nil {
// this function provides its own output // this function provides its own output
@ -229,7 +224,17 @@ func (c *InitCommand) getProviders(path string, state *terraform.State, upgrade
} else { } else {
available = c.providerPluginSet() available = c.providerPluginSet()
} }
requirements := terraform.ModuleTreeDependencies(mod, state).AllPluginRequirements() requirements := terraform.ModuleTreeDependencies(mod, state).AllPluginRequirements()
if len(requirements) == 0 {
// nothing to initialize
return nil
}
c.Ui.Output(c.Colorize().Color(
"\n[reset][bold]Initializing provider plugins...",
))
missing := c.missingPlugins(available, requirements) missing := c.missingPlugins(available, requirements)
var errs error var errs error

View File

@ -946,8 +946,7 @@ func (m *Meta) backend_C_R_s(
} }
m.Ui.Output(m.Colorize().Color(fmt.Sprintf( m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
"[reset][green]\n\n"+ "[reset][green]\n"+strings.TrimSpace(successBackendSet), s.Backend.Type)))
strings.TrimSpace(successBackendSet), s.Backend.Type)))
return b, nil return b, nil
} }
@ -1050,8 +1049,7 @@ func (m *Meta) backend_C_r_s(
} }
m.Ui.Output(m.Colorize().Color(fmt.Sprintf( m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
"[reset][green]\n\n"+ "[reset][green]\n"+strings.TrimSpace(successBackendSet), s.Backend.Type)))
strings.TrimSpace(successBackendSet), s.Backend.Type)))
// Return the backend // Return the backend
return b, nil return b, nil
@ -1148,8 +1146,7 @@ func (m *Meta) backend_C_r_S_changed(
if output { if output {
m.Ui.Output(m.Colorize().Color(fmt.Sprintf( m.Ui.Output(m.Colorize().Color(fmt.Sprintf(
"[reset][green]\n\n"+ "[reset][green]\n"+strings.TrimSpace(successBackendSet), s.Backend.Type)))
strings.TrimSpace(successBackendSet), s.Backend.Type)))
} }
return b, nil return b, nil

View File

@ -4,12 +4,10 @@ import (
"archive/tar" "archive/tar"
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"fmt"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"runtime"
"sort" "sort"
"strings" "strings"
"testing" "testing"
@ -123,15 +121,21 @@ func TestPush_goodBackendInit(t *testing.T) {
// Expected weird behavior, doesn't affect unpackaging // Expected weird behavior, doesn't affect unpackaging
".terraform/", ".terraform/",
".terraform/", ".terraform/",
".terraform/plugins/",
fmt.Sprintf(".terraform/plugins/%s_%s/", runtime.GOOS, runtime.GOARCH), // this config contains no plugins
fmt.Sprintf(".terraform/plugins/%s_%s/lock.json", runtime.GOOS, runtime.GOARCH), // TODO: we should add one or more plugins to this test config, just to
// verfy the pushed data. The expected additional files are listed below:
//
//".terraform/plugins/",
//fmt.Sprintf(".terraform/plugins/%s_%s/", runtime.GOOS, runtime.GOARCH),
//fmt.Sprintf(".terraform/plugins/%s_%s/lock.json", runtime.GOOS, runtime.GOARCH),
".terraform/terraform.tfstate", ".terraform/terraform.tfstate",
".terraform/terraform.tfstate", ".terraform/terraform.tfstate",
"main.tf", "main.tf",
} }
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Fatalf("bad: %#v", actual) t.Fatalf("expected: %#v\ngot: %#v", expected, actual)
} }
variables := make(map[string]interface{}) variables := make(map[string]interface{})