add "Updating" output and fix output tests
This commit is contained in:
parent
9c334fe012
commit
1bf64ec788
|
@ -30,7 +30,7 @@ func TestGet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ui.OutputWriter.String()
|
output := ui.OutputWriter.String()
|
||||||
if !strings.Contains(output, "Get: file://") {
|
if !strings.Contains(output, `Module "foo"`) {
|
||||||
t.Fatalf("doesn't look like get: %s", output)
|
t.Fatalf("doesn't look like get: %s", output)
|
||||||
}
|
}
|
||||||
if strings.Contains(output, "(update)") {
|
if strings.Contains(output, "(update)") {
|
||||||
|
@ -78,7 +78,7 @@ func TestGet_noArgs(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ui.OutputWriter.String()
|
output := ui.OutputWriter.String()
|
||||||
if !strings.Contains(output, "Get: file://") {
|
if !strings.Contains(output, `Module "foo"`) {
|
||||||
t.Fatalf("doesn't look like get: %s", output)
|
t.Fatalf("doesn't look like get: %s", output)
|
||||||
}
|
}
|
||||||
if strings.Contains(output, "(update)") {
|
if strings.Contains(output, "(update)") {
|
||||||
|
@ -108,10 +108,7 @@ func TestGet_update(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
output := ui.OutputWriter.String()
|
output := ui.OutputWriter.String()
|
||||||
if !strings.Contains(output, "Get: file://") {
|
if !strings.Contains(output, `Updating source "./foo"`) {
|
||||||
t.Fatalf("doesn't look like get: %s", output)
|
|
||||||
}
|
|
||||||
if !strings.Contains(output, "(update)") {
|
|
||||||
t.Fatalf("doesn't look like get: %s", output)
|
t.Fatalf("doesn't look like get: %s", output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ func TestInit_get(t *testing.T) {
|
||||||
|
|
||||||
// Check output
|
// Check output
|
||||||
output := ui.OutputWriter.String()
|
output := ui.OutputWriter.String()
|
||||||
if !strings.Contains(output, "Get: file://") {
|
if !strings.Contains(output, "Getting source") {
|
||||||
t.Fatalf("doesn't look like get: %s", output)
|
t.Fatalf("doesn't look like get: %s", output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ func TestInit_getUpgradeModules(t *testing.T) {
|
||||||
|
|
||||||
// Check output
|
// Check output
|
||||||
output := ui.OutputWriter.String()
|
output := ui.OutputWriter.String()
|
||||||
if !strings.Contains(output, "(update)") {
|
if !strings.Contains(output, "Updating source") {
|
||||||
t.Fatalf("doesn't look like get upgrade: %s", output)
|
t.Fatalf("doesn't look like get upgrade: %s", output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,13 @@ func (t *Tree) getChildren(s *Storage) (map[string]*Tree, error) {
|
||||||
subDir = filepath.Join(detectedSubDir, subDir)
|
subDir = filepath.Join(detectedSubDir, subDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
output := fmt.Sprintf(" Getting source %q", m.Source)
|
output := ""
|
||||||
|
switch s.Mode {
|
||||||
|
case GetModeUpdate:
|
||||||
|
output = fmt.Sprintf(" Updating source %q", m.Source)
|
||||||
|
default:
|
||||||
|
output = fmt.Sprintf(" Getting source %q", m.Source)
|
||||||
|
}
|
||||||
s.output(output)
|
s.output(output)
|
||||||
|
|
||||||
dir, ok, err := s.getStorage(key, source)
|
dir, ok, err := s.getStorage(key, source)
|
||||||
|
@ -373,6 +379,50 @@ func (t *Tree) inheritProviderConfigs(stack []*Tree) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Search for implicit provider configs
|
||||||
|
// This adds an empty config is no inherited config is found, so that
|
||||||
|
// there is always a provider config present.
|
||||||
|
// This is done in the root module as well, just to set the providers.
|
||||||
|
for missing := range missingProviders {
|
||||||
|
// first create an empty provider config
|
||||||
|
pc := &config.ProviderConfig{
|
||||||
|
Name: missing,
|
||||||
|
}
|
||||||
|
|
||||||
|
// walk up the stack looking for matching providers
|
||||||
|
for i := len(stack) - 2; i >= 0; i-- {
|
||||||
|
pt := stack[i]
|
||||||
|
var parentProvider *config.ProviderConfig
|
||||||
|
for _, p := range pt.config.ProviderConfigs {
|
||||||
|
if p.FullName() == missing {
|
||||||
|
parentProvider = p
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if parentProvider == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
pc.Path = pt.Path()
|
||||||
|
pc.Path = append([]string{RootName}, pt.path...)
|
||||||
|
pc.RawConfig = parentProvider.RawConfig
|
||||||
|
pc.Inherited = true
|
||||||
|
log.Printf("[TRACE] provider %q inheriting config from %q",
|
||||||
|
strings.Join(append(t.Path(), pc.FullName()), "."),
|
||||||
|
strings.Join(append(pt.Path(), parentProvider.FullName()), "."),
|
||||||
|
)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
// always set a provider config
|
||||||
|
if pc.RawConfig == nil {
|
||||||
|
pc.RawConfig, _ = config.NewRawConfig(map[string]interface{}{})
|
||||||
|
}
|
||||||
|
|
||||||
|
t.config.ProviderConfigs = append(t.config.ProviderConfigs, pc)
|
||||||
|
}
|
||||||
|
|
||||||
// After allowing the empty implicit configs to be created in root, there's nothing left to inherit
|
// After allowing the empty implicit configs to be created in root, there's nothing left to inherit
|
||||||
if len(stack) == 1 {
|
if len(stack) == 1 {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue