2019-01-11 18:13:55 -05:00
|
|
|
{
|
2021-09-01 11:17:13 -04:00
|
|
|
"format_version": "1.0",
|
terraform: Plans can be "complete" and "applyable"
These ideas are both already implied by some logic elsewhere in the system,
but until now we didn't have the decision logic centralized in a single
place that could therefore evolve over time without necessarily always
updating every caller together.
We'll now have the modules runtime produce its own boolean ruling about
each characteristic, which callers can rely on for the mechanical
decision-making of whether to offer the user an "approve" prompt, and
whether to remind the user after apply that it was an incomplete plan
that will probably therefore need at least one more plan/apply round to
converge.
The "Applyable" flag directly replaces the previous method Plan.CanApply,
with equivalent logic. Making this a field instead of a method means that
we can freeze it as part of a saved plan, rather than recalculating it
when we reload the plan, and we can export the field value in our export
formats like JSON while ensuring it'll always be consistent with what
Terraform is using internally.
Callers can (and should) still use other context in the plan to return
more tailored messages for specific situations they already know about
that might be useful to users, but with these flags as a baseline callers
can now just fall back to a generic presentation when encountering a
situation they don't yet understand, rather than making the wrong decision
and causing something strange to happen. That is: a lack of awareness of
a new rule will now cause just a generic message in the UI, rather than
incorrect behavior.
This commit mostly just deals with populating the flags, and then all of
the direct consequences of that on our various tests. Further changes to
actually make use of these flags elsewhere in the system will follow in
later commits, both in this repository and in other repositories.
2024-02-08 14:07:55 -05:00
|
|
|
"applyable": false,
|
|
|
|
|
"complete": true,
|
2019-02-11 16:17:03 -05:00
|
|
|
"variables": {
|
|
|
|
|
"test_var": {
|
|
|
|
|
"value": "bar"
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-11 18:13:55 -05:00
|
|
|
"planned_values": {
|
|
|
|
|
"outputs": {
|
|
|
|
|
"test": {
|
|
|
|
|
"sensitive": false,
|
json-output: Add output type to JSON format
Previously the supported JSON plan and state formats included only
serialized output values, which was a lossy serialization of the
Terraform type system. This commit adds a type field in the usual cty
JSON format, which allows reconstitution of the original value.
For example, previously a list(string) and a set(string) containing the
same values were indistinguishable. This change serializes these as
follows:
{
"value": ["a","b","c"],
"type": ["list","string"]
}
and:
{
"value": ["a","b","c"],
"type": ["set","string"]
}
2022-04-27 13:08:43 -04:00
|
|
|
"type": "string",
|
2019-01-11 18:13:55 -05:00
|
|
|
"value": "bar"
|
|
|
|
|
}
|
|
|
|
|
},
|
mildwonkey/b-show-state (#20032)
* command/show: properly marshal attribute values to json
marshalAttributeValues in jsonstate and jsonplan packages was returning
a cty.Value, which json/encoding could not marshal. These functions now
convert those cty.Values into json.RawMessages.
* command/jsonplan: planned values should include resources that are not changing
* command/jsonplan: return a filtered list of proposed 'after' attributes
Previously, proposed 'after' attributes were not being shown if the
attributes were not WhollyKnown. jsonplan now iterates through all the
`after` attributes, omitting those which are not wholly known.
The same was roughly true for after_unknown, and that structure is now
correctly populated. In the future we may choose to filter the
after_unknown structure to _only_ display unknown attributes, instead of
all attributes.
* command/jsonconfig: use a unique key for providers so that aliased
providers don't get munged together
This now uses the same "provider" key from configs.Module, e.g.
`providername.provideralias`.
* command/jsonplan: unknownAsBool needs to iterate through objects that are not wholly known
* command/jsonplan: properly display actions as strings according to the RFC,
instead of a plans.Action string.
For example:
a plans.Action string DeleteThenCreate should be displayed as ["delete",
"create"]
Tests have been updated to reflect this.
* command/jsonplan: return "null" for unknown list items.
The length of a list could be meaningful on its own, so we will turn
unknowns into "null". The same is less likely true for maps and objects,
so we will continue to omit unknown values from those.
2019-01-23 14:46:53 -05:00
|
|
|
"root_module": {
|
|
|
|
|
"resources": [
|
|
|
|
|
{
|
|
|
|
|
"address": "test_instance.test",
|
|
|
|
|
"mode": "managed",
|
|
|
|
|
"type": "test_instance",
|
|
|
|
|
"name": "test",
|
2020-04-02 12:58:44 -04:00
|
|
|
"provider_name": "registry.terraform.io/hashicorp/test",
|
mildwonkey/b-show-state (#20032)
* command/show: properly marshal attribute values to json
marshalAttributeValues in jsonstate and jsonplan packages was returning
a cty.Value, which json/encoding could not marshal. These functions now
convert those cty.Values into json.RawMessages.
* command/jsonplan: planned values should include resources that are not changing
* command/jsonplan: return a filtered list of proposed 'after' attributes
Previously, proposed 'after' attributes were not being shown if the
attributes were not WhollyKnown. jsonplan now iterates through all the
`after` attributes, omitting those which are not wholly known.
The same was roughly true for after_unknown, and that structure is now
correctly populated. In the future we may choose to filter the
after_unknown structure to _only_ display unknown attributes, instead of
all attributes.
* command/jsonconfig: use a unique key for providers so that aliased
providers don't get munged together
This now uses the same "provider" key from configs.Module, e.g.
`providername.provideralias`.
* command/jsonplan: unknownAsBool needs to iterate through objects that are not wholly known
* command/jsonplan: properly display actions as strings according to the RFC,
instead of a plans.Action string.
For example:
a plans.Action string DeleteThenCreate should be displayed as ["delete",
"create"]
Tests have been updated to reflect this.
* command/jsonplan: return "null" for unknown list items.
The length of a list could be meaningful on its own, so we will turn
unknowns into "null". The same is less likely true for maps and objects,
so we will continue to omit unknown values from those.
2019-01-23 14:46:53 -05:00
|
|
|
"schema_version": 0,
|
|
|
|
|
"values": {
|
|
|
|
|
"ami": "bar",
|
2019-02-08 14:58:08 -05:00
|
|
|
"id": "placeholder"
|
2021-06-14 09:19:13 -04:00
|
|
|
},
|
|
|
|
|
"sensitive_values": {}
|
mildwonkey/b-show-state (#20032)
* command/show: properly marshal attribute values to json
marshalAttributeValues in jsonstate and jsonplan packages was returning
a cty.Value, which json/encoding could not marshal. These functions now
convert those cty.Values into json.RawMessages.
* command/jsonplan: planned values should include resources that are not changing
* command/jsonplan: return a filtered list of proposed 'after' attributes
Previously, proposed 'after' attributes were not being shown if the
attributes were not WhollyKnown. jsonplan now iterates through all the
`after` attributes, omitting those which are not wholly known.
The same was roughly true for after_unknown, and that structure is now
correctly populated. In the future we may choose to filter the
after_unknown structure to _only_ display unknown attributes, instead of
all attributes.
* command/jsonconfig: use a unique key for providers so that aliased
providers don't get munged together
This now uses the same "provider" key from configs.Module, e.g.
`providername.provideralias`.
* command/jsonplan: unknownAsBool needs to iterate through objects that are not wholly known
* command/jsonplan: properly display actions as strings according to the RFC,
instead of a plans.Action string.
For example:
a plans.Action string DeleteThenCreate should be displayed as ["delete",
"create"]
Tests have been updated to reflect this.
* command/jsonplan: return "null" for unknown list items.
The length of a list could be meaningful on its own, so we will turn
unknowns into "null". The same is less likely true for maps and objects,
so we will continue to omit unknown values from those.
2019-01-23 14:46:53 -05:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
2019-01-11 18:13:55 -05:00
|
|
|
},
|
|
|
|
|
"resource_changes": [
|
|
|
|
|
{
|
|
|
|
|
"address": "test_instance.test",
|
|
|
|
|
"mode": "managed",
|
|
|
|
|
"type": "test_instance",
|
2020-04-02 12:58:44 -04:00
|
|
|
"provider_name": "registry.terraform.io/hashicorp/test",
|
2019-01-11 18:13:55 -05:00
|
|
|
"name": "test",
|
|
|
|
|
"change": {
|
|
|
|
|
"actions": [
|
mildwonkey/b-show-state (#20032)
* command/show: properly marshal attribute values to json
marshalAttributeValues in jsonstate and jsonplan packages was returning
a cty.Value, which json/encoding could not marshal. These functions now
convert those cty.Values into json.RawMessages.
* command/jsonplan: planned values should include resources that are not changing
* command/jsonplan: return a filtered list of proposed 'after' attributes
Previously, proposed 'after' attributes were not being shown if the
attributes were not WhollyKnown. jsonplan now iterates through all the
`after` attributes, omitting those which are not wholly known.
The same was roughly true for after_unknown, and that structure is now
correctly populated. In the future we may choose to filter the
after_unknown structure to _only_ display unknown attributes, instead of
all attributes.
* command/jsonconfig: use a unique key for providers so that aliased
providers don't get munged together
This now uses the same "provider" key from configs.Module, e.g.
`providername.provideralias`.
* command/jsonplan: unknownAsBool needs to iterate through objects that are not wholly known
* command/jsonplan: properly display actions as strings according to the RFC,
instead of a plans.Action string.
For example:
a plans.Action string DeleteThenCreate should be displayed as ["delete",
"create"]
Tests have been updated to reflect this.
* command/jsonplan: return "null" for unknown list items.
The length of a list could be meaningful on its own, so we will turn
unknowns into "null". The same is less likely true for maps and objects,
so we will continue to omit unknown values from those.
2019-01-23 14:46:53 -05:00
|
|
|
"no-op"
|
2019-01-11 18:13:55 -05:00
|
|
|
],
|
|
|
|
|
"before": {
|
|
|
|
|
"ami": "bar",
|
2019-02-08 14:58:08 -05:00
|
|
|
"id": "placeholder"
|
2019-01-11 18:13:55 -05:00
|
|
|
},
|
|
|
|
|
"after": {
|
|
|
|
|
"ami": "bar",
|
2019-02-08 14:58:08 -05:00
|
|
|
"id": "placeholder"
|
2019-01-11 18:13:55 -05:00
|
|
|
},
|
2021-03-25 11:41:49 -04:00
|
|
|
"after_unknown": {},
|
|
|
|
|
"after_sensitive": {},
|
|
|
|
|
"before_sensitive": {}
|
2019-01-11 18:13:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
"output_changes": {
|
|
|
|
|
"test": {
|
|
|
|
|
"actions": [
|
2020-10-09 19:45:31 -04:00
|
|
|
"no-op"
|
2019-01-11 18:13:55 -05:00
|
|
|
],
|
2020-10-09 19:45:31 -04:00
|
|
|
"before": "bar",
|
2019-01-11 18:13:55 -05:00
|
|
|
"after": "bar",
|
2021-03-26 19:21:40 -04:00
|
|
|
"after_unknown": false,
|
|
|
|
|
"before_sensitive": false,
|
|
|
|
|
"after_sensitive": false
|
2019-01-11 18:13:55 -05:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"prior_state": {
|
2021-09-01 11:17:13 -04:00
|
|
|
"format_version": "1.0",
|
2019-01-11 18:13:55 -05:00
|
|
|
"values": {
|
2019-06-05 07:29:02 -04:00
|
|
|
"outputs": {
|
|
|
|
|
"test": {
|
|
|
|
|
"sensitive": false,
|
json-output: Add output type to JSON format
Previously the supported JSON plan and state formats included only
serialized output values, which was a lossy serialization of the
Terraform type system. This commit adds a type field in the usual cty
JSON format, which allows reconstitution of the original value.
For example, previously a list(string) and a set(string) containing the
same values were indistinguishable. This change serializes these as
follows:
{
"value": ["a","b","c"],
"type": ["list","string"]
}
and:
{
"value": ["a","b","c"],
"type": ["set","string"]
}
2022-04-27 13:08:43 -04:00
|
|
|
"type": "string",
|
2019-06-05 07:29:02 -04:00
|
|
|
"value": "bar"
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-11 18:13:55 -05:00
|
|
|
"root_module": {
|
|
|
|
|
"resources": [
|
|
|
|
|
{
|
|
|
|
|
"address": "test_instance.test",
|
|
|
|
|
"mode": "managed",
|
|
|
|
|
"type": "test_instance",
|
|
|
|
|
"name": "test",
|
2019-02-12 15:03:07 -05:00
|
|
|
"schema_version": 0,
|
2020-04-02 12:58:44 -04:00
|
|
|
"provider_name": "registry.terraform.io/hashicorp/test",
|
2019-01-11 18:13:55 -05:00
|
|
|
"values": {
|
2019-02-12 15:03:07 -05:00
|
|
|
"ami": "bar",
|
|
|
|
|
"id": "placeholder"
|
2021-06-14 09:19:13 -04:00
|
|
|
},
|
|
|
|
|
"sensitive_values": {}
|
2019-01-11 18:13:55 -05:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"configuration": {
|
2022-02-18 11:15:58 -05:00
|
|
|
"provider_config": {
|
|
|
|
|
"test": {
|
|
|
|
|
"name": "test",
|
|
|
|
|
"full_name": "registry.terraform.io/hashicorp/test"
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-01-11 18:13:55 -05:00
|
|
|
"root_module": {
|
|
|
|
|
"outputs": {
|
|
|
|
|
"test": {
|
|
|
|
|
"expression": {
|
|
|
|
|
"references": [
|
|
|
|
|
"var.test_var"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"resources": [
|
|
|
|
|
{
|
|
|
|
|
"address": "test_instance.test",
|
|
|
|
|
"mode": "managed",
|
|
|
|
|
"type": "test_instance",
|
|
|
|
|
"name": "test",
|
2019-02-20 17:27:49 -05:00
|
|
|
"provider_config_key": "test",
|
2019-01-11 18:13:55 -05:00
|
|
|
"schema_version": 0,
|
2019-02-12 15:03:07 -05:00
|
|
|
"expressions": {
|
|
|
|
|
"ami": {
|
|
|
|
|
"references": [
|
|
|
|
|
"var.test_var"
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-11 18:13:55 -05:00
|
|
|
}
|
2019-02-12 15:03:07 -05:00
|
|
|
],
|
|
|
|
|
"variables": {
|
|
|
|
|
"test_var": {
|
|
|
|
|
"default": "bar"
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-11 18:13:55 -05:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-02 12:58:44 -04:00
|
|
|
}
|