From 71dec301a26e0b67d89209180c2fbf2b08e00338 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Wed, 24 Aug 2022 11:33:19 -0700 Subject: [PATCH] command/jsonchecks: Mark check result objects as experimental This is a clumsy way to do this, but a pragmatic way to inform potential consumers that this part of the format is not yet finalized without having to read the docs to see our warning about that. We need to get some practical experience with a few different consumers making use of this format before we can be confident that it's designed appropriately. We're not _expecting_ to break it, but we'd like to leave the opportunity open in case we quickly learn that there's something non-ideal about this design. --- internal/command/jsonchecks/checks.go | 8 ++++++++ internal/command/jsonchecks/checks_test.go | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/internal/command/jsonchecks/checks.go b/internal/command/jsonchecks/checks.go index 8590da9be2..892dcba325 100644 --- a/internal/command/jsonchecks/checks.go +++ b/internal/command/jsonchecks/checks.go @@ -70,6 +70,8 @@ func MarshalCheckStates(results *states.CheckResults) []byte { // object in the configuration even if Terraform Core encountered an error // before being able to determine the dynamic instances of the checkable object. type checkResultStatic struct { + ExperimentalNote experimentalNote `json:"//"` + // Address is the address of the checkable object this result relates to. Address staticObjectAddr `json:"address"` @@ -114,3 +116,9 @@ type checkProblem struct { // intentionally an object to allow us to add other data over time, such // as the source location where the failing condition was defined. } + +type experimentalNote struct{} + +func (n experimentalNote) MarshalJSON() ([]byte, error) { + return []byte(`"EXPERIMENTAL: see docs for details"`), nil +} diff --git a/internal/command/jsonchecks/checks_test.go b/internal/command/jsonchecks/checks_test.go index fd8dba8b80..6e0f52da4f 100644 --- a/internal/command/jsonchecks/checks_test.go +++ b/internal/command/jsonchecks/checks_test.go @@ -94,6 +94,7 @@ func TestMarshalCheckStates(t *testing.T) { }, []any{ map[string]any{ + "//": "EXPERIMENTAL: see docs for details", "address": map[string]any{ "kind": "output_value", "module": "module.child", @@ -117,6 +118,7 @@ func TestMarshalCheckStates(t *testing.T) { "status": "fail", }, map[string]any{ + "//": "EXPERIMENTAL: see docs for details", "address": map[string]any{ "kind": "resource", "mode": "managed", @@ -142,6 +144,7 @@ func TestMarshalCheckStates(t *testing.T) { "status": "fail", }, map[string]any{ + "//": "EXPERIMENTAL: see docs for details", "address": map[string]any{ "kind": "output_value", "name": "a", @@ -158,6 +161,7 @@ func TestMarshalCheckStates(t *testing.T) { "status": "fail", }, map[string]any{ + "//": "EXPERIMENTAL: see docs for details", "address": map[string]any{ "kind": "resource", "mode": "managed",