From 865e61b4eabf1fa0d126b202d522a61484512ea0 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 18 Oct 2017 08:52:13 -0700 Subject: [PATCH] main+command: provide service disco and creds to commands The command package is the main place we need access to these, so that we can use them during init (to install packages, for example) and so that we can use them to configure remote backends. For the moment we're just providing an empty credentials object, which will start to include both statically-configured and helper-program-provided credentials sources in subsequent commits. --- command/meta.go | 10 ++++++++++ commands.go | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/command/meta.go b/command/meta.go index 806bd3961..bb58ab654 100644 --- a/command/meta.go +++ b/command/meta.go @@ -24,6 +24,8 @@ import ( "github.com/hashicorp/terraform/helper/experiment" "github.com/hashicorp/terraform/helper/variables" "github.com/hashicorp/terraform/helper/wrappedstreams" + "github.com/hashicorp/terraform/svchost/auth" + "github.com/hashicorp/terraform/svchost/disco" "github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/tfdiags" "github.com/mitchellh/cli" @@ -44,6 +46,14 @@ type Meta struct { // ExtraHooks are extra hooks to add to the context. ExtraHooks []terraform.Hook + // Services provides access to remote endpoint information for + // "terraform-native' services running at a specific user-facing hostname. + Services *disco.Disco + + // Credentials provides access to credentials for "terraform-native" + // services, which are accessed by a service hostname. + Credentials auth.CredentialsSource + // RunningInAutomation indicates that commands are being run by an // automated system rather than directly at a command prompt. // diff --git a/commands.go b/commands.go index 045b783d2..b3380884d 100644 --- a/commands.go +++ b/commands.go @@ -4,6 +4,9 @@ import ( "os" "os/signal" + "github.com/hashicorp/terraform/svchost/auth" + "github.com/hashicorp/terraform/svchost/disco" + "github.com/hashicorp/terraform/command" "github.com/mitchellh/cli" ) @@ -31,12 +34,19 @@ func initCommands(config *Config) { inAutomation = true } + credsSrc := auth.NoCredentials // TODO: Actually expose credentials here + services := disco.NewDisco() + services.SetCredentialsSource(credsSrc) + meta := command.Meta{ Color: true, GlobalPluginDirs: globalPluginDirs(), PluginOverrides: &PluginOverrides, Ui: Ui, + Services: services, + Credentials: credsSrc, + RunningInAutomation: inAutomation, PluginCacheDir: config.PluginCacheDir, }