Skip to main content
Made with pop, a Python implementation of Plugin Oriented Programming Made with Python

Idem plugin with built-in functions

About

An Idem plugin containing common functions that you can run with the exec.run state. You can use argument binding to pass the output of these common functions to other Idem plugin resource states, such as in idem-aws, idem-k8s, or other Idem plugins.

What is POP?

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

Getting Started

Prerequisites

  • Python 3.8+

  • git (if installing from source or contributing to the project)

    To contribute to the project and set up your local development environment, see CONTRIBUTING.rst in the source repository for this project.

Installation

You can install idem-core-functions with the Python package installer (PyPI) or from source.

Install from PyPI

pip install idem-core-functions

Install from Source

# clone repo
git clone git@<your-project-path>/idem-core-functions.git
cd idem-core-functions

# Setup venv
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Usage

Setup

After installation, idem-core-functions execution modules are accessible to the pop hub.

For more information:

You are now ready to use idem-core-functions.

Exec Module

An SLS file specifies the desired state of a resource. You can run an exec module within an SLS file using the exec.run state, where the exec module returns a new state that can be referenced with argument binding.

  • core.encoding.base64encode

    Apply Base64 encoding to a string.

  • core.encoding.base64decode

    Restore a Base64 encoded character string to the original string.

  • core.conversion.to_json

    Serialize an object to a string of JSON.

  • core.collection.distinct

    For a given list, return a new list with any duplicate elements removed.

  • core.collection.flatten

    For a given list, replace any elements that are lists with a flattened sequence of that list.

  • core.collection.element

    Retrieve a single element from a list.

  • core.collection.length

    Determine the length of a given list, map, or string.

Syntax:

[Idem-state-name]:
  exec.run:
    - path: core.encoder.base64.encode
    - kwargs:
        data: test-user-name:test-password

[Idem-state-name]:
  exec.run:
    - path: core.encoder.base64.decode
    - kwargs:
        encoded_data: dGVzdC11c2VyLW5hbWU6dGVzdC1wYXNzd29yZA==

[Idem-state-name]:
  exec.run:
    - path: core.conversion.to_json
    - kwargs:
        data: '{
          "cluster_name":  "idem-eks-test",
          "region": "ap-south-1",
        }'

[Idem-state-name]:
  exec.run:
    - path: core.encryption.gpg.encrypt
    - kwargs:
        data: test-data-for-encryption

Examples:

vault_generic_secret.example-creds.search:
  vault.secrets.kv_v1.secret.search:
    - path: "example/projects.registry.example.com"

idem.core.encoder.base64.encode.test-2:
  exec.run:
    - path: core.encoder.base64.encode
    - kwargs:
        data: "${vault.secrets.kv_v1.secret:vault_generic_secret.example-creds.search:data:user}:${vault.secrets.kv_v1.secret:vault_generic_secret.example-creds.search:data:pass}"

kubernetes_secret.registry-secret-example:
  k8s.core.v1.secret.present:
    - resource_id: {{ params.get('kubernetes_secret.registry-secret-example') }}
    - metadata:
        name: "registrysecret-example"
    - string_data:
        ".dockerconfigjson": |+
                             {
                               "auths": {
                                 "projects.registry.example.com": {
                                   "auth": "${exec:idem.core.b64Encode.test-2:data}"
                                 }
                               }
                             }
    - type: "kubernetes.io/dockerconfigjson"

idem.core.encryption.gpg.encrypt.test-1:
  exec.run:
    - path: core.encryption.gpg.encrypt
    - kwargs:
        data: test-data-for-encryption

Idem command line examples:

idem exec exec.core.encoding.base64encode data=sample-data
idem exec exec.core.encoding.base64decode encoded_data=dGVzdC11c2VyLW5hbWU6dGVzdC1wYXNzd29yZA==

Current Supported Exec Functions

core

  • conversion

  • collection

  • encoder

  • encryption

Metadata

Release files for idem-core-functions 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for idem-core-functions 2.0.0
File Size Uploaded
idem-core-functions-2.0.0.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for idem-core-functions 2.0.0
File Interpreter ABI Platform
idem_core_functions-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / idem-core-functions-2.0.0.tar.gz

Download URL idem-core-functions-2.0.0.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2ace415ec52cea74c81b1df83654784a692eee85c5c05811d7438dadd84747bf
BLAKE2b-256 checksum
How to use checksums
c7c71c988d7e892a3a016cdf28910e859c7f9858418fd2ee3a02635b7cad6d4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.17

Release files / idem_core_functions-2.0.0-py3-none-any.whl

Download URL idem_core_functions-2.0.0-py3-none-any.whl
Size 16.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
493dcdda296ea02f1591f4405b0898488257d9d91507565a2e07c081e59bc043
BLAKE2b-256 checksum
How to use checksums
19d7ddd6be476dc21a98e8032a42e0d44ca6220f6154603eea1f6dacb2ecd431
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/40.0 requests/2.31.0 requests-toolbelt/1.0.0 urllib3/2.0.4 tqdm/4.65.0 importlib-metadata/6.8.0 keyring/24.2.0 rfc3986/2.0.0 colorama/0.4.6 CPython/3.9.17

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page