From 4e04372891d41cab6e6d43df01f7fde4db925524 Mon Sep 17 00:00:00 2001 From: panic Date: Thu, 3 Oct 2024 15:37:41 +0300 Subject: [PATCH] Update framework wrappers methods support --- .../datasource/wrapper_data_source.go | 4 +++- .../framework/resource/wrapper_resource.go | 22 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/vkcs/internal/providerwrapper/framework/datasource/wrapper_data_source.go b/vkcs/internal/providerwrapper/framework/datasource/wrapper_data_source.go index 3f6d21ad..a3e0d619 100644 --- a/vkcs/internal/providerwrapper/framework/datasource/wrapper_data_source.go +++ b/vkcs/internal/providerwrapper/framework/datasource/wrapper_data_source.go @@ -9,7 +9,9 @@ import ( ) var ( - _ datasource.DataSource = &DataSourceWrapper{} + _ datasource.DataSource = (*DataSourceWrapper)(nil) + _ datasource.DataSourceWithConfigValidators = (*DataSourceWrapper)(nil) + _ datasource.DataSourceWithValidateConfig = (*DataSourceWrapper)(nil) ) func NewDataSourceWrapper(dataSource datasource.DataSource, dataSourceJSON jsonschema.ResourceJSON) *DataSourceWrapper { diff --git a/vkcs/internal/providerwrapper/framework/resource/wrapper_resource.go b/vkcs/internal/providerwrapper/framework/resource/wrapper_resource.go index ebb687ca..f049eaa2 100644 --- a/vkcs/internal/providerwrapper/framework/resource/wrapper_resource.go +++ b/vkcs/internal/providerwrapper/framework/resource/wrapper_resource.go @@ -9,7 +9,14 @@ import ( ) var ( - _ resource.Resource = &ResourceWrapper{} + _ resource.Resource = (*ResourceWrapper)(nil) + _ resource.ResourceWithConfigValidators = (*ResourceWrapper)(nil) + _ resource.ResourceWithConfigure = (*ResourceWrapper)(nil) + _ resource.ResourceWithImportState = (*ResourceWrapper)(nil) + _ resource.ResourceWithModifyPlan = (*ResourceWrapper)(nil) + _ resource.ResourceWithMoveState = (*ResourceWrapper)(nil) + _ resource.ResourceWithUpgradeState = (*ResourceWrapper)(nil) + _ resource.ResourceWithValidateConfig = (*ResourceWrapper)(nil) ) func NewResourceWrapper(resource resource.Resource, resourceJSON jsonschema.ResourceJSON) *ResourceWrapper { @@ -79,9 +86,22 @@ func (rw *ResourceWrapper) ModifyPlan(ctx context.Context, req resource.ModifyPl } } +func (rw *ResourceWrapper) MoveState(ctx context.Context) []resource.StateMover { + if rs, ok := rw.resource.(resource.ResourceWithMoveState); ok { + return rs.MoveState(ctx) + } + return nil +} + func (rw *ResourceWrapper) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { if rs, ok := rw.resource.(resource.ResourceWithUpgradeState); ok { return rs.UpgradeState(ctx) } return make(map[int64]resource.StateUpgrader, 0) } + +func (rw *ResourceWrapper) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { + if rs, ok := rw.resource.(resource.ResourceWithValidateConfig); ok { + rs.ValidateConfig(ctx, req, resp) + } +}