terraform-provider-gitea/vendor/github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/toproto/dynamic_value.go
Tobias Trabelsi e1266ebf64
Some checks reported errors
continuous-integration/drone/pr Build encountered an error
continuous-integration/drone/push Build encountered an error
updated GHA
Update to v2 SDK
updated dependencies
2022-08-06 16:21:18 +02:00

36 lines
1.1 KiB
Go

package toproto
import (
"fmt"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6"
"github.com/hashicorp/terraform-plugin-go/tftypes"
)
func DynamicValue(in *tfprotov6.DynamicValue) *tfplugin6.DynamicValue {
return &tfplugin6.DynamicValue{
Msgpack: in.MsgPack,
Json: in.JSON,
}
}
func CtyType(in tftypes.Type) ([]byte, error) {
switch {
case in.Is(tftypes.String), in.Is(tftypes.Bool), in.Is(tftypes.Number),
in.Is(tftypes.List{}), in.Is(tftypes.Map{}),
in.Is(tftypes.Set{}), in.Is(tftypes.Object{}),
in.Is(tftypes.Tuple{}), in.Is(tftypes.DynamicPseudoType):
return in.MarshalJSON() //nolint:staticcheck
}
return nil, fmt.Errorf("unknown type %s", in)
}
// 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.