Skip to content

Commit 893a668

Browse files
committed
bobfile: add JSON schema, improve Bobfile's field comments
1 parent 631b0da commit 893a668

File tree

3 files changed

+453
-26
lines changed

3 files changed

+453
-26
lines changed

pkg/bobfile/bobfile.go

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ const (
2323
)
2424

2525
type Bobfile struct {
26-
FileDescriptionBoilerplate string `json:"for_description_of_this_file_see"`
27-
VersionMajor int `json:"version_major"`
28-
ProjectName string `json:"project_name"`
29-
Meta ProjectMetadata `json:"meta,omitempty"`
30-
Builders []BuilderSpec `json:"builders"`
31-
DockerImages []DockerImageSpec `json:"docker_images,omitempty"`
32-
Subrepos []SubrepoSpec `json:"subrepos,omitempty"`
33-
OsArches *OsArchesSpec `json:"os_arches,omitempty"`
34-
Experiments experiments `json:"experiments_i_consent_to_breakage,omitempty"`
35-
Deprecated1 string `json:"project_emoji_icon,omitempty"` // moved to `ProjectMetadata`
26+
Schema string `json:"$schema"` // JSON schema URL
27+
FileDescriptionBoilerplate string `json:"for_description_of_this_file_see"` // link which explains what this file is about
28+
VersionMajor int `json:"version_major"` // major version, for indicating backwards-incompatible version breaks
29+
ProjectName string `json:"project_name"` // the project's name, prefer filesystem-safe & URL-safe characters
30+
Meta ProjectMetadata `json:"meta,omitempty"` // metadata about this project
31+
Builders []BuilderSpec `json:"builders"` // builders used to build components of this project
32+
DockerImages []DockerImageSpec `json:"docker_images,omitempty"` // container images to build during the build
33+
Subrepos []SubrepoSpec `json:"subrepos,omitempty"` // subrepos to check out
34+
OsArches *OsArchesSpec `json:"os_arches,omitempty"` // operating systems and CPU architectures to build for
35+
Experiments experiments `json:"experiments_i_consent_to_breakage,omitempty"` // unstable experiments to enable. by defining any of these, you consent to your builds breaking on new versions of Turbo Bob.
36+
Deprecated1 string `json:"project_emoji_icon,omitempty"` // moved to `ProjectMetadata`
3637
}
3738

3839
func (b Bobfile) ProjectEmojiIcon() string {
@@ -130,39 +131,39 @@ func (o *OsArchesSpec) AsBuildEnvVariables() []string {
130131
so there's no unnecessary uploads.
131132
*/
132133
type BuilderCommands struct {
133-
Prepare []string `json:"prepare,omitempty"`
134-
Build []string `json:"build"`
135-
Publish []string `json:"publish,omitempty"`
136-
Dev []string `json:"dev"`
134+
Prepare []string `json:"prepare,omitempty"` // command for preparing the build
135+
Build []string `json:"build"` // command for building the project
136+
Publish []string `json:"publish,omitempty"` // command for publishing the artefacts of the project
137+
Dev []string `json:"dev"` // command for entering the development shell of the project
137138
}
138139

139140
type BuilderSpec struct {
140-
Name string `json:"name"`
141-
Uses string `json:"uses"` // "docker://alpine:latest" | "dockerfile://build-default.Dockerfile"
141+
Name string `json:"name" jsonschema:"example=default,example=backend"` // name of the builder
142+
Uses string `json:"uses" jsonschema:"example=docker://alpine:latest,example=dockerfile://build-default.Dockerfile"` // image used for container of this builder
142143
MountSource string `json:"mount_source,omitempty"`
143144
MountDestination string `json:"mount_destination"`
144145
Workdir string `json:"workdir,omitempty"`
145-
Commands BuilderCommands `json:"commands"`
146+
Commands BuilderCommands `json:"commands"` // commands used to build / develop / etc. the project
146147
DevPorts []string `json:"dev_ports,omitempty"`
147-
DevHttpIngress string `json:"dev_http_ingress,omitempty"`
148-
DevProTips []string `json:"dev_pro_tips,omitempty"`
148+
DevHttpIngress string `json:"dev_http_ingress,omitempty" jsonschema:"example=80"`
149+
DevProTips []string `json:"dev_pro_tips,omitempty"` // pro-tips e.g. commands the user can run inside the builder to lint / launch / etc. the project
149150
DevShellCommands []DevShellCommand `json:"dev_shell_commands,omitempty"` // injected as history for quick recall (ctrl + r)
150151
Envs map[string]string `json:"env,omitempty"`
151152
PassEnvs []string `json:"pass_envs,omitempty"`
152-
ContextlessBuild bool `json:"contextless_build,omitempty"`
153+
ContextlessBuild bool `json:"contextless_build,omitempty"` // (DEPRECATED) build without uploading any files to the build context
153154
}
154155

155156
type DevShellCommand struct {
156-
Command string `json:"command"`
157+
Command string `json:"command"` // command to run to achieve the specific task
157158
Important bool `json:"important"` // important commands are shown as pro-tips on "$ bob dev"
158159
}
159160

160161
type DockerImageSpec struct {
161-
Image string `json:"image"`
162-
DockerfilePath string `json:"dockerfile_path"`
163-
AuthType *string `json:"auth_type"` // creds_from_env
164-
Platforms []string `json:"platforms,omitempty"` // if set, uses buildx
165-
TagLatest bool `json:"tag_latest"`
162+
Image string `json:"image" jsonschema:"example=myorg/myproject"` // image ref (without the tag) to which to push the image
163+
DockerfilePath string `json:"dockerfile_path" jsonschema:"example=Dockerfile"` // where to find the `Dockerfile` from
164+
AuthType *string `json:"auth_type"` // creds_from_env
165+
Platforms []string `json:"platforms,omitempty"` // platforms to build for, in `$ docker build --platform=...` syntax
166+
TagLatest bool `json:"tag_latest"` // whether to publish the `:latest` tag
166167
}
167168

168169
// FIXME: Bobfile should actually be read only after correct

0 commit comments

Comments
 (0)