Merge pull request #29550 from hashicorp/alisdair/json-format-version-1.0

json-output: Release format version 1.0
This commit is contained in:
Alisdair McDiarmid 2021-10-06 11:20:46 -04:00 committed by GitHub
commit 09edbba81f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 103 additions and 63 deletions

View File

@ -22,7 +22,7 @@ import (
// FormatVersion represents the version of the json format and will be // FormatVersion represents the version of the json format and will be
// incremented for any change to this format that requires changes to a // incremented for any change to this format that requires changes to a
// consuming parser. // consuming parser.
const FormatVersion = "0.2" const FormatVersion = "1.0"
// Plan is the top-level representation of the json format of a plan. It includes // Plan is the top-level representation of the json format of a plan. It includes
// the complete config and current state. // the complete config and current state.

View File

@ -9,7 +9,7 @@ import (
// FormatVersion represents the version of the json format and will be // FormatVersion represents the version of the json format and will be
// incremented for any change to this format that requires changes to a // incremented for any change to this format that requires changes to a
// consuming parser. // consuming parser.
const FormatVersion = "0.2" const FormatVersion = "1.0"
// providers is the top-level object returned when exporting provider schemas // providers is the top-level object returned when exporting provider schemas
type providers struct { type providers struct {

View File

@ -18,7 +18,7 @@ import (
// FormatVersion represents the version of the json format and will be // FormatVersion represents the version of the json format and will be
// incremented for any change to this format that requires changes to a // incremented for any change to this format that requires changes to a
// consuming parser. // consuming parser.
const FormatVersion = "0.2" const FormatVersion = "1.0"
// state is the top-level representation of the json format of a terraform // state is the top-level representation of the json format of a terraform
// state. // state.

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"provider_schemas": { "provider_schemas": {
"registry.terraform.io/hashicorp/test": { "registry.terraform.io/hashicorp/test": {
"provider": { "provider": {

View File

@ -1,3 +1,3 @@
{ {
"format_version": "0.2" "format_version": "1.0"
} }

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"provider_schemas": { "provider_schemas": {
"registry.terraform.io/hashicorp/test": { "registry.terraform.io/hashicorp/test": {
"provider": { "provider": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -66,7 +66,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.12.0", "terraform_version": "0.12.0",
"values": { "values": {
"root_module": { "root_module": {

View File

@ -1,3 +1,3 @@
{ {
"format_version": "0.2" "format_version": "1.0"
} }

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.12.0", "terraform_version": "0.12.0",
"values": { "values": {
"outputs": { "outputs": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.14.0", "terraform_version": "0.14.0",
"values": { "values": {
"root_module": { "root_module": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -57,7 +57,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -89,7 +89,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -68,7 +68,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"root_module": { "root_module": {
"resources": [ "resources": [
@ -106,7 +106,7 @@
} }
], ],
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"root_module": { "root_module": {
"resources": [ "resources": [

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.13.1-dev", "terraform_version": "0.13.1-dev",
"planned_values": { "planned_values": {
"root_module": { "root_module": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"outputs": { "outputs": {
"test": { "test": {
@ -74,7 +74,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"root_module": { "root_module": {
"resources": [ "resources": [
@ -108,7 +108,7 @@
} }
], ],
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"root_module": { "root_module": {
"resources": [ "resources": [

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"root_module": { "root_module": {
"resources": [ "resources": [
@ -46,7 +46,7 @@
} }
], ],
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"root_module": { "root_module": {
"resources": [ "resources": [

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.13.0", "terraform_version": "0.13.0",
"variables": { "variables": {
"test_var": { "test_var": {
@ -107,7 +107,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"terraform_version": "0.13.0", "terraform_version": "0.13.0",
"values": { "values": {
"outputs": { "outputs": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"root_module": { "root_module": {
"child_modules": [ "child_modules": [

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -57,7 +57,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "bar" "value": "bar"
@ -57,7 +57,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"planned_values": { "planned_values": {
"root_module": { "root_module": {
"resources": [ "resources": [
@ -48,7 +48,7 @@
} }
], ],
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"root_module": { "root_module": {
"resources": [ "resources": [

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.2", "format_version": "1.0",
"variables": { "variables": {
"test_var": { "test_var": {
"value": "boop" "value": "boop"
@ -69,7 +69,7 @@
} }
}, },
"prior_state": { "prior_state": {
"format_version": "0.2", "format_version": "1.0",
"values": { "values": {
"outputs": { "outputs": {
"test": { "test": {

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 4, "error_count": 4,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 2, "error_count": 2,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": true, "valid": true,
"error_count": 0, "error_count": 0,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 1, "error_count": 1,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": false, "valid": false,
"error_count": 2, "error_count": 2,
"warning_count": 0, "warning_count": 0,

View File

@ -1,5 +1,5 @@
{ {
"format_version": "0.1", "format_version": "1.0",
"valid": true, "valid": true,
"error_count": 0, "error_count": 0,
"warning_count": 0, "warning_count": 0,

View File

@ -13,7 +13,7 @@ import (
// This version describes the schema of JSON UI messages. This version must be // This version describes the schema of JSON UI messages. This version must be
// updated after making any changes to this view, the jsonHook, or any of the // updated after making any changes to this view, the jsonHook, or any of the
// command/views/json package. // command/views/json package.
const JSON_UI_VERSION = "0.1.0" const JSON_UI_VERSION = "1.0"
func NewJSONView(view *View) *JSONView { func NewJSONView(view *View) *JSONView {
log := hclog.New(&hclog.LoggerOptions{ log := hclog.New(&hclog.LoggerOptions{

View File

@ -81,7 +81,7 @@ func (v *ValidateJSON) Results(diags tfdiags.Diagnostics) int {
// FormatVersion represents the version of the json format and will be // FormatVersion represents the version of the json format and will be
// incremented for any change to this format that requires changes to a // incremented for any change to this format that requires changes to a
// consuming parser. // consuming parser.
const FormatVersion = "0.1" const FormatVersion = "1.0"
type Output struct { type Output struct {
FormatVersion string `json:"format_version"` FormatVersion string `json:"format_version"`

View File

@ -23,7 +23,18 @@ The list of available flags are:
Please note that, at this time, the `-json` flag is a _required_ option. In future releases, this command will be extended to allow for additional options. Please note that, at this time, the `-json` flag is a _required_ option. In future releases, this command will be extended to allow for additional options.
-> **Note:** The output includes a `format_version` key, which currently has major version zero to indicate that the format is experimental and subject to change. A future version will assign a non-zero major version and make stronger promises about compatibility. We do not anticipate any significant breaking changes to the format before its first major version, however. The output includes a `format_version` key, which as of Terraform 1.1.0 has
value `"1.0"`. The semantics of this version are:
- We will increment the minor version, e.g. `"1.1"`, for backward-compatible
changes or additions. Ignore any object properties with unrecognized names to
remain forward-compatible with future minor versions.
- We will increment the major version, e.g. `"2.0"`, for changes that are not
backward-compatible. Reject any input which reports an unsupported major
version.
We will introduce new major versions only within the bounds of
[the Terraform 1.0 Compatibility Promises](https://www.terraform.io/docs/language/v1-compatibility-promises.html).
## Format Summary ## Format Summary
@ -41,7 +52,7 @@ The JSON output format consists of the following objects and sub-objects:
```javascript ```javascript
{ {
"format_version": "0.1", "format_version": "1.0",
// "provider_schemas" describes the provider schemas for all // "provider_schemas" describes the provider schemas for all
// providers throughout the configuration tree. // providers throughout the configuration tree.

View File

@ -57,11 +57,18 @@ to the JSON output setting. For that reason, external software consuming
Terraform's output should be prepared to find data on stdout that _isn't_ valid Terraform's output should be prepared to find data on stdout that _isn't_ valid
JSON, which it should then treat as a generic error case. JSON, which it should then treat as a generic error case.
**Note:** The output includes a `format_version` key, which currently has major The output includes a `format_version` key, which as of Terraform 1.1.0 has
version zero to indicate that the format is experimental and subject to change. value `"1.0"`. The semantics of this version are:
A future version will assign a non-zero major version and make stronger
promises about compatibility. We do not anticipate any significant breaking - We will increment the minor version, e.g. `"1.1"`, for backward-compatible
changes to the format before its first major version, however. changes or additions. Ignore any object properties with unrecognized names to
remain forward-compatible with future minor versions.
- We will increment the major version, e.g. `"2.0"`, for changes that are not
backward-compatible. Reject any input which reports an unsupported major
version.
We will introduce new major versions only within the bounds of
[the Terraform 1.0 Compatibility Promises](https://www.terraform.io/docs/language/v1-compatibility-promises.html).
In the normal case, Terraform will print a JSON object to the standard output In the normal case, Terraform will print a JSON object to the standard output
stream. The top-level JSON object will have the following properties: stream. The top-level JSON object will have the following properties:

View File

@ -16,7 +16,18 @@ Since the format of plan files isn't suited for use with external tools (and lik
Use `terraform show -json <FILE>` to generate a JSON representation of a plan or state file. See [the `terraform show` documentation](/docs/cli/commands/show.html) for more details. Use `terraform show -json <FILE>` to generate a JSON representation of a plan or state file. See [the `terraform show` documentation](/docs/cli/commands/show.html) for more details.
-> **Note:** The output includes a `format_version` key, which currently has major version zero to indicate that the format is experimental and subject to change. A future version will assign a non-zero major version and make stronger promises about compatibility. We do not anticipate any significant breaking changes to the format before its first major version, however. The output includes a `format_version` key, which as of Terraform 1.1.0 has
value `"1.0"`. The semantics of this version are:
- We will increment the minor version, e.g. `"1.1"`, for backward-compatible
changes or additions. Ignore any object properties with unrecognized names to
remain forward-compatible with future minor versions.
- We will increment the major version, e.g. `"2.0"`, for changes that are not
backward-compatible. Reject any input which reports an unsupported major
version.
We will introduce new major versions only within the bounds of
[the Terraform 1.0 Compatibility Promises](https://www.terraform.io/docs/language/v1-compatibility-promises.html).
## Format Summary ## Format Summary
@ -60,7 +71,7 @@ For ease of consumption by callers, the plan representation includes a partial r
```javascript ```javascript
{ {
"format_version": "0.2", "format_version": "1.0",
// "prior_state" is a representation of the state that the configuration is // "prior_state" is a representation of the state that the configuration is
// being applied to, using the state representation described above. // being applied to, using the state representation described above.

View File

@ -14,7 +14,18 @@ By default, many Terraform commands display UI output as unstructured text, inte
For long-running commands such as `plan`, `apply`, and `refresh`, the `-json` flag outputs a stream of JSON UI messages, one per line. These can be processed one message at a time, with integrating software filtering, combining, or modifying the output as desired. For long-running commands such as `plan`, `apply`, and `refresh`, the `-json` flag outputs a stream of JSON UI messages, one per line. These can be processed one message at a time, with integrating software filtering, combining, or modifying the output as desired.
-> **Note:** The first message output has type `version`, and includes a `ui` key, which currently has major version zero to indicate that the format is experimental and subject to change. A future version will assign a non-zero major version and make stronger promises about compatibility. We do not anticipate any significant breaking changes to the format before its first major version, however. The first message output has type `version`, and includes a `ui` key, which as of Terraform 1.1.0 has
value `"1.0"`. The semantics of this version are:
- We will increment the minor version, e.g. `"1.1"`, for backward-compatible
changes or additions. Ignore any object properties with unrecognized names to
remain forward-compatible with future minor versions.
- We will increment the major version, e.g. `"2.0"`, for changes that are not
backward-compatible. Reject any input which reports an unsupported major
version.
We will introduce new major versions only within the bounds of
[the Terraform 1.0 Compatibility Promises](https://www.terraform.io/docs/language/v1-compatibility-promises.html).
## Sample JSON Output ## Sample JSON Output