-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting up private data for use in ReadResource RPC (#399)
Reference: #399
- Loading branch information
1 parent
827ee38
commit 48d25c6
Showing
11 changed files
with
165 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fromproto5 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/internal/privatestate" | ||
) | ||
|
||
// PrivateData returns the privatestate.Data for []byte. | ||
func PrivateData(ctx context.Context, input []byte) (privatestate.Data, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
output, err := privatestate.NewData(ctx, input) | ||
if err != nil { | ||
diags.AddError( | ||
"Unable to Create Private Data", | ||
"An unexpected error was encountered when creating the private data. "+ | ||
"This is always an issue in terraform-plugin-framework used to implement the provider and should be reported to the provider developers.\n\n"+ | ||
"Please report this to the provider developer:\n\n"+ | ||
"Private data create error.", | ||
) | ||
|
||
return privatestate.Data{}, diags | ||
} | ||
|
||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package fromproto6 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/internal/privatestate" | ||
) | ||
|
||
// PrivateData returns the privatestate.Data for []byte. | ||
func PrivateData(ctx context.Context, input []byte) (privatestate.Data, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
output, err := privatestate.NewData(ctx, input) | ||
if err != nil { | ||
diags.AddError( | ||
"Unable to Create Private Data", | ||
"An unexpected error was encountered when creating the private data. "+ | ||
"This is always an issue in terraform-plugin-framework used to implement the provider and should be reported to the provider developers.\n\n"+ | ||
"Please report this to the provider developer:\n\n"+ | ||
"Private data create error.", | ||
) | ||
|
||
return privatestate.Data{}, diags | ||
} | ||
|
||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package toproto5 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/internal/privatestate" | ||
) | ||
|
||
// PrivateData returns []byte from privateState.Data. | ||
func PrivateData(ctx context.Context, input privatestate.Data) ([]byte, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
output, err := input.Bytes(ctx) | ||
if err != nil { | ||
diags.AddError( | ||
"Unable to Convert Private Data", | ||
"An unexpected error was encountered when converting the private data. "+ | ||
"This is always an issue in terraform-plugin-framework used to implement the provider and should be reported to the provider developers.\n\n"+ | ||
"Please report this to the provider developer:\n\n"+ | ||
"Private data convert error.", | ||
) | ||
|
||
return nil, diags | ||
} | ||
|
||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package toproto6 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/internal/privatestate" | ||
) | ||
|
||
// PrivateData returns []byte from privateState.Data. | ||
func PrivateData(ctx context.Context, input privatestate.Data) ([]byte, diag.Diagnostics) { | ||
var diags diag.Diagnostics | ||
|
||
output, err := input.Bytes(ctx) | ||
if err != nil { | ||
diags.AddError( | ||
"Unable to Convert Private Data", | ||
"An unexpected error was encountered when converting the private data. "+ | ||
"This is always an issue in terraform-plugin-framework used to implement the provider and should be reported to the provider developers.\n\n"+ | ||
"Please report this to the provider developer:\n\n"+ | ||
"Private data convert error.", | ||
) | ||
|
||
return nil, diags | ||
} | ||
|
||
return output, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters