Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
krtk6160 committed Jun 14, 2024
1 parent 8c27004 commit 115993d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
4 changes: 1 addition & 3 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
provider "cala" {
endpoint = "http://localhost:2252"
}
provider "cala" {}
10 changes: 7 additions & 3 deletions examples/resources/cala_account/resource.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
resource "cala_account" "name" {
name = "name"
code = "slghsg"
account_id = "1ce41f76-1e86-4879-b326-0c4a8501ded3"
name = "name"
code = "slghsg"
id = "1ce41f76-1e86-4879-b326-0c4a8501ded3"
}

provider "cala" {
endpoint = "http://localhost:2252"
}

terraform {
Expand Down
2 changes: 1 addition & 1 deletion provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (p *CalaProvider) Schema(ctx context.Context, req provider.SchemaRequest, r
Attributes: map[string]schema.Attribute{
"endpoint": schema.StringAttribute{
MarkdownDescription: "The endpoint for cala server.",
Optional: false,
Required: true,
},
},
}
Expand Down
17 changes: 16 additions & 1 deletion provider/resource_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/Khan/genqlient/graphql"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringdefault"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
)
Expand All @@ -26,6 +27,8 @@ type AccountResourceModel struct {
AccountId types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
Code types.String `tfsdk:"code"`
NormalBalanceType types.String `tfsdk:"normal_balance_type"`
Status types.String `tfsdk:"status"`
}

func (r *AccountResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand All @@ -36,7 +39,7 @@ func (r *AccountResource) Schema(ctx context.Context, req resource.SchemaRequest
resp.Schema = schema.Schema{
MarkdownDescription: "Cala account.",
Attributes: map[string]schema.Attribute{
"account_id": schema.StringAttribute{
"id": schema.StringAttribute{
MarkdownDescription: "ID of the account.",
Required: true,
},
Expand All @@ -48,6 +51,16 @@ func (r *AccountResource) Schema(ctx context.Context, req resource.SchemaRequest
MarkdownDescription: "code",
Required: true,
},
"normal_balance_type": schema.StringAttribute{
MarkdownDescription: "normalBalanceType",
Default: stringdefault.StaticString("CREDIT"),
Computed: true,
},
"status": schema.StringAttribute{
MarkdownDescription: "status",
Default: stringdefault.StaticString("ACTIVE"),
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -85,6 +98,8 @@ func (r *AccountResource) Create(ctx context.Context, req resource.CreateRequest
AccountId: data.AccountId.ValueString(),
Name: data.Name.ValueString(),
Code: data.Code.ValueString(),
NormalBalanceType: DebitOrCreditCredit,
Status: StatusActive,
}

response, err := accountCreate(ctx, *r.client, input)
Expand Down

0 comments on commit 115993d

Please sign in to comment.