Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit 9963f38

Browse files
committed
campaigns: support RFC 228 prototype
1 parent 72293db commit 9963f38

File tree

4 files changed

+183
-12
lines changed

4 files changed

+183
-12
lines changed

internal/campaigns/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,14 @@ type CampaignSpecStep struct {
17561756
Env map[string]string `json:"env"`
17571757
}
17581758

1759+
// FIXME: the Title and Published fields should be unmarshalled properly to
1760+
// handle the new oneOf types in the campaign spec schema.
17591761
type ChangesetTemplate struct {
1760-
Title string `json:"title"`
1762+
Title interface{} `json:"title"`
17611763
Body string `json:"body"`
17621764
Branch string `json:"branch"`
17631765
Commit CommitTemplate `json:"commit"`
1764-
Published bool `json:"published"`
1766+
Published interface{} `json:"published"`
17651767
}
17661768

17671769
type CommitTemplate struct {

schema/campaign_spec.schema.json

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,48 @@
115115
"additionalProperties": false,
116116
"required": ["title", "branch", "commit", "published"],
117117
"properties": {
118-
"title": { "type": "string", "description": "The title of the changeset." },
119-
"body": { "type": "string", "description": "The body (description) of the changeset." },
118+
"title": {
119+
"description": "The title of the changeset.",
120+
"oneOf": [
121+
{
122+
"type": "string",
123+
"description": "The title to use for the entire campaign."
124+
},
125+
{
126+
"type": "object",
127+
"required": ["default", "only"],
128+
"additionalProperties": false,
129+
"properties": {
130+
"default": {
131+
"type": "string",
132+
"description": "The title to use for all changesets that do not match any of the rules in the only array."
133+
},
134+
"only": {
135+
"type": "array",
136+
"items": {
137+
"type": "object",
138+
"required": ["match", "value"],
139+
"additionalProperties": false,
140+
"properties": {
141+
"match": {
142+
"type": "string",
143+
"description": "The repository name to match. Glob wildcards are supported."
144+
},
145+
"value": {
146+
"type": "string",
147+
"description": "The title to use for changesets that match this rule."
148+
}
149+
}
150+
}
151+
}
152+
}
153+
}
154+
]
155+
},
156+
"body": {
157+
"type": "string",
158+
"description": "The body (description) of the changeset."
159+
},
120160
"branch": {
121161
"type": "string",
122162
"description": "The name of the Git branch to create or update on each repository with the changes."
@@ -135,9 +175,43 @@
135175
}
136176
},
137177
"published": {
138-
"type": "boolean",
139178
"description": "Whether to publish the changeset. An unpublished changeset can be previewed on Sourcegraph by any person who can view the campaign, but its commit, branch, and pull request aren't created on the code host. A published changeset results in a commit, branch, and pull request being created on the code host.",
140-
"$comment": "TODO(sqs): Come up with a way to specify that only a subset of changesets should be published. For example, making `published` an array with some include/exclude syntax items."
179+
"oneOf": [
180+
{
181+
"type": "boolean",
182+
"description": "A single flag to control the publishing state for the entire campaign."
183+
},
184+
{
185+
"type": "object",
186+
"title": "PublishedOnly",
187+
"description": "Only repositories that match patterns in this array will be published.",
188+
"additionalProperties": false,
189+
"required": ["only"],
190+
"properties": {
191+
"only": {
192+
"type": "array",
193+
"items": {
194+
"type": "string"
195+
}
196+
}
197+
}
198+
},
199+
{
200+
"type": "object",
201+
"title": "PublishedExcept",
202+
"description": "Only repositories that do NOT match patterns in this array will be published.",
203+
"additionalProperties": false,
204+
"required": ["except"],
205+
"properties": {
206+
"except": {
207+
"type": "array",
208+
"items": {
209+
"type": "string"
210+
}
211+
}
212+
}
213+
}
214+
]
141215
}
142216
}
143217
}

schema/campaign_spec_stringdata.go

Lines changed: 78 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/schema.go

Lines changed: 23 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)