Skip to content

Commit

Permalink
Merge pull request #37 from nullplatform/features/account
Browse files Browse the repository at this point in the history
fix: account oragnization Id
  • Loading branch information
sebasnallar authored Nov 6, 2024
2 parents d97e51c + c756fa1 commit 88ad9de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nullplatform/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ACCOUNT_PATH = "/account"
type Account struct {
Id int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
OrganizationId string `json:"organization_id,omitempty"`
OrganizationId int `json:"organization_id,omitempty"`
RepositoryPrefix string `json:"repository_prefix,omitempty"`
RepositoryProvider string `json:"repository_provider,omitempty"`
Slug string `json:"slug,omitempty"`
Expand Down
11 changes: 8 additions & 3 deletions nullplatform/resource_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func resourceAccount() *schema.Resource {
Description: "The name of the account",
},
"organization_id": {
Type: schema.TypeString,
Type: schema.TypeInt,
Computed: true,
ForceNew: true,
Description: "The ID of the organization this account belongs to (computed from authentication token)",
Expand Down Expand Up @@ -59,7 +59,13 @@ func AccountCreate(d *schema.ResourceData, m any) error {
nullOps := m.(NullOps)
client := nullOps.(*NullClient)

organizationID, err := client.GetOrganizationIDFromToken()
organizationIDStr, err := client.GetOrganizationIDFromToken()
if err != nil {
return fmt.Errorf("error getting organization ID from token: %w", err)
}

organizationID, err := strconv.Atoi(organizationIDStr)

if err != nil {
return fmt.Errorf("error getting organization ID from token: %w", err)
}
Expand All @@ -79,7 +85,6 @@ func AccountCreate(d *schema.ResourceData, m any) error {

d.SetId(strconv.Itoa(account.Id))

// Set the computed organization_id in the state
if err := d.Set("organization_id", account.OrganizationId); err != nil {
return fmt.Errorf("error setting organization_id: %w", err)
}
Expand Down

0 comments on commit 88ad9de

Please sign in to comment.