From b43690c01a239b4235d59edb3ec0a2b3ecb66db1 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 20 Mar 2018 18:44:44 -0700 Subject: [PATCH] tfdiags: Simple helper for creating "sourceless" diagnostics While diagnostics are primarily designed for reporting problems in configuration, they can also be used for errors and warnings about the environment Terraform is running in, such as inability to reach a remote service, etc. Function Sourceless makes it easy to produce such diagnostics with the customary summary/detail structure. When these diagnostics are rendered they will have no source code snippet and will instead just include the English-language content. --- tfdiags/sourceless.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tfdiags/sourceless.go diff --git a/tfdiags/sourceless.go b/tfdiags/sourceless.go new file mode 100644 index 0000000000..eaa27373db --- /dev/null +++ b/tfdiags/sourceless.go @@ -0,0 +1,13 @@ +package tfdiags + +// Sourceless creates and returns a diagnostic with no source location +// information. This is generally used for operational-type errors that are +// caused by or relate to the environment where Terraform is running rather +// than to the provided configuration. +func Sourceless(severity Severity, summary, detail string) Diagnostic { + return diagnosticBase{ + severity: severity, + summary: summary, + detail: detail, + } +}