Skip to content

Commit

Permalink
Merge pull request #58 from Infisical/fix/addressed-machine-identity-…
Browse files Browse the repository at this point in the history
…auth-check

fix: resolved machine identity auth check in old resources
  • Loading branch information
sheensantoscapadngan authored Sep 26, 2024
2 parents ba3cf81 + 82cc18e commit c967c6d
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions internal/provider/resource/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (r *IdentityResource) Configure(_ context.Context, req resource.ConfigureRe

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity",
"Only Machine Identity authentication is supported for this operation",
Expand Down Expand Up @@ -139,7 +139,7 @@ func (r *IdentityResource) Create(ctx context.Context, req resource.CreateReques

// Read refreshes the Terraform state with the latest data.
func (r *IdentityResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity role",
"Only Machine Identity authentication is supported for this operation",
Expand Down Expand Up @@ -195,7 +195,7 @@ func (r *IdentityResource) Read(ctx context.Context, req resource.ReadRequest, r

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity",
"Only Machine Identity authentication is supported for this operation",
Expand Down Expand Up @@ -249,7 +249,7 @@ func (r *IdentityResource) Update(ctx context.Context, req resource.UpdateReques
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity",
"Only Machine Identity authentication is supported for this operation",
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/resource/identity_aws_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ func updateAwsAuthTerraformStateFromApi(ctx context.Context, diagnose diag.Diagn

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityAwsAuthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity aws auth",
"Only Machine IdentityAwsAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -239,10 +239,10 @@ func (r *IdentityAwsAuthResource) Create(ctx context.Context, req resource.Creat

// Read refreshes the Terraform state with the latest data.
func (r *IdentityAwsAuthResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity aws auth role",
"Only Machine IdentityAwsAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -283,10 +283,10 @@ func (r *IdentityAwsAuthResource) Read(ctx context.Context, req resource.ReadReq

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityAwsAuthResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity aws auth",
"Only Machine IdentityAwsAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -341,10 +341,10 @@ func (r *IdentityAwsAuthResource) Update(ctx context.Context, req resource.Updat
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityAwsAuthResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity aws auth",
"Only Machine IdentityAwsAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/resource/identity_azure_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ func updateAzureAuthTerraformStateByApi(ctx context.Context, diagnose diag.Diagn

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityAzureAuthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity azure auth",
"Only Machine IdentityAzureAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -227,10 +227,10 @@ func (r *IdentityAzureAuthResource) Create(ctx context.Context, req resource.Cre

// Read refreshes the Terraform state with the latest data.
func (r *IdentityAzureAuthResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity azure auth role",
"Only Machine IdentityAzureAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -271,10 +271,10 @@ func (r *IdentityAzureAuthResource) Read(ctx context.Context, req resource.ReadR

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityAzureAuthResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity azure auth",
"Only Machine IdentityAzureAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -327,10 +327,10 @@ func (r *IdentityAzureAuthResource) Update(ctx context.Context, req resource.Upd
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityAzureAuthResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity azure auth",
"Only Machine IdentityAzureAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/resource/identity_gcp_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ func updateGcpAuthStateByApi(ctx context.Context, diagnose diag.Diagnostics, pla

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityGcpAuthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity gcp auth",
"Only Machine IdentityGcpAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -249,10 +249,10 @@ func (r *IdentityGcpAuthResource) Create(ctx context.Context, req resource.Creat

// Read refreshes the Terraform state with the latest data.
func (r *IdentityGcpAuthResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity gcp auth role",
"Only Machine IdentityGcpAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -293,10 +293,10 @@ func (r *IdentityGcpAuthResource) Read(ctx context.Context, req resource.ReadReq

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityGcpAuthResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity gcp auth",
"Only Machine IdentityGcpAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -352,10 +352,10 @@ func (r *IdentityGcpAuthResource) Update(ctx context.Context, req resource.Updat
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityGcpAuthResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity gcp auth",
"Only Machine IdentityGcpAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/resource/identity_kubernetes_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ func updateKubernetesAuthStateByApi(ctx context.Context, diagnose diag.Diagnosti

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityKubernetesAuthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity kubernetes auth",
"Only Machine IdentityKubernetesAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -253,10 +253,10 @@ func (r *IdentityKubernetesAuthResource) Create(ctx context.Context, req resourc

// Read refreshes the Terraform state with the latest data.
func (r *IdentityKubernetesAuthResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity kubernetes auth role",
"Only Machine IdentityKubernetesAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -297,10 +297,10 @@ func (r *IdentityKubernetesAuthResource) Read(ctx context.Context, req resource.

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityKubernetesAuthResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity kubernetes auth",
"Only Machine IdentityKubernetesAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -358,10 +358,10 @@ func (r *IdentityKubernetesAuthResource) Update(ctx context.Context, req resourc
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityKubernetesAuthResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity kubernetes auth",
"Only Machine IdentityKubernetesAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down
16 changes: 8 additions & 8 deletions internal/provider/resource/identity_universal_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ func tfPlanExpandIpFieldAsApiField(ctx context.Context, diagnostics diag.Diagnos

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityUniversalAuthResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity universal auth",
"Only Machine IdentityUniversalAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -247,10 +247,10 @@ func (r *IdentityUniversalAuthResource) Create(ctx context.Context, req resource

// Read refreshes the Terraform state with the latest data.
func (r *IdentityUniversalAuthResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity universal auth role",
"Only Machine IdentityUniversalAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -291,10 +291,10 @@ func (r *IdentityUniversalAuthResource) Read(ctx context.Context, req resource.R

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityUniversalAuthResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity universal auth",
"Only Machine IdentityUniversalAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -345,10 +345,10 @@ func (r *IdentityUniversalAuthResource) Update(ctx context.Context, req resource
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityUniversalAuthResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity universal auth",
"Only Machine IdentityUniversalAuth authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ func (r *IdentityUniversalAuthClientSecretResource) Configure(_ context.Context,

// Create creates the resource and sets the initial Terraform state.
func (r *IdentityUniversalAuthClientSecretResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to create identity universal auth client secret",
"Only Machine IdentityUniversalAuthClientSecret authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -181,10 +181,10 @@ func (r *IdentityUniversalAuthClientSecretResource) Create(ctx context.Context,

// Read refreshes the Terraform state with the latest data.
func (r *IdentityUniversalAuthClientSecretResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to read identity universal auth client secret role",
"Only Machine IdentityUniversalAuthClientSecret authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down Expand Up @@ -227,10 +227,10 @@ func (r *IdentityUniversalAuthClientSecretResource) Read(ctx context.Context, re

// Update updates the resource and sets the updated Terraform state on success.
func (r *IdentityUniversalAuthClientSecretResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to update identity universal auth client secret",
"Only Machine IdentityUniversalAuthClientSecret authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand All @@ -241,10 +241,10 @@ func (r *IdentityUniversalAuthClientSecretResource) Update(ctx context.Context,
// Delete deletes the resource and removes the Terraform state on success.
func (r *IdentityUniversalAuthClientSecretResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {

if r.client.Config.AuthStrategy != infisical.AuthStrategy.UNIVERSAL_MACHINE_IDENTITY {
if !r.client.Config.IsMachineIdentityAuth {
resp.Diagnostics.AddError(
"Unable to delete identity universal auth client secret",
"Only Machine IdentityUniversalAuthClientSecret authentication is supported for this operation",
"Only Machine Identity authentication is supported for this operation",
)
return
}
Expand Down

0 comments on commit c967c6d

Please sign in to comment.