From 30672faebea0590a3a84c34127805c915db89051 Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Mon, 11 Mar 2019 07:29:36 -0700 Subject: [PATCH] remove indentation from json output of `show` and `providers schema` (#20623) * command/providers schema: correct help text * command/show: remove indentation from json output * command/providers schema: remove indentation from json output --- command/jsonplan/plan.go | 3 +-- command/jsonprovider/provider.go | 3 +-- command/jsonstate/state.go | 2 +- command/providers_schema.go | 8 +++++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/command/jsonplan/plan.go b/command/jsonplan/plan.go index 8adc8dd62..14107baa0 100644 --- a/command/jsonplan/plan.go +++ b/command/jsonplan/plan.go @@ -135,8 +135,7 @@ func Marshal( return nil, fmt.Errorf("error marshaling config: %s", err) } - // add some polish - ret, err := json.MarshalIndent(output, "", " ") + ret, err := json.Marshal(output) return ret, err } diff --git a/command/jsonprovider/provider.go b/command/jsonprovider/provider.go index cdadbf408..a6db90e93 100644 --- a/command/jsonprovider/provider.go +++ b/command/jsonprovider/provider.go @@ -42,8 +42,7 @@ func Marshal(s *terraform.Schemas) ([]byte, error) { providers.Schemas[k] = marshalProvider(v) } - // add some polish for the human consumers - ret, err := json.MarshalIndent(providers, "", " ") + ret, err := json.Marshal(providers) return ret, err } diff --git a/command/jsonstate/state.go b/command/jsonstate/state.go index aeb355dd8..5718129de 100644 --- a/command/jsonstate/state.go +++ b/command/jsonstate/state.go @@ -135,7 +135,7 @@ func Marshal(sf *statefile.File, schemas *terraform.Schemas) ([]byte, error) { return nil, err } - ret, err := json.MarshalIndent(output, "", " ") + ret, err := json.Marshal(output) return ret, err } diff --git a/command/providers_schema.go b/command/providers_schema.go index b18e413c8..73d540e59 100644 --- a/command/providers_schema.go +++ b/command/providers_schema.go @@ -45,6 +45,12 @@ func (c *ProvidersSchemaCommand) Run(args []string) int { return 1 } + // Check for user-supplied plugin path + if c.pluginPath, err = c.loadPluginPath(); err != nil { + c.Ui.Error(fmt.Sprintf("Error loading plugin path: %s", err)) + return 1 + } + var diags tfdiags.Diagnostics // Load the backend @@ -100,7 +106,7 @@ func (c *ProvidersSchemaCommand) Run(args []string) int { } const providersSchemaCommandHelp = ` -Usage: terraform providers schemas -json +Usage: terraform providers schema -json Prints out a json representation of the schemas for all providers used in the current configuration.