Skip to content
Verified Commit 9ad770e4 authored by Florian Forster's avatar Florian Forster
Browse files

feat(PipelineTriggersService): Add support for pipeline inputs to trigger API

Extend `RunPipelineTrigger` to support the "inputs" parameter, enabling trigger
tokens to start pipelines with typed input parameters. This mirrors the
functionality added to `CreatePipeline`, providing consistent input handling
across both pipeline creation methods.

Implementation details:
- Add Inputs field to `RunPipelineTriggerOptions` using the
  `PipelineInputOptions` type
- Reuse the same type validation and JSON marshaling logic from
  `CreatePipeline`
- Both variables and inputs can be used simultaneously, serving different
  purposes:
  * variables: simple string key-value pairs for CI/CD variables
  * inputs: typed parameters for pipelines using spec:inputs keyword

Testing improvements:
- Refactor `TestRunPipelineTrigger` to use table-driven tests
- Add comprehensive test coverage for the existing "variables" parameter
- Add test cases for pipeline inputs with various data types:
  strings, integers, booleans, and string arrays
- Add test case for invalid input type error handling

This enables trigger-based pipeline starts with typed inputs:

```go
client.PipelineTriggers.RunPipelineTrigger(projectID, &RunPipelineTriggerOptions{
  Token: Ptr("trigger-token"),
  Ref:   Ptr("main"),
  Variables: map[string]string{
    "DEPLOY_ENV": "prod",
  },
  Inputs: PipelineInputOptions{
    "environment": "production",
    "replicas": 3,
    "enable_debug": false,
    "regions": []string{"us-east", "eu-west"},
  },
})
```

Issue: #2154
parent ab3056f4
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