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

feat(PipelinesService): Add support for pipeline inputs with type validation

Add support for the "inputs" parameter when creating pipelines via the GitLab
API. Pipeline inputs allow passing typed parameters to pipelines that use the
`spec:inputs` keyword in their `.gitlab-ci.yml` configuration.

Implementation details:
- Add PipelineInputOptions type as a map[string]any to hold input values
- Implement custom MarshalJSON to validate input types at serialization time
- Support the following value types as per GitLab API requirements:
  * string
  * integers (int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64)
  * floats (float32, float64)
  * bool
  * string slice ([]string)
- Return `ErrInvalidPipelineInputType` for unsupported types to fail fast and
  provide clear error messages

Testing improvements:
- Refactor `TestCreatePipeline` to use table-driven tests
- Add test coverage for the existing "variables" parameter
- Add test cases for pipeline inputs with various data types
- Add test case for invalid input type error handling
- Verify correct JSON serialization of both variables and inputs

This enables users to trigger pipelines with inputs like:

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

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