Skip to content

commands/state_migrate: Implement JSON output - #38895

Draft
SarahFrench wants to merge 14 commits into
mainfrom
implement-state-migrate-json-output
Draft

commands/state_migrate: Implement JSON output#38895
SarahFrench wants to merge 14 commits into
mainfrom
implement-state-migrate-json-output

Conversation

@SarahFrench

Copy link
Copy Markdown
Member

WIP

Target Release

1.17.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench
SarahFrench force-pushed the implement-state-migrate-json-output branch from 8b998c7 to fee481f Compare July 20, 2026 18:53
@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Jul 20, 2026
@@ -0,0 +1,3 @@
{"@level":"info","@message":"Terraform 1.16.0-dev","@module":"terraform.ui","@timestamp":"2026-07-20T17:37:42.389757+01:00","terraform":"1.16.0-dev","type":"version","ui":"1.3"}
{"@level":"info","@message":"[reset][bold]Migrating state from backend \"local\" to backend \"local\"...[reset]","@module":"terraform.ui","@timestamp":"2026-07-20T17:37:42.392448+01:00"}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wherever a log is produced through state migrate's Log method we have human output formatting directives present in the JSON like this.

Also, it'd be nice to have the log type be unique to the message, similar to messages logged via the ProviderInstaller interface.

Base automatically changed from init-view-method-per-action to main July 21, 2026 10:08
@SarahFrench
SarahFrench force-pushed the implement-state-migrate-json-output branch from fee481f to 4a5c086 Compare August 4, 2026 15:05
…r formatting and printing messages to stdout
… `print` method.

This ensures that all methods perform the same actions on a message string:
* Trim whitespace
* Apply colour

Previously `prepareMessage` did this, which meant that methods that don't use `prepareMessage` were at risk of not formatting messages in the expected way.
…a view to log details about establishing trust for a PSS provider

This change also takes the PSS-related message codes/types and puts them in the message_types.go file, and avoids the 'message registry' in the init view implementation's file.
…ger use the init message registry when constructing the logged message.

Also, update the message type code. Before we matched what was in the init message registry, but now we match the conventions of message_types.go instead of having unnecessary `_message` suffixes.
…tion_start` message type, and how it's used as the value of the `type` field in JSON objects.
… if an unrecognised message code, or empty message contents, is encountered.

The `init` implementation of 'prepareMessage' doesn't panic and instead lets data fall through, which potentially can cover up defects (they'd otherwise only be detectable by tests asserting that log's contents). As `state migrate` is new I believe panicking is good as it helps us identify defects.
…nInfoWithKeyID` methods to `StateMigrateJSON` view
@SarahFrench
SarahFrench force-pushed the implement-state-migrate-json-output branch 2 times, most recently from 85e25d2 to 25ccbdb Compare August 5, 2026 14:23
@SarahFrench
SarahFrench force-pushed the implement-state-migrate-json-output branch from 25ccbdb to e7830bf Compare August 5, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Add this to your PR if the change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant