mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Fix schema validation with array syntax for clone and services (#2920)
Co-authored-by: Robert Kaussow <xoxys@rknet.org> Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
parent
f0dc5ee182
commit
511cfec66a
4 changed files with 105 additions and 11 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/pipeline/errors"
|
"go.woodpecker-ci.org/woodpecker/pipeline/errors"
|
||||||
"go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml"
|
"go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml"
|
||||||
"go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml/linter"
|
"go.woodpecker-ci.org/woodpecker/pipeline/frontend/yaml/linter"
|
||||||
|
@ -60,6 +61,9 @@ steps:
|
||||||
settings:
|
settings:
|
||||||
repo: foo/bar
|
repo: foo/bar
|
||||||
foo: bar
|
foo: bar
|
||||||
|
services:
|
||||||
|
- name: redis
|
||||||
|
image: redis
|
||||||
`,
|
`,
|
||||||
}, {
|
}, {
|
||||||
Title: "merge maps", Data: `
|
Title: "merge maps", Data: `
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
version: 1
|
||||||
|
|
||||||
|
clone:
|
||||||
|
- name: git
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
partial: true
|
||||||
|
- name: testdata
|
||||||
|
image: woodpeckerci/plugin-git
|
||||||
|
settings:
|
||||||
|
remote: https://gitserver/owner/testdata.git
|
||||||
|
path: testdata
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golang
|
||||||
|
commands:
|
||||||
|
- go build
|
||||||
|
- go test
|
||||||
|
|
||||||
|
services:
|
||||||
|
- name: database
|
||||||
|
image: mysql
|
||||||
|
- name: cache
|
||||||
|
image: redis
|
|
@ -70,6 +70,8 @@
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"clone": {
|
"clone": {
|
||||||
"description": "Configures the clone step. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#clone",
|
"description": "Configures the clone step. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#clone",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -77,12 +79,55 @@
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"image": {
|
"image": {
|
||||||
"type": "string"
|
"$ref": "#/definitions/step_image"
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"$ref": "#/definitions/clone_settings"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/step"
|
||||||
|
},
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"clone_settings": {
|
||||||
|
"description": "Change the settings of your clone plugin. Read more: https://woodpecker-ci.org/plugins/Git%20Clone",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"depth": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "If specified, uses git's --depth option to create a shallow clone with a limited number of commits, overwritten by partial"
|
||||||
|
},
|
||||||
|
"recursive": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Clones submodules recursively"
|
||||||
|
},
|
||||||
|
"partial": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Only fetch the one commit and it's blob objects to resolve all files, overwrite depth with 1"
|
||||||
|
},
|
||||||
|
"lfs": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Set this to false to disable retrieval of LFS files"
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Fetches tags when set to true, default is false if event is not tag else true"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": {
|
||||||
|
"type": ["boolean", "string", "number", "array", "object"]
|
||||||
|
}
|
||||||
|
},
|
||||||
"branches": {
|
"branches": {
|
||||||
"description": "Only include commits based on their target branch. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#branches",
|
"description": "Only include commits based on their target branch. Read more: https://woodpecker-ci.org/docs/usage/pipeline-syntax#branches",
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
|
@ -664,12 +709,23 @@
|
||||||
},
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"description": "Read more: https://woodpecker-ci.org/docs/usage/services",
|
"description": "Read more: https://woodpecker-ci.org/docs/usage/services",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"$ref": "#/definitions/service"
|
"$ref": "#/definitions/service"
|
||||||
},
|
},
|
||||||
"minProperties": 1
|
"minProperties": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/service"
|
||||||
|
},
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"service": {
|
"service": {
|
||||||
"description": "Read more: https://woodpecker-ci.org/docs/usage/services",
|
"description": "Read more: https://woodpecker-ci.org/docs/usage/services",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -677,6 +733,10 @@
|
||||||
"minProperties": 1,
|
"minProperties": 1,
|
||||||
"required": ["image"],
|
"required": ["image"],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"description": "The name of the service. Can be used if using the array style services list",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"image": {
|
"image": {
|
||||||
"$ref": "#/definitions/step_image"
|
"$ref": "#/definitions/step_image"
|
||||||
},
|
},
|
||||||
|
|
|
@ -101,6 +101,11 @@ func TestSchema(t *testing.T) {
|
||||||
testFile: ".woodpecker/test-broken.yml",
|
testFile: ".woodpecker/test-broken.yml",
|
||||||
fail: true,
|
fail: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Array syntax",
|
||||||
|
testFile: ".woodpecker/test-array-syntax.yml",
|
||||||
|
fail: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range testTable {
|
for _, tt := range testTable {
|
||||||
|
|
Loading…
Reference in a new issue