LogoLogo
HomeBlogGet a Demo
  • Introduction
  • Install Lunar
  • Learn the basics
  • 📖Docs
    • Key concepts
    • Component JSON
    • Catalog JSON
    • Lunar CLI Reference
  • 📝Configuration
    • lunar-config.yml
      • catalogers
      • catalogers/hooks
      • domains
      • components
      • collectors
      • collectors/hooks
      • policies
    • lunar.yml
  • 🛠️Plugin SDKs
    • Plugins configuration
      • lunar-cataloger.yml
      • lunar-collector.yml
      • lunar-policy.yml
    • Bash SDK
      • Cataloger
      • Collector
    • Python SDK
      • Collector
      • Policy
        • Check
        • Path
        • ComponentData
        • NoDataError
        • Utility Functions
  • ⚙️SQL API
    • Overview
    • Views
      • domains
      • components
      • component_deltas
      • initiatives
      • policies
      • checks
      • prs
      • catalog
Powered by GitBook

©️ Earthly Technologies

On this page
  • Constructor
  • Class Methods
  • from_json
  • from_file
  1. Plugin SDKs
  2. Python SDK
  3. Policy

ComponentData

The ComponentData class is used to initialize a Check instance with component metadata from different sources. It provides methods to load data from JSON objects or files.

Constructor

ComponentData(data)
  • data (dict): A dictionary containing component metadata

Class Methods

from_json

@classmethod
from_json(cls, json_data)

Creates a ComponentData instance from a JSON object.

  • json_data (dict): A dictionary containing component metadata

  • Returns: A new ComponentData instance

Example:

component_json = {
    "readme": {
        "lines": 50,
        "missing": False
    }
}
component_data = ComponentData.from_json(component_json)

from_file

@classmethod
from_file(cls, file_path)

Creates a ComponentData instance from a JSON file.

  • file_path (str): Path to a JSON file containing component metadata

  • Returns: A new ComponentData instance

Example:

component_data = ComponentData.from_file("path/to/component.json")
PreviousPathNextNoDataError

Last updated 19 hours ago

🛠️