terraform-provider-gitea/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/toproto/diagnostic.go

51 lines
1.4 KiB
Go
Raw Normal View History

package toproto
import (
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5"
)
func Diagnostic(in *tfprotov5.Diagnostic) (*tfplugin5.Diagnostic, error) {
diag := &tfplugin5.Diagnostic{
Severity: Diagnostic_Severity(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 Diagnostic_Severity(in tfprotov5.DiagnosticSeverity) tfplugin5.Diagnostic_Severity {
return tfplugin5.Diagnostic_Severity(in)
}
func Diagnostics(in []*tfprotov5.Diagnostic) ([]*tfplugin5.Diagnostic, error) {
diagnostics := make([]*tfplugin5.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
}
// we have to say this next thing to get golint to stop yelling at us about the
// underscores in the function names. We want the function names to match
// actually-generated code, so it feels like fair play. It's just a shame we
// lose golint for the entire file.
//
// This file is not actually generated. You can edit it. Ignore this next line.
// Code generated by hand ignore this next bit DO NOT EDIT.