Skip to content

Commit

Permalink
feat: support references for identity tokens and their attributes (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Sep 23, 2024
1 parent 2051755 commit e952a60
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/schema/refscope/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ var (
ResourceScope = lang.ScopeId("resource")
VariableScope = lang.ScopeId("variable")

ComponentScope = lang.ScopeId("component")
ComponentScope = lang.ScopeId("component")
IdentityTokenScope = lang.ScopeId("identity_token")
)
4 changes: 2 additions & 2 deletions internal/schema/stacks/1.9/deployment_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package schema
import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
"github.com/hashicorp/terraform-schema/internal/schema/tokmod"
"github.com/zclconf/go-cty/cty"
)

func deploymentBlockSchema() *schema.BlockSchema {
Expand All @@ -32,7 +32,7 @@ func deploymentBlockSchema() *schema.BlockSchema {
IsOptional: true,
Constraint: schema.Map{
Name: "map of variable references",
Elem: schema.Reference{OfScopeId: refscope.VariableScope},
Elem: schema.AnyExpression{OfType: cty.DynamicPseudoType},
},
},
},
Expand Down
22 changes: 22 additions & 0 deletions internal/schema/stacks/1.9/identity_token_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ package schema
import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
"github.com/hashicorp/terraform-schema/internal/schema/tokmod"
"github.com/zclconf/go-cty/cty"
)

func identityTokenBlockSchema() *schema.BlockSchema {
return &schema.BlockSchema{
Description: lang.PlainText("An identity token block is a definition of a JSON Web Token (JWT) that will be generated for a given deployment if referenced in the inputs for that deployment block. The block label defines the token name, which must be unique within the stack."),
Address: &schema.BlockAddrSchema{
Steps: []schema.AddrStep{
schema.StaticStep{Name: "identity_token"},
schema.LabelStep{Index: 0},
},
FriendlyName: "identity_token",
ScopeId: refscope.IdentityTokenScope,
AsReference: true,
InferBody: true,
BodyAsData: true,
},
Labels: []*schema.LabelSchema{
{
Name: "name",
Expand All @@ -32,6 +44,16 @@ func identityTokenBlockSchema() *schema.BlockSchema {
Elem: schema.AnyExpression{OfType: cty.String},
},
},
"jwt": {
Description: lang.Markdown("Token that will be generated that you can pass to a given provider's configuration for OIDC/JWT authentication"),
IsComputed: true,
Constraint: schema.AnyExpression{OfType: cty.String},
},
"jwt_filename": {
Description: lang.Markdown("Path to the token that will be generated on the filesystem that you can pass to a given provider's configuration for OIDC/JWT authentication"),
IsComputed: true,
Constraint: schema.AnyExpression{OfType: cty.String},
},
},
},
}
Expand Down

0 comments on commit e952a60

Please sign in to comment.