mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-08-22 19:38:35 +00:00
fix(token): do not reset user token value in TF state during update (#1857)
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
de65997de4
commit
2da4e3de1c
@ -115,7 +115,7 @@ func TestAccResourceUserToken(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
err := te.AccessClient().DeleteUser(context.Background(), userID)
|
err = te.AccessClient().DeleteUser(context.Background(), userID)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -148,9 +148,7 @@ func TestAccResourceUserToken(t *testing.T) {
|
|||||||
"privileges_separation": "false",
|
"privileges_separation": "false",
|
||||||
"token_name": tokenName,
|
"token_name": tokenName,
|
||||||
"user_id": userID,
|
"user_id": userID,
|
||||||
}),
|
"value": fmt.Sprintf("%s!%s=.*", userID, tokenName),
|
||||||
test.NoResourceAttributesSet("proxmox_virtual_environment_user_token.user_token", []string{
|
|
||||||
"value",
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -167,10 +165,10 @@ func TestAccResourceUserToken(t *testing.T) {
|
|||||||
"privileges_separation": "false",
|
"privileges_separation": "false",
|
||||||
"token_name": tokenName,
|
"token_name": tokenName,
|
||||||
"user_id": userID,
|
"user_id": userID,
|
||||||
|
"value": fmt.Sprintf("%s!%s=.*", userID, tokenName),
|
||||||
}),
|
}),
|
||||||
test.NoResourceAttributesSet("proxmox_virtual_environment_user_token.user_token", []string{
|
test.NoResourceAttributesSet("proxmox_virtual_environment_user_token.user_token", []string{
|
||||||
"expiration_date",
|
"expiration_date",
|
||||||
"value",
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -178,6 +176,9 @@ func TestAccResourceUserToken(t *testing.T) {
|
|||||||
ResourceName: "proxmox_virtual_environment_user_token.user_token",
|
ResourceName: "proxmox_virtual_environment_user_token.user_token",
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
|
ImportStateVerifyIgnore: []string{
|
||||||
|
"value",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -108,6 +108,11 @@ func (r *userTokenResource) Schema(
|
|||||||
"and can't be retrieved at import.",
|
"and can't be retrieved at import.",
|
||||||
Computed: true,
|
Computed: true,
|
||||||
Sensitive: true,
|
Sensitive: true,
|
||||||
|
PlanModifiers: []planmodifier.String{
|
||||||
|
// the attribute can't be retrieved after token creation, so during update we have to use value
|
||||||
|
// from state (i.e. populated at create) if available.
|
||||||
|
stringplanmodifier.UseStateForUnknown(),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -254,8 +259,6 @@ func (r *userTokenResource) Update(ctx context.Context, req resource.UpdateReque
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
plan.Value = types.StringNull()
|
|
||||||
|
|
||||||
resp.State.Set(ctx, plan)
|
resp.State.Set(ctx, plan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user