argument with boolean value
Jarnpher553 opened this issue · 1 comments
Jarnpher553 commented
type Argument struct {
Description string `json:"desc,omitempty"`
Type string `json:"type,omitempty"`
Key string `json:"key,omitempty"`
Value string `json:"value,omitempty"`
}
func (pp *PipelineProvider) PipelineStart(c echo.Context) error {
pipelineIDStr := c.Param("pipelineid")
// Look for arguments.
// We do not check for errors here cause arguments are optional.
var args []*gaia.Argument
_ = c.Bind(&args)
// Convert string to int because id is int
pipelineID, err := strconv.Atoi(pipelineIDStr)
if err != nil {
return c.String(http.StatusBadRequest, errInvalidPipelineID.Error())
}
// Look up pipeline for the given id
var foundPipeline gaia.Pipeline
for _, p := range pipeline.GlobalActivePipelines.GetAll() {
if p.ID == pipelineID {
foundPipeline = p
break
}
}
// Overwrite docker setting
for _, a := range args {
if a.Key == "docker" {
foundPipeline.Docker = a.Value == "1"
}
}
if foundPipeline.Name != "" {
pipelineRun, err := pp.deps.Scheduler.SchedulePipeline(&foundPipeline, gaia.StartReasonManual, args)
if err != nil {
return c.String(http.StatusBadRequest, err.Error())
} else if pipelineRun != nil {
return c.JSON(http.StatusCreated, pipelineRun)
}
}
// Pipeline not found
return c.String(http.StatusNotFound, errPipelineNotFound.Error())
}
if bind with []*gaia.Argument can not pass argument with boolean value, the Argument value is type of string
Skarlso commented
Hi!
Thanks for opening an issue.
Yes, everything is string:string in the values, because the protobuf definition defines them as such. So if you need a boolean value, I suggest using "true"
or "1"
or something similar.