Skip to content

Enhancement: Add command to get module outputs from facets.yaml #78

@SatyendraGollaFacets

Description

@SatyendraGollaFacets

Description

Currently, there is no command to extract and display the outputs section from a module's facets.yaml file. While we have get-output-types for listing control plane output types and get-resources for listing Terraform resources, we lack a way to quickly view what outputs a module exposes without manually opening and reading the facets.yaml file.

Current Behavior

  • ftf get-resources <path> - Lists Terraform resources from .tf files
  • ftf get-output-types - Lists output types registered in control plane
  • ftf get-output-type-details -o <type> - Shows control plane output type details
  • ftf preview-module <path> - Reads outputs.tf and generates output.facets.yaml
  • No command to view the outputs section from facets.yaml

Requested Enhancement

Add a new command to extract and display the outputs section from a module's facets.yaml file.

Proposed Command

ftf get-module-outputs <module_path> [OPTIONS]

Options

  • <module_path>: Path to the module directory (required)
  • --output-name: (Optional) Filter to show specific output only
  • --format: Output format (yaml/json, default: yaml)

Use Cases

  1. Module Interface Discovery: Quickly understand what outputs a module exposes without opening files
  2. Input Compatibility Checking: Verify output types before wiring as inputs to other modules
  3. Documentation: Generate output documentation for modules
  4. Module Comparison: Compare output definitions across different module flavors
  5. Validation: Verify output configurations during development
  6. CI/CD: Programmatic access to module output metadata

Example Output

outputs:
  default:
    type: "@facets/postgres"
    title: "PostgreSQL Database"
    providers:
      postgresql:
        source: "hashicorp/postgresql"
        version: ">= 1.0"
        attributes:
          host: attributes.endpoint
          port: attributes.port
  
  attributes.connection_string:
    type: "@facets/postgres-connection-string"
    title: "Database Connection String"

With --output-name default:

type: "@facets/postgres"
title: "PostgreSQL Database"
providers:
  postgresql:
    source: "hashicorp/postgresql"
    version: ">= 1.0"
    attributes:
      host: attributes.endpoint
      port: attributes.port

Implementation Notes

  • Use existing load_facets_yaml(path) utility from ftf_cli/utils.py
  • Extract the outputs section from the loaded YAML
  • Support both YAML and JSON output formats
  • Handle cases where outputs section is missing or empty
  • Optional filtering by specific output name using dot notation
  • Should work offline (no control plane API calls needed)

Related Files

  • ftf_cli/utils.py - Contains load_facets_yaml() helper
  • ftf_cli/commands/get_resources.py - Similar pattern for reading module info
  • ftf_cli/commands/validate_facets.py - Uses facets.yaml reading

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions