diff --git a/.github/workflows/build-test-release.yml b/.github/workflows/build-test-release.yml index b3b3a5cc..c19cf252 100644 --- a/.github/workflows/build-test-release.yml +++ b/.github/workflows/build-test-release.yml @@ -5,8 +5,6 @@ on: branches: - "main" - "develop" - tags: - - "v[0-9]+.[0-9]+.[0-9]+" pull_request: branches: [main, develop] @@ -59,7 +57,6 @@ jobs: - uses: pre-commit/action@v3.0.1 semgrep: - if: github.actor != 'dependabot[bot]' uses: splunk/sast-scanning/.github/workflows/sast-scan.yml@main secrets: SEMGREP_KEY: ${{ secrets.SEMGREP_PUBLISH_TOKEN }} diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index ef829e6b..6a302eb1 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -2,7 +2,12 @@ name: docs on: push: branches: - - main + - "main" + - "develop" + pull_request: + branches: + - "main" + - "develop" jobs: deploy: runs-on: ubuntu-latest @@ -17,4 +22,9 @@ jobs: - run: curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1 - run: | poetry install - poetry run mkdocs gh-deploy --force + - name: Deploy to GitHub Pages + if: github.ref_name == 'main' + run: poetry run mkdocs gh-deploy --force --strict + - name: Build Docs + if: github.ref_name != 'main' + run: poetry run mkdocs build --strict diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3224e995..67bc6bc2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,16 @@ repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-merge-conflict + - id: debug-statements - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.2 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/myint/docformatter diff --git a/.releaserc b/.releaserc index dce467f0..6959872d 100644 --- a/.releaserc +++ b/.releaserc @@ -1,7 +1,6 @@ { branches: [ - "+([0-9])?(.{+([0-9]),x}).x", "main", { name: "develop", prerelease: "beta", channel: "beta" }, ], diff --git a/README.md b/README.md index f4cfd5dc..adc40573 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,18 @@ -# README +# solnlib -Splunk Solutions SDK is an open source packaged solution for getting data into Splunk using modular inputs. -This SDK is used by Splunk Add-on builder, and Splunk UCC based add-ons and is intended for use by partner -developers. This SDK/Library extends the Splunk SDK for python +![PyPI](https://img.shields.io/pypi/v/solnlib) +![Python](https://img.shields.io/pypi/pyversions/solnlib.svg) +![PyPI monthly downloads](https://img.shields.io/pypi/dm/solnlib) + +## What is solnlib? + +`solnlib` is an open source Python library designed to be used in Splunk technology add-ons. + +It allows to: +* interact with Splunk's KVStore to manage checkpoints +* read, update and delete secrets in Splunk's credential store +* manipulate with Splunk's .conf files +* and many more Documentation is available [here](https://splunk.github.io/addonfactory-solutions-library-python/). @@ -14,9 +24,13 @@ If you are a part of the community use: https://splunk-usergroups.slack.com/arch ## Support -Splunk Solutions SDK is an open source product developed by Splunkers. This SDK is not "Supported Software" by Splunk, Inc. issues and defects can be reported +`solnlib` is an open source product developed by Splunkers. This SDK is not "Supported Software" by Splunk, Inc. issues and defects can be reported via the public issue tracker. +## Contributing Guidelines + +Go to [contributing Guidelines in the repo](docs/contributing.md) or [published version](https://splunk.github.io/solnlib/contributing/). + ## License -* Configuration and documentation licensed subject to [APACHE-2.0](LICENSE) +Configuration and documentation licensed subject to [APACHE-2.0](LICENSE). diff --git a/docs/alerts_rest_client.md b/docs/alerts_rest_client.md new file mode 100644 index 00000000..1cbbbf65 --- /dev/null +++ b/docs/alerts_rest_client.md @@ -0,0 +1,3 @@ +# alerts_rest_client.py + +::: solnlib.alerts_rest_client \ No newline at end of file diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 00000000..463fa77b --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,38 @@ +# Contributing Guidelines + +We welcome contributions from the community! This guide will help you understand our contribution process and requirements. + +## Development guidelines + +1. Small PRs ([blogpost](https://testing.googleblog.com/2024/07/in-praise-of-small-pull-requests.html)) +1. When fixing a bug, include a test that reproduces the issue in the same pull request (the test should fail without your changes) +1. If you are refactoring, ensure adequate test coverage exists for the target area. If coverage is insufficient, create tests in a separate pull request first. This approach provides a safety net for validating current behavior and simplifies code reviews. + +## Build and Test + +Prerequisites: + +- Poetry 1.5.1 [Installation guide](https://python-poetry.org/docs/#installing-with-the-official-installer) + +### Install dependencies + +```bash +poetry install +``` + +### Unit tests + +```bash +poetry run pytest tests/unit +``` + +### Linting and Type-checking + +`solnlib` uses the [`pre-commit`](https://pre-commit.com) framework for linting and type-checking. +Consult with `pre-commit` documentation about what is the best way to install the software. + +To run it locally: + +```bash +pre-commit run --all-files +``` diff --git a/mkdocs.yml b/mkdocs.yml index f0742b0e..103894f0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,4 +1,11 @@ -site_name: Splunk Solutions SDK +site_name: solnlib +site_author: Splunk +site_url: "https://splunk.github.io/solnlib/" +edit_uri: "tree/main/docs/" +remote_branch: gh-pages + +repo_name: Splunk Solutions Library +repo_url: "https://github.com/splunk/addonfactory-solutions-library-python" theme: name: "material" @@ -31,6 +38,7 @@ plugins: nav: - Home: index.md - Release 6.0.0: release_6_0_0.md + - Contributing: contributing.md - References: - modular_input: - "checkpointer.py": modular_input/checkpointer.md @@ -38,6 +46,8 @@ nav: - "event_writer.py": modular_input/event_writer.md - "modular_input.py": modular_input/modular_input.md - "acl.py": acl.md + - "alerts_rest_client.py": alerts_rest_client.md + - "bulletin_rest_client.py": bulletin_rest_client.md - "credentials.py": credentials.md - "conf_manager.py": conf_manager.md - "file_monitor.py": file_monitor.md diff --git a/pyproject.toml b/pyproject.toml index 20844847..5ad4c142 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ [tool.poetry] name = "solnlib" -version = "6.1.0-beta.1" +version = "6.0.1" description = "The Splunk Software Development Kit for Splunk Solutions" authors = ["Splunk "] license = "Apache-2.0" diff --git a/solnlib/__init__.py b/solnlib/__init__.py index e69f25bd..f12f8350 100644 --- a/solnlib/__init__.py +++ b/solnlib/__init__.py @@ -56,4 +56,4 @@ "utils", ] -__version__ = "6.1.0-beta.1" +__version__ = "6.0.1" diff --git a/solnlib/rest.py b/solnlib/rest.py index df13c303..b7eb12f5 100644 --- a/solnlib/rest.py +++ b/solnlib/rest.py @@ -34,7 +34,6 @@ def splunkd_request( retry=1, verify=False, ) -> Optional[requests.Response]: - headers = headers if headers is not None else {} headers["Authorization"] = f"Splunk {session_key}" content_type = headers.get("Content-Type")