Skip to main content

Standard Components for the Pyvider Framework

Project description

Pyvider Components

This repository provides a standard set of components for the Pyvider framework, a Python-based framework for building Terraform providers.

Components

The following components are available:

Data Sources

  • pyvider_env_variables: Provides access to environment variables.
  • pyvider_file_info: Provides information about a file.
  • pyvider_http_api: Makes an HTTP request and returns the response.
  • pyvider_lens_jq: Transforms data using a JQ expression.

Resources

  • pyvider_file_content: Manages the content of a file.
  • pyvider_local_directory: Manages a directory on the local filesystem.
  • pyvider_private_state_verifier: Verifies the private state of a resource.
  • pyvider_timed_token: Manages a timed token.
  • pyvider_warning_example: An example resource that demonstrates how to return warnings.

Functions

Numeric Functions

  • add: Adds two numbers.
  • subtract: Subtracts two numbers.
  • multiply: Multiplies two numbers.
  • divide: Divides two numbers.
  • sum: Sums a list of numbers.
  • min: Returns the minimum of a list of numbers.
  • max: Returns the maximum of a list of numbers.
  • round: Rounds a number to specified precision.

String Functions

  • upper: Converts a string to uppercase.
  • lower: Converts a string to lowercase.
  • split: Splits a string into a list of strings.
  • join: Joins a list of strings.
  • replace: Replaces a substring in a string.
  • format: Formats a string using positional arguments.
  • truncate: Truncates text to specified length.
  • format_size: Formats bytes as human-readable size.
  • pluralize: Pluralizes a word based on count.
  • to_snake_case: Converts a string to snake_case.
  • to_kebab_case: Converts a string to kebab-case.
  • to_camel_case: Converts a string to camelCase.

Collection Functions

  • length: Returns the length of a string, list, or map.
  • contains: Checks if a list contains a given element.
  • lookup: Looks up a value in a map.

Type Conversion Functions

  • tostring: Converts any value to a string.

Transformation Functions

  • lens_jq: Transforms data using a JQ expression.

Getting Started

To use the pyvider-components provider, you need to configure it in your Terraform project.

terraform {
  required_providers {
    pyvider = {
      source  = "local/providers/pyvider"
      version = "0.1.0"
    }
  }
}

provider "pyvider" {
  # Configuration options here
}

Examples

Here are a few examples of how to use the components:

pyvider_env_variables

# Filter by a specific list of keys
data "pyvider_env_variables" "by_keys" {
  keys = ["TEST_VAR1", "TEST_VAR2", "TEST_SENSITIVE_TOKEN", "NON_EXISTENT_VAR"]
}

output "by_keys_result" {
  description = "Result of filtering by specific keys."
  value       = data.pyvider_env_variables.by_keys.values
}

pyvider_file_content

# Create file
resource "pyvider_file_content" "test_create" {
  filename = "/tmp/pyvider_test_create.txt"
  content  = "This is a test file created by Pyvider"
}

output "created_file" {
  value = {
    filename = pyvider_file_content.test_create.filename
    content = pyvider_file_content.test_create.content
    exists = pyvider_file_content.test_create.exists
    content_hash = pyvider_file_content.test_create.content_hash
  }
}

upper function

output "upper_result" {
  value = provider::pyvider::upper("hello world")
}

Development

To contribute to the development of the pyvider-components provider, you need to set up the development environment.

Environment Setup

# Set up the development environment (creates virtual env, installs dependencies)
source ./env.sh

Testing

# Run all tests
pytest

Building

# Build the package
uv build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvider_components-0.0.1000.tar.gz (181.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvider_components-0.0.1000-py3-none-any.whl (232.0 kB view details)

Uploaded Python 3

File details

Details for the file pyvider_components-0.0.1000.tar.gz.

File metadata

File hashes

Hashes for pyvider_components-0.0.1000.tar.gz
Algorithm Hash digest
SHA256 bf3122ac726e0379c1ab571bf5ebad1d5818cbcb11189a350431e2e186297b79
MD5 b76d7530c9ffab5b098683734e734da4
BLAKE2b-256 cfe2b9bbebaf5c38026631903679818b46c1419b303fcb80f87b5931cdb2b73e

See more details on using hashes here.

File details

Details for the file pyvider_components-0.0.1000-py3-none-any.whl.

File metadata

File hashes

Hashes for pyvider_components-0.0.1000-py3-none-any.whl
Algorithm Hash digest
SHA256 126e5766dd5bf571177a895d8b5b8512c9ede37c56a86fe32ecbd93cd7b10e30
MD5 bb219dc72bcb2370230a0b949b89049b
BLAKE2b-256 951cf97e8a801e10786fbebc34f1a49e04ba6dcc10ae3501b59bc70a1d6ab7c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page