{"id":19899322,"url":"https://github.com/baijum/pyservicebinding","last_synced_at":"2026-04-27T18:03:47.403Z","repository":{"id":56953924,"uuid":"381421611","full_name":"baijum/pyservicebinding","owner":"baijum","description":"Kubernetes Service Binding Library for Python Applications","archived":false,"fork":false,"pushed_at":"2022-04-07T08:45:40.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-08T21:47:14.271Z","etag":null,"topics":["kubernetes","python","service-binding"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pyservicebinding","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/baijum.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-29T15:57:13.000Z","updated_at":"2022-04-07T08:46:37.000Z","dependencies_parsed_at":"2022-08-21T04:10:16.010Z","dependency_job_id":null,"html_url":"https://github.com/baijum/pyservicebinding","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/baijum/pyservicebinding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baijum%2Fpyservicebinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baijum%2Fpyservicebinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baijum%2Fpyservicebinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baijum%2Fpyservicebinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baijum","download_url":"https://codeload.github.com/baijum/pyservicebinding/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baijum%2Fpyservicebinding/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261523771,"owners_count":23172091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","python","service-binding"],"created_at":"2024-11-12T20:08:02.028Z","updated_at":"2026-04-27T18:03:42.361Z","avatar_url":"https://github.com/baijum.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyservicebinding\n\u003e **Kubernetes Service Binding Library for Python Applications**\n\n![PyPI - Downloads](https://img.shields.io/pypi/dm/pyservicebinding)\n![Release](https://img.shields.io/pypi/v/pyservicebinding)\n![Supported Python Versions](https://img.shields.io/pypi/pyversions/pyservicebinding)\n[![CI](https://github.com/baijum/pyservicebinding/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/baijum/pyservicebinding/actions/workflows/ci.yml)\n\nThe [Service Binding Specification][spec] for Kubernetes standardizes exposing\nbacking service secrets to applications.  This project provides a Python module\nto consume the bindings projected into the container.  The [Application\nProjection][application-projection] section of the spec describes how the\nbindings are projected into the application.  The primary mechanism of\nprojection is through files mounted at a specific directory.  The bindings\ndirectory path can be discovered through `SERVICE_BINDING_ROOT` environment\nvariable.  The operator must have injected `SERVICE_BINDING_ROOT` environment to\nall the containers where bindings are created.\n\nWithin this service binding root directory, there could be multiple bindings\nprojected from different Service Bindings.  For example, suppose an application\nrequires to connect to a database and cache server. In that case, one Service\nBinding can provide the database, and the other Service Binding can offer\nbindings to the cache server.\n\nLet's take a look at the example given in the spec:\n\n```\n$SERVICE_BINDING_ROOT\n├── account-database\n│   ├── type\n│   ├── provider\n│   ├── uri\n│   ├── username\n│   └── password\n└── transaction-event-stream\n    ├── type\n    ├── connection-count\n    ├── uri\n    ├── certificates\n    └── private-key\n```\n\nIn the above example, there are two bindings under the `SERVICE_BINDING_ROOT`\ndirectory.  The `account-database` and `transaction-event-system` are the names\nof the bindings.  Files within each bindings directory has a special file named\n`type`, and you can rely on the value of that file to identify the type of the\nbinding projected into that directory.  In certain directories, you can also see\nanother file named `provider`.  The provider is an additional identifier to\nnarrow down the type further.  This module use the `type` field and, optionally,\n`provider` field to look up the bindings.\n\n## Installation\n\nYou can install this package using pip:\n\n```bash\npip install pyservicebinding\n```\n\n## Usage\n\nThe `ServiceBinding` object can be instantiated like this:\n```python\nfrom pyservicebinding import binding\ntry:\n    sb = binding.ServiceBinding()\nexcept binding.ServiceBindingRootMissingError as msg:\n    # log the error message and retry/exit\n    print(\"SERVICE_BINDING_ROOT env var not set\")\n```\n\nTo get bindings for a specific `type`, say `postgresql`:\n\n```python\nbindings_list = sb.bindings(\"postgresql\")\n```\n\nTo get bindings for a specific `type`, say `mysql`, and `provider`, say `mariadb`:\n\n```python\nbindings_list = sb.bindings(\"mysql\", \"mariadb\")\n```\n\nTo get all bindings irrespective of the `type` and `provider`:\n\n```python\nbindings_list = sb.all_bindings()\n```\n\nThis is the complete API of the module:\n```python\n\nclass ServiceBindingRootMissingError(Exception):\n    pass\n\n\nclass ServiceBinding:\n\n    def __init__(self):\n        \"\"\"\n        - raise ServiceBindingRootMissingError if SERVICE_BINDING_ROOT env var not set\n        \"\"\"\n\n    def all_bindings(self) -\u003e list[dict[str, str]]:\n        \"\"\"Get all bindings as a list of dictionaries\n\n        - return empty list if no bindings found\n        \"\"\"\n\n    def bindings(self, _type: str, provider: typing.Optional[str] = None) -\u003e list[dict[str, str]]:\n        \"\"\"Get filtered bindings as a list of dictionaries\n\n        - return empty dictionary if no binding found\n        - filter the result with the given _type input\n        - if provider input is given, filter bindings using the given type and provider\n        \"\"\"\n```\n\n[spec]: https://github.com/servicebinding/spec\n[application-projection]: https://github.com/servicebinding/spec#application-projection\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaijum%2Fpyservicebinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaijum%2Fpyservicebinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaijum%2Fpyservicebinding/lists"}