From 9d6326545a262616a283645dfe4fbe17012924c0 Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Fri, 27 May 2016 10:51:23 -0700 Subject: [PATCH] Hide plugin discovery log message when we are running a plugin --- config.go | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/config.go b/config.go index 5a3e929bd..340efa6f3 100644 --- a/config.go +++ b/config.go @@ -120,32 +120,34 @@ func (c *Config) Discover(ui cli.Ui) error { } // Finally, if we have a plugin compiled into Terraform and we didn't find - // a replacement on disk, we'll just use the internal version. - for name, _ := range command.InternalProviders { - if path, found := c.Providers[name]; found { - ui.Warn(fmt.Sprintf("[WARN] %s overrides an internal plugin for %s-provider.\n"+ - " If you did not expect to see this message you will need to remove the old plugin.\n"+ - " See https://www.terraform.io/docs/internals/internal-plugins.html", path, name)) - } else { - - cmd, err := command.BuildPluginCommandString("provider", name) - if err != nil { - return err + // a replacement on disk, we'll just use the internal version. Only do this + // from the main process. + if os.Getenv("TF_PLUGIN_MAGIC_COOKIE") == "" { + for name, _ := range command.InternalProviders { + if path, found := c.Providers[name]; found { + ui.Warn(fmt.Sprintf("[WARN] %s overrides an internal plugin for %s-provider.\n"+ + " If you did not expect to see this message you will need to remove the old plugin.\n"+ + " See https://www.terraform.io/docs/internals/internal-plugins.html", path, name)) + } else { + cmd, err := command.BuildPluginCommandString("provider", name) + if err != nil { + return err + } + c.Providers[name] = cmd } - c.Providers[name] = cmd } - } - for name, _ := range command.InternalProvisioners { - if path, found := c.Provisioners[name]; found { - ui.Warn(fmt.Sprintf("[WARN] %s overrides an internal plugin for %s-provisioner.\n"+ - " If you did not expect to see this message you will need to remove the old plugin.\n"+ - " See https://www.terraform.io/docs/internals/internal-plugins.html", path, name)) - } else { - cmd, err := command.BuildPluginCommandString("provisioner", name) - if err != nil { - return err + for name, _ := range command.InternalProvisioners { + if path, found := c.Provisioners[name]; found { + ui.Warn(fmt.Sprintf("[WARN] %s overrides an internal plugin for %s-provisioner.\n"+ + " If you did not expect to see this message you will need to remove the old plugin.\n"+ + " See https://www.terraform.io/docs/internals/internal-plugins.html", path, name)) + } else { + cmd, err := command.BuildPluginCommandString("provisioner", name) + if err != nil { + return err + } + c.Provisioners[name] = cmd } - c.Provisioners[name] = cmd } }