mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Introduce metadata functions command (#32487)
* Add metadata functions command skeleton * Export functions as JSON via cli command * Add metadata command * Add tests to jsonfunction package * WIP: Add metadata functions test * Change return_type & type in JSON to json.RawMessage This enables easier deserialisation of types when parsing the JSON. * Skip is_nullable when false * Update cli docs with metadata command * Use tfdiags to report function marshal errors * Ignore map, list and type functions * Test Marshal function with diags * Test metadata functions command output * Simplify type marshaling by using cty.Type * Add static function signatures for can and try * Update internal/command/jsonfunction/function_test.go Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com> --------- Co-authored-by: kmoe <5575356+kmoe@users.noreply.github.com>
This commit is contained in:
31
internal/command/metadata_command.go
Normal file
31
internal/command/metadata_command.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// MetadataCommand is a Command implementation that just shows help for
|
||||
// the subcommands nested below it.
|
||||
type MetadataCommand struct {
|
||||
Meta
|
||||
}
|
||||
|
||||
func (c *MetadataCommand) Run(args []string) int {
|
||||
return cli.RunResultHelp
|
||||
}
|
||||
|
||||
func (c *MetadataCommand) Help() string {
|
||||
helpText := `
|
||||
Usage: terraform [global options] metadata <subcommand> [options] [args]
|
||||
|
||||
This command has subcommands for metadata related purposes.
|
||||
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
||||
func (c *MetadataCommand) Synopsis() string {
|
||||
return "Metadata related commands"
|
||||
}
|
||||
Reference in New Issue
Block a user