910ccdb092
Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.26.1 to 2.27.0. - [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases) - [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/terraform-plugin-sdk/compare/v2.26.1...v2.27.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package fromproto
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
|
|
"github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6"
|
|
)
|
|
|
|
func Diagnostic(in *tfplugin6.Diagnostic) (*tfprotov6.Diagnostic, error) {
|
|
diag := &tfprotov6.Diagnostic{
|
|
Severity: DiagnosticSeverity(in.Severity),
|
|
Summary: in.Summary,
|
|
Detail: in.Detail,
|
|
}
|
|
if in.Attribute != nil {
|
|
attr, err := AttributePath(in.Attribute)
|
|
if err != nil {
|
|
return diag, err
|
|
}
|
|
diag.Attribute = attr
|
|
}
|
|
return diag, nil
|
|
}
|
|
|
|
func DiagnosticSeverity(in tfplugin6.Diagnostic_Severity) tfprotov6.DiagnosticSeverity {
|
|
return tfprotov6.DiagnosticSeverity(in)
|
|
}
|
|
|
|
func Diagnostics(in []*tfplugin6.Diagnostic) ([]*tfprotov6.Diagnostic, error) {
|
|
diagnostics := make([]*tfprotov6.Diagnostic, 0, len(in))
|
|
for _, diag := range in {
|
|
if diag == nil {
|
|
diagnostics = append(diagnostics, nil)
|
|
continue
|
|
}
|
|
d, err := Diagnostic(diag)
|
|
if err != nil {
|
|
return diagnostics, err
|
|
}
|
|
diagnostics = append(diagnostics, d)
|
|
}
|
|
return diagnostics, nil
|
|
}
|