Skip to content

Commit

Permalink
feat: add static schema for deployment store blocks (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm authored and jpogran committed Aug 30, 2024
1 parent de3a1d3 commit a92c822
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/schema/stacks/1.9/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func DeploymentSchema(_ *version.Version) *schema.BodySchema {
"deployment": deploymentBlockSchema(),
"identity_token": identityTokenBlockSchema(),
"orchestrate": orchestrateBlockSchema(),
"store": storeBlockSchema(),
},
}
}
59 changes: 59 additions & 0 deletions internal/schema/stacks/1.9/store_block.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package schema

import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
"github.com/hashicorp/terraform-schema/internal/schema/tokmod"
"github.com/zclconf/go-cty/cty"
)

func storeBlockSchema() *schema.BlockSchema {
return &schema.BlockSchema{
Description: lang.PlainText("A store block allows to retrieve credentials at plan and apply time. These credentials can be used as inputs to deployment blocks."),
Labels: []*schema.LabelSchema{
{
Name: "type",
SemanticTokenModifiers: lang.SemanticTokenModifiers{tokmod.Type, lang.TokenModifierDependent},
Description: lang.PlainText("Store type"),
IsDepKey: true,
Completable: true,
},
{
Name: "name",
SemanticTokenModifiers: lang.SemanticTokenModifiers{tokmod.Name},
Description: lang.PlainText("Store name"),
},
},
DependentBody: map[schema.SchemaKey]*schema.BodySchema{
schema.NewSchemaKey(schema.DependencyKeys{
Labels: []schema.LabelDependent{
{Index: 0, Value: "tfvars"},
},
}): {
Attributes: map[string]*schema.AttributeSchema{
"path": {
IsRequired: true,
Constraint: schema.LiteralType{Type: cty.String},
Description: lang.Markdown("The path to the tfvars file."),
},
},
},
schema.NewSchemaKey(schema.DependencyKeys{
Labels: []schema.LabelDependent{
{Index: 0, Value: "varset"},
},
}): {
Attributes: map[string]*schema.AttributeSchema{
"id": {
IsRequired: true,
Constraint: schema.LiteralType{Type: cty.String},
Description: lang.Markdown("The id of the varset. In the form of 'varset-nnnnnnnnnnnnnnnn'."),
},
},
},
},
}
}

0 comments on commit a92c822

Please sign in to comment.