Skip to content

Commit

Permalink
Fix: Move from org ID -> org slug
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHougaard committed Feb 29, 2024
1 parent d473e35 commit e00eafd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
20 changes: 10 additions & 10 deletions examples/resources/infisical_project/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ terraform {
}

provider "infisical" {
host = "http://localhost:8080" # Only required if using self hosted instance of Infisical, default is https://app.infisical.com
host = "https://app.infisical.com" # Only required if using self hosted instance of Infisical, default is https://app.infisical.com
client_id = "<machine-identity-client-id>"
client_secret = "<machine-identity-client-secret>"
}

resource "infisical_project" "gcp-project" {
name = "GCP Project"
slug = "gcp-project"
organization_id = "<organization-id>"
name = "GCP Project"
slug = "gcp-project"
organization_slug = "<organization-slug>"
}

resource "infisical_project" "aws-project" {
name = "AWS Project"
slug = "aws-project"
organization_id = "<organization-id>"
name = "AWS Project"
slug = "aws-project"
organization_slug = "<organization-slug>"
}

resource "infisical_project" "azure-project" {
name = "Azure Project"
slug = "azure-project"
organization_id = "<organization-id>"
name = "Azure Project"
slug = "azure-project"
organization_slug = "<organization-slug>"
}


24 changes: 12 additions & 12 deletions infisical/provider/project_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type projectResource struct {

// projectResourceSourceModel describes the data source data model.
type projectResourceModel struct {
Slug types.String `tfsdk:"slug"`
OrganizationId types.String `tfsdk:"organization_id"`
Name types.String `tfsdk:"name"`
LastUpdated types.String `tfsdk:"last_updated"`
Slug types.String `tfsdk:"slug"`
OrganizationSlug types.String `tfsdk:"organization_slug"`
Name types.String `tfsdk:"name"`
LastUpdated types.String `tfsdk:"last_updated"`
}

// Metadata returns the resource type name.
Expand All @@ -48,8 +48,8 @@ func (r *projectResource) Schema(_ context.Context, _ resource.SchemaRequest, re
Description: "The slug of the project",
Required: true,
},
"organization_id": schema.StringAttribute{
Description: "The ID of the organization to which the project belongs",
"organization_slug": schema.StringAttribute{
Description: "The slug of the organization to which the project belongs",
Required: true,
},
"name": schema.StringAttribute{
Expand Down Expand Up @@ -103,9 +103,9 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest
}

_, err := r.client.CallCreateProject(infisical.CreateProjectRequest{
OrganizationId: plan.OrganizationId.ValueString(),
ProjectName: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
OrganizationSlug: plan.OrganizationSlug.ValueString(),
ProjectName: plan.Name.ValueString(),
Slug: plan.Slug.ValueString(),
})

if err != nil {
Expand All @@ -118,7 +118,7 @@ func (r *projectResource) Create(ctx context.Context, req resource.CreateRequest

plan.LastUpdated = types.StringValue(time.Now().Format(time.RFC850))
plan.Slug = types.StringValue(plan.Slug.ValueString())
plan.OrganizationId = types.StringValue(plan.OrganizationId.ValueString())
plan.OrganizationSlug = types.StringValue(plan.OrganizationSlug.ValueString())
plan.Name = types.StringValue(plan.Name.ValueString())

diags = resp.State.Set(ctx, plan)
Expand Down Expand Up @@ -205,10 +205,10 @@ func (r *projectResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

if state.OrganizationId != plan.OrganizationId {
if state.OrganizationSlug != plan.OrganizationSlug {
resp.Diagnostics.AddError(
"Unable to update project",
"Organization ID cannot be updated",
"Organization slug cannot be updated",
)
return
}
Expand Down

0 comments on commit e00eafd

Please sign in to comment.