Skip to content
Verified Commit 4b30e602 authored by Florian Forster's avatar Florian Forster
Browse files

feat(pipelines): Add compile-time type-safe pipeline inputs support

Implement strongly-typed pipeline inputs for `CreatePipeline` and
`RunPipelineTrigger` using generics to ensure compile-time type safety. This
approach prevents invalid input types from being used at compile time rather
than failing at runtime.

Implementation details:
- Add `PipelineInputsOption` type to represent pipeline input parameters
- Create `PipelineInputValue[T]` generic wrapper with type constraints
- Use `PipelineInputValueInterface` to enable map storage while maintaining
  type safety
- Constrain valid types using `PipelineInputValueType` (string, integers,
  floats, bool, string slice)
- Provide `NewPipelineInputValue()` constructor following the `Ptr()` pattern

Key design benefits:
- Compile-time type validation eliminates runtime type errors
- Invalid types (e.g., `struct{}`, `map`) cannot compile
- Explicit API contract through type constraints
- Consistent with existing patterns (similar to `Ptr()` usage)
- Self-documenting through IDE autocomplete and type hints

Usage example:

```go
client.Pipelines.CreatePipeline(projectID, &CreatePipelineOptions{
  Ref: Ptr("main"),
  Inputs: PipelineInputsOption{
    "environment": NewPipelineInputValue("production"),
    "replicas":    NewPipelineInputValue(3),
    "debug":       NewPipelineInputValue(false),
    "regions":     NewPipelineInputValue([]string{"us-east", "eu-west"}),
  },
})
```

Testing:
- Update tests to use `NewPipelineInputValue()` wrapper
- Verify compile-time type checking prevents invalid types
- Maintain comprehensive coverage for all supported types
- Test both `CreatePipeline` and `RunPipelineTrigger` endpoints

Fixes: #2154
parent 9ad770e4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment