-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate vkcs_db_datastore_capabilities data source to terraform-plugi…
…n-framework * Add provider based on terraform-provider-framework * Switch tests to terraform-plugin-testing * Support terraform-plugin-framework in schema customization --------- Co-authored-by: panic <[email protected]>
- Loading branch information
Showing
242 changed files
with
2,701 additions
and
1,384 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
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 was deleted.
Oops, something went wrong.
8 changes: 5 additions & 3 deletions
8
helpers/providerjson/read.go → helpers/providerjson/json/read.go
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,33 @@ | ||
package json | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/vk-cs/terraform-provider-vkcs/helpers/providerjson/schema" | ||
) | ||
|
||
func DumpWithWrapper(wrapper *schema.ProviderWrapper) error { | ||
if err := json.NewEncoder(os.Stdout).Encode(wrapper); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func WriteWithWrapper(wrapper *schema.ProviderWrapper, filename string) error { | ||
f, err := os.Create(filename) | ||
if err != nil { | ||
return err | ||
} | ||
defer f.Close() | ||
|
||
encoder := json.NewEncoder(f) | ||
encoder.SetIndent("", " ") | ||
|
||
if err := encoder.Encode(wrapper); err != nil { | ||
return err | ||
} | ||
|
||
return 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package schema | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
ds_schema "github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/provider" | ||
"github.com/hashicorp/terraform-plugin-framework/resource" | ||
rs_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema" | ||
sdkschema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func (p *ProviderJSON) SDKSchema() map[string]*sdkschema.Schema { | ||
return p.SDKProvider.Schema | ||
} | ||
|
||
func (p *ProviderJSON) SDKDataSourcesMap() map[string]*sdkschema.Resource { | ||
return p.SDKProvider.DataSourcesMap | ||
} | ||
|
||
func (p *ProviderJSON) SDKResourcesMap() map[string]*sdkschema.Resource { | ||
return p.SDKProvider.ResourcesMap | ||
} | ||
|
||
func (p *ProviderJSON) ResourcesMap() map[string]*rs_schema.Schema { | ||
resourcesMap := make(map[string]*rs_schema.Schema) | ||
ctx := context.Background() | ||
providerMeta := provider.MetadataResponse{} | ||
p.Provider.Metadata(ctx, provider.MetadataRequest{}, &providerMeta) | ||
|
||
for _, f := range p.Provider.Resources(ctx) { | ||
rs := f() | ||
rsMeta := resource.MetadataResponse{} | ||
rs.Metadata(ctx, resource.MetadataRequest{ProviderTypeName: providerMeta.TypeName}, &rsMeta) | ||
rsSchema := resource.SchemaResponse{} | ||
rs.Schema(ctx, resource.SchemaRequest{}, &rsSchema) | ||
resourcesMap[rsMeta.TypeName] = &rsSchema.Schema | ||
} | ||
|
||
return resourcesMap | ||
} | ||
|
||
func (p *ProviderJSON) DataSourcesMap() map[string]*ds_schema.Schema { | ||
dataSourcesMap := make(map[string]*ds_schema.Schema) | ||
ctx := context.Background() | ||
providerMeta := provider.MetadataResponse{} | ||
p.Provider.Metadata(ctx, provider.MetadataRequest{}, &providerMeta) | ||
|
||
for _, f := range p.Provider.DataSources(ctx) { | ||
ds := f() | ||
dsMeta := datasource.MetadataResponse{} | ||
ds.Metadata(ctx, datasource.MetadataRequest{ProviderTypeName: providerMeta.TypeName}, &dsMeta) | ||
dsSchema := datasource.SchemaResponse{} | ||
ds.Schema(ctx, datasource.SchemaRequest{}, &dsSchema) | ||
dataSourcesMap[dsMeta.TypeName] = &dsSchema.Schema | ||
} | ||
|
||
return dataSourcesMap | ||
} | ||
|
||
func NodeIsBlock(input SchemaJSON) bool { | ||
if input.Type == SchemaTypeList || input.Type == SchemaTypeSet { | ||
if _, ok := input.Elem.(ResourceJSON); ok { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
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
Oops, something went wrong.