Skip to main content

Extending Osmedeus

This guide covers how to extend Osmedeus with custom step types, runners, CLI commands, and utility functions.

Architecture Overview

Adding a New Step Type

Step types are implemented as plugins registered in the StepDispatcher.

1. Define the Step Type Constant

In internal/core/types.go:

2. Create the Executor

Create a new file internal/executor/your_executor.go:

3. Register in Dispatcher

In internal/executor/dispatcher.go, add to NewStepDispatcher():

4. Use in Workflows

Adding a New Runner

Runners execute commands in different environments (host, Docker, SSH).

1. Define Runner Type

In internal/core/types.go:

2. Implement the Runner Interface

Create internal/runner/your_runner.go:

3. Register in Runner Factory

In internal/runner/runner.go:

4. Use in Workflows

Adding a New CLI Command

CLI commands use Cobra.

1. Create Command File

Create pkg/cli/mycommand.go:

2. Register in Root Command

In pkg/cli/root.go:

3. Add Subcommands (Optional)

Adding Utility Functions

Utility functions are executed via the Goja JavaScript VM.

1. Define Function Name Constant

In internal/functions/constants.go:

2. Implement the Function

In internal/functions/util_functions.go (or create a new file):

3. Register in Goja Runtime

In internal/functions/goja_runtime.go, add to registerFunctionsOnVM():

4. Use in Workflows

Or via CLI:

Function Categories

Organize functions by category:

Testing Your Extensions

Unit Tests

Integration Tests

Best Practices

  1. Error Handling: Always return meaningful errors
  2. Context Support: Respect context cancellation for long operations
  3. Logging: Use structured logging with zap
  4. Template Variables: Support {{Variable}} syntax in inputs
  5. Documentation: Update usage help and CLAUDE.md
  6. Tests: Write unit and integration tests

File Reference