Skip to content

Add SDK docs with Python and Go source-to-function examples#428

Open
welteki wants to merge 3 commits intoopenfaas:masterfrom
welteki:python-sdk-examples
Open

Add SDK docs with Python and Go source-to-function examples#428
welteki wants to merge 3 commits intoopenfaas:masterfrom
welteki:python-sdk-examples

Conversation

@welteki
Copy link
Copy Markdown
Member

@welteki welteki commented Apr 28, 2026

Description

Adds a new SDKs section covering the Python and Go SDKs. Each SDK includes a source-to-function example that walks through creating a namespace and secret, building a function image via the Function Builder API, deploying it, and invoking it.

Motivation and Context

The Python and Go SDKs lacked dedicated documentation. This gives users a reference for common use-cases such as multi-tenant platforms and CI/CD pipelines that go from source code to a running function programmatically.

  • I have raised an issue to propose this change (required)

How Has This Been Tested?

Both examples were run end-to-end against a live OpenFaaS Pro gateway and Function Builder, verifying a 200 response with a valid token and a 401 with an invalid token.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s

welteki added 3 commits April 28, 2026 14:49
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
…ython index pages

Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
Signed-off-by: Han Verstraete (OpenFaaS Ltd) <han@openfaas.com>
@reviewfn
Copy link
Copy Markdown

reviewfn Bot commented Apr 28, 2026

AI Pull Request Overview

Summary

  • Adds comprehensive SDK documentation for Python and Go
  • Includes source-to-function examples demonstrating namespace, secret, build, deploy, and invoke workflows
  • Updates navigation to include new SDKs section
  • Modifies existing Python API example to reference SDK

Approval rating

7/10 - Solid documentation addition with working examples, but Go code has potential nil pointer issue in readiness check

Summary per file

Summary per file
File path Summary
docs/sdks/index.md Overview of Python and Go SDKs with install and feature lists
docs/sdks/go/examples/source-to-function.md Complete Go example for source-to-function workflow with code snippets
docs/sdks/python/examples/source-to-function.md Complete Python example for source-to-function workflow with code snippets
docs/languages/python/examples/openfaas-api.md Updated to reference Python SDK at top
mkdocs.yml Added SDKs section to navigation menu

Overall Assessment

The PR adds valuable documentation for the OpenFaaS SDKs with practical examples that demonstrate common use cases for programmatic function management. The examples cover multi-tenant scenarios and CI/CD automation effectively. However, the Go code contains a potential runtime panic in the readiness check that should be addressed.

Detailed Review

Detailed Review

docs/sdks/index.md

  • SDK overview is clear and accurate
  • Feature lists match SDK capabilities
  • Installation instructions use git+ URLs, appropriate for development versions

docs/sdks/go/examples/source-to-function.md

  • Handler code correctly implements Bearer token authentication against mounted secret
  • Error handling in handler properly returns structured JSON responses
  • Orchestration code demonstrates proper OpenFaaS SDK usage for namespace, secret, build, and deploy operations
  • Issue: In waitForReady, the check if fn.AvailableReplicas >= 1 will panic if AvailableReplicas is nil (common in Kubernetes/OpenFaaS types where fields are pointers). Should check for nil first: if fn.AvailableReplicas != nil && *fn.AvailableReplicas >= 1
  • Build context creation uses correct template and build directory parameters
  • HMAC authentication for builder is properly implemented
  • Log streaming and function invocation examples are correct
  • Environment variable validation is appropriate with fatal exits for missing required vars

docs/sdks/python/examples/source-to-function.md

  • Handler correctly implements Bearer token auth and readiness endpoint
  • Orchestration script properly handles exceptions and authentication
  • Readiness check safely handles optional available_replicas field
  • Build and deploy workflow matches Go implementation
  • Annotations for readiness probe are correctly configured
  • UUID-based API key generation is more secure than timestamp

docs/languages/python/examples/openfaas-api.md

  • Updated introduction properly references Python SDK
  • Code examples remain correct and demonstrate idempotent namespace creation
  • Authentication helper addition shows proper Bearer token validation
  • Secret mounting and environment configuration are accurate

mkdocs.yml

  • Navigation update correctly adds SDKs section with proper hierarchy
  • Links to new documentation pages are accurate

AI agent details.

Agent processing time: 1m35.894s
Environment preparation time: 3.984s
Total time from webhook: 1m43.938s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant