Metadata-Version: 2.4
Name: kratix-sdk
Version: 0.4.3
Summary: Kratix SDK for writing Promises workflows
Project-URL: Homepage, https://github.com/syntasso/kratix-python
Project-URL: Repository, https://github.com/syntasso/kratix-python
Project-URL: Source, https://github.com/syntasso/kratix-python
Project-URL: Documentation, https://syntasso.github.io/kratix-python
Project-URL: Bug Tracker, https://github.com/syntasso/kratix-python/issues
Project-URL: Changelog, https://github.com/syntasso/kratix-python/blob/main/CHANGELOG.md
Author-email: Syntasso <hello@syntasso.io>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: kratix,platform-engineering,promises,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: kubernetes<36,>=33.0.0
Requires-Dist: pyyaml<7,>=6.0.0
Provides-Extra: dev
Requires-Dist: pdoc>=15.0.0; extra == 'dev'
Requires-Dist: pytest>=9.0.2; extra == 'dev'
Requires-Dist: ruff>=0.14.8; extra == 'dev'
Description-Content-Type: text/markdown

# kratix-python

Library documentation can be found [here](https://syntasso.github.io/kratix-python).

## Installation

```bash
# From PyPI (preferred once published)
pip install kratix-sdk

# From the main branch
pip install git+https://github.com/syntasso/kratix-python.git

# Editable install for local development
pip install -e .
```

## Usage

```python
import kratix_sdk as ks
import yaml

# Initialize the sdk
sdk = ks.KratixSDK()
resource = sdk.read_resource_input()

# Read from resource input
name = resource.get_value("spec.key")

# Write workload documents to OUTPUT_DIR
manifest = {
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "metadata": {"name": name, "labels": {"app": name}},
    "spec": {
        "replicas": 1,
        "selector": {"matchLabels": {"app": name}},
        "template": {
            "metadata": {"labels": {"app": name}},
            "spec": {
                "containers": [
                    {"name": name, "image": "busybox"}
                ]
            },
        },
    },
}
data = yaml.safe_dump(manifest).encode("utf-8")
sdk.write_output("deployment.yaml", data)

# Publish status during workflow run
status = ks.Status()
status.set("phase", "updates-from-mid-stage")
sdk.publish_status(resource, status)

# Set status
status = ks.Status()
status.set("message", f"created deployment {key}")
sdk.write_status(status)

# Write destination selectors for dynamic scheduling
selectors: List[ks.DestinationSelector] = [
    ks.DestinationSelector(match_labels={"environment": "test"})
]
sdk.write_destination_selectors(selectors)
```

## Development

Library is under `kratix_sdk`. Examples of Promises using this library can be found under `examples`.

* `make install` installs all dependencies

* `make test` runs all tests under `tests/`

* `make fmt` code formatting using `ruff`

* `make lint` linting using `ruff`

See `RELEASING.md` for the tested release workflow when publishing to TestPyPI/PyPI.
