Skip to content

Commit e22eba0

Browse files
committed
add log entries and update to valueString to avoid double quotes around the values
1 parent 5925f06 commit e22eba0

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

internal/provider/ephemeral_resource_agent_token.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package provider
66
import (
77
"context"
88
"fmt"
9+
"log"
910

1011
tfe "github.com/hashicorp/go-tfe"
1112
"github.com/hashicorp/terraform-plugin-framework/ephemeral"
@@ -38,12 +39,11 @@ func (e *AgentTokenEphemeralResource) Schema(ctx context.Context, req ephemeral.
3839
Attributes: map[string]schema.Attribute{
3940
"agent_pool_id": schema.StringAttribute{
4041
Description: `ID of the agent. If omitted, agent must be defined in the provider config.`,
41-
Optional: false,
42-
Computed: true,
42+
Required: true,
4343
},
4444
"description": schema.StringAttribute{
45-
Description: `The token's expiration date.`,
46-
Optional: true,
45+
Description: `Description of the agent token.`,
46+
Required: true,
4747
},
4848
"token": schema.StringAttribute{
4949
Description: `The generated token.`,
@@ -86,9 +86,15 @@ func (e *AgentTokenEphemeralResource) Open(ctx context.Context, req ephemeral.Op
8686
return
8787
}
8888

89-
agentPoolId := data.AgentPoolId.String()
89+
agentPoolId := data.AgentPoolId.ValueString()
90+
description := data.Description.ValueString()
91+
92+
options := tfe.AgentTokenCreateOptions{
93+
Description: tfe.String(description),
94+
}
9095

91-
options := tfe.AgentTokenCreateOptions{}
96+
log.Printf("[DEBUG] Create new agent token for agent pool ID: %s", agentPoolId)
97+
log.Printf("[DEBUG] Create new agent token with description: %s", description)
9298

9399
result, err := e.config.Client.AgentTokens.Create(ctx, agentPoolId, options)
94100

0 commit comments

Comments
 (0)