Skip to content

Commit

Permalink
remove tf annotations from custom structs
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchy committed Jan 8, 2025
1 parent f81d9ec commit d62b492
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 15 deletions.
11 changes: 9 additions & 2 deletions internal/providers/pluginfw/products/app/data_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ type dataSourceApp struct {
}

type dataApp struct {
Name types.String `tfsdk:"name" tf:"required"`
App types.Object `tfsdk:"app" tf:"computed"`
Name types.String `tfsdk:"name"`
App types.Object `tfsdk:"app"`
}

func (dataApp) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder {
attrs["name"] = attrs["name"].SetRequired()
attrs["app"] = attrs["app"].SetComputed()

return attrs
}

func (dataApp) GetComplexFieldTypes(context.Context) map[string]reflect.Type {
Expand Down
17 changes: 13 additions & 4 deletions internal/providers/pluginfw/products/catalog/data_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@ type FunctionsDataSource struct {
}

type FunctionsData struct {
CatalogName types.String `tfsdk:"catalog_name" tf:"required"`
SchemaName types.String `tfsdk:"schema_name" tf:"required"`
IncludeBrowse types.Bool `tfsdk:"include_browse" tf:"optional"`
Functions types.List `tfsdk:"functions" tf:"optional,computed"`
CatalogName types.String `tfsdk:"catalog_name"`
SchemaName types.String `tfsdk:"schema_name"`
IncludeBrowse types.Bool `tfsdk:"include_browse"`
Functions types.List `tfsdk:"functions"`
}

func (FunctionsData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder {
attrs["catalog_name"] = attrs["catalog_name"].SetRequired()
attrs["schema_name"] = attrs["schema_name"].SetRequired()
attrs["include_browse"] = attrs["include_browse"].SetOptional()
attrs["functions"] = attrs["functions"].SetOptional().SetComputed()

return attrs
}

func (FunctionsData) GetComplexFieldTypes(context.Context) map[string]reflect.Type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,18 @@ type RegisteredModelDataSource struct {
}

type RegisteredModelData struct {
FullName types.String `tfsdk:"full_name" tf:"required"`
IncludeAliases types.Bool `tfsdk:"include_aliases" tf:"optional"`
IncludeBrowse types.Bool `tfsdk:"include_browse" tf:"optional"`
ModelInfo types.List `tfsdk:"model_info" tf:"optional,computed"`
FullName types.String `tfsdk:"full_name"`
IncludeAliases types.Bool `tfsdk:"include_aliases"`
IncludeBrowse types.Bool `tfsdk:"include_browse"`
ModelInfo types.List `tfsdk:"model_info"`
}

func (RegisteredModelData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder {
attrs["full_name"] = attrs["full_name"].SetRequired()
attrs["include_aliases"] = attrs["include_aliases"].SetOptional()
attrs["include_browse"] = attrs["include_browse"].SetOptional()
attrs["model_info"] = attrs["model_info"].SetOptional().SetComputed()
return attrs
}

func (RegisteredModelData) GetComplexFieldTypes(context.Context) map[string]reflect.Type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ type RegisteredModelVersionsDataSource struct {
}

type RegisteredModelVersionsData struct {
FullName types.String `tfsdk:"full_name" tf:"required"`
ModelVersions types.List `tfsdk:"model_versions" tf:"optional,computed"`
FullName types.String `tfsdk:"full_name"`
ModelVersions types.List `tfsdk:"model_versions"`
}

func (RegisteredModelVersionsData) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder {
attrs["full_name"] = attrs["full_name"].SetRequired()
attrs["model_versions"] = attrs["model_versions"].SetOptional().SetComputed()
return attrs
}

func (RegisteredModelVersionsData) GetComplexFieldTypes(context.Context) map[string]reflect.Type {
Expand Down
13 changes: 10 additions & 3 deletions internal/providers/pluginfw/products/volume/data_volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ type VolumesDataSource struct {
}

type VolumesList struct {
CatalogName types.String `tfsdk:"catalog_name" tf:"required"`
SchemaName types.String `tfsdk:"schema_name" tf:"required"`
Ids types.List `tfsdk:"ids" tf:"optional,computed"`
CatalogName types.String `tfsdk:"catalog_name"`
SchemaName types.String `tfsdk:"schema_name"`
Ids types.List `tfsdk:"ids"`
}

func (VolumesList) ApplySchemaCustomizations(attrs map[string]tfschema.AttributeBuilder) map[string]tfschema.AttributeBuilder {
attrs["catalog_name"] = attrs["catalog_name"].SetRequired()
attrs["schema_name"] = attrs["schema_name"].SetRequired()
attrs["ids"] = attrs["ids"].SetOptional().SetComputed()
return attrs
}

func (VolumesList) GetComplexFieldTypes(context.Context) map[string]reflect.Type {
Expand Down

0 comments on commit d62b492

Please sign in to comment.