github.com/opentofu/opentofu@v1.7.1/internal/tofu/diagnostics.go (about) 1 // Copyright (c) The OpenTofu Authors 2 // SPDX-License-Identifier: MPL-2.0 3 // Copyright (c) 2023 HashiCorp, Inc. 4 // SPDX-License-Identifier: MPL-2.0 5 6 package tofu 7 8 import ( 9 "github.com/opentofu/opentofu/internal/tfdiags" 10 ) 11 12 // This file contains some package-local helpers for working with diagnostics. 13 // For the main diagnostics API, see the separate "tfdiags" package. 14 15 // diagnosticCausedByUnknown is an implementation of 16 // tfdiags.DiagnosticExtraBecauseUnknown which we can use in the "Extra" field 17 // of a diagnostic to indicate that the problem was caused by unknown values 18 // being involved in an expression evaluation. 19 // 20 // When using this, set the Extra to diagnosticCausedByUnknown(true) and also 21 // populate the EvalContext and Expression fields of the diagnostic so that 22 // the diagnostic renderer can use all of that information together to assist 23 // the user in understanding what was unknown. 24 type diagnosticCausedByUnknown bool 25 26 var _ tfdiags.DiagnosticExtraBecauseUnknown = diagnosticCausedByUnknown(true) 27 28 func (e diagnosticCausedByUnknown) DiagnosticCausedByUnknown() bool { 29 return bool(e) 30 } 31 32 // diagnosticCausedBySensitive is an implementation of 33 // tfdiags.DiagnosticExtraBecauseSensitive which we can use in the "Extra" field 34 // of a diagnostic to indicate that the problem was caused by sensitive values 35 // being involved in an expression evaluation. 36 // 37 // When using this, set the Extra to diagnosticCausedBySensitive(true) and also 38 // populate the EvalContext and Expression fields of the diagnostic so that 39 // the diagnostic renderer can use all of that information together to assist 40 // the user in understanding what was sensitive. 41 type diagnosticCausedBySensitive bool 42 43 var _ tfdiags.DiagnosticExtraBecauseSensitive = diagnosticCausedBySensitive(true) 44 45 func (e diagnosticCausedBySensitive) DiagnosticCausedBySensitive() bool { 46 return bool(e) 47 }