summaryrefslogtreecommitdiff
path: root/schema/baserock-example.schema
blob: 8ead42f18f884546bbce00fa26cc286117f460a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
# Baserock Definitions schema example

# This is an attempt to describe the data model part of Baserock definitions
# format.
#
# See also: http://wiki.baserock.org/definitions/current/
#
# This is not a brilliant schema, in Linked Data terms, because it's using
# Baserock-specific terminology and a rigid layout, instead of being a generic
# vocabulary for describing how to assemble software. However, it maps closely
# to existing data (the Baserock reference systems).
#
# This is an OWL ontology represented as RDF/Turtle data.

# NOTE: I absolutely HATE CamelCase but it seems to be the convention for RDF
# property names. I'm undecided on whether it's worse to condemning everyone
# to using stupidCamelCaseNames for things, or worse to make a schema that is
# inconsistent with the rest of the Linked Data world.

# Things you can do with this:
#
# Check it is syntactically valid:
#  rapper -i turtle baserock-example.schema
#
# Visualise it in a rubbish way:
#  rapper -i turtle -o dot baserock-example.schema | dot -Tpng > schema.png
#
# (Rapper is part of the 'raptor2' package on most distros.
#  See: http://librdf.org/)
#
# Check for common mistakes:
#  ln -s ./baserock-example.schema ./baserock-example.owl
#  cd /path/to/owllint
#  sbt "run /path/to/baserock/definitions/schema"
#
# (owLint is a tool written in Scala, it is likely not packaged for your
#  distro, but if you install Scala and the `sbt` build tool, you can build
#  and run it from sources at <https://github.com/Samangan/owLint>. The schema
#  has various issues according to owLint which I haven't figured out.)
#
# Edit with Protégé:
#  just open it in protege, it can save to Turtle format as well but will lose
#  comments and formatting.
#
# (Protégé is a Java application for editing OWL ontologies. I prefer to edit
#  them as Turtle text files but maybe you like compex GUIs.
#  See: http://protege.stanford.edu/products.php#desktop-protege)
#
# Browse it using the example browser program.
#   See: browser/README.txt

## An RDF/OWL primer, for people who aren't familiar with it:
#
# domain: the set of objects that a can have a property.
# range: the set of possible values for a property.
#
# ObjectProperty:
#   a property whose value must be another resource.
# DatatypeProperty:
#   a property whose value is one of the datatype defined by XML Schema ("xsd")
# FunctionalProperty:
#   a property which can only have one value per resource
# InverseFunctionalProperty:
#   a property which can only have one resource per value


# Metadata

@prefix : <http://baserock.org/definitions/example-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

: a owl:Ontology ;
  dc:title "Example schema for Baserock Definitions format version 5." ;
  dc:creator "The Baserock Project" ;
  # Versioned according to Semantic Versioning http://www.semver.org/
  owl:versionInfo "0.1.0" .


## Entities

# Source definitions

:Morphology a owl:Class ;
   rdfs:comment "A definition file." .

:Cluster a owl:Class ;
   rdfs:subClassOf :Morphology ;
   rdfs:comment "Instructions for deploying one or systems." ;
   owl:disjointWith :System, :Stratum, :Chunk .

:System a owl:Class ;
   rdfs:subClassOf :Morphology ;
   rdfs:comment "A collection of strata in a form that can be executed." ;
   owl:disjointWith :Cluster, :Stratum, :Chunk .

:Stratum a owl:Class ;
   rdfs:subClassOf :Morphology ;
   rdfs:comment "A set of related chunks." ;
   owl:disjointWith :Cluster, :System, :Chunk .

:Chunk a owl:Class ;
   rdfs:subClassOf :Morphology ;
   rdfs:comment "An individual component, that can be built from a Git repository." ;
   owl:disjointWith :Cluster, :System, :Stratum .

# Container contents

:SystemDeployment a owl:Class ;
   rdfs:comment "Information for deploying one system of a cluster." .

:ChunkReference a owl:Class ;
   rdfs:comment "An instance of a chunk within a stratum." .

# Products (for artifact split rules).

:Artifact a owl:Class ;
   rdfs:comment "One part of the result of building a morphology. The output of a build is split according to patterns, so there are multiple artifacts produced for a given source." .

:StratumArtifact a owl:Class ;
   rdfs:subClassOf :Artifact ;
   rdfs:comment "Part of the result of building a stratum." ;
   owl:disjointWith :ChunkArtifact.

:ChunkArtifact a owl:Class ;
   rdfs:subClassOf :Artifact ;
   rdfs:comment "Part of the result of building a chunk." ;
   owl:disjointWith :StratumArtifact.


## Shared properties

# 'name' becomes part of the URL when we import definition .morph files as RDF,
# so it doesn't need a property.

# Use dc:description for 'description', see:
# http://dublincore.org/documents/2012/06/14/dcmi-terms/?v=terms#terms-description


## Cluster-specific properties

:containsSystemDeployment a owl:ObjectProperty ;
  rdfs:domain :Cluster ;
  rdfs:range :SystemDeployment ;
  owl:minCardinality 1 .


## SystemDeployment-specific properties

:deploysSystem a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :SystemDeployment ;
  rdfs:range :System .

:hasLabel a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :SystemDeployment ;
  rdfs:range xsd:string .

:hasType a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :SystemDeployment ;
  rdfs:range xsd:string ;
  rdfs:comment "The .write extension used to perform the deployment." .

:hasLocation a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :SystemDeployment ;
  rdfs:range xsd:string ;
  rdfs:comment "Deployment location. This is passed to the selected .write extension" .

# FIXME: this is actually a key-value mapping, how do you do that in RDF properly?
:hasConfigurationSetting a owl:DatatypeProperty ;
  rdfs:domain :SystemDeployment ;
  rdfs:range xsd:string ;
  rdfs:comment "Arbitrary key=value pair that is set in the environment of the .configure and .write extensions during deployment." .


## System-specific properties

:containsStratumArtifact a owl:ObjectProperty ;
  rdfs:domain :System ;
  rdfs:range :StratumArtifact ;
  owl:minCardinality 1 .

# A build tool will only understand a certain set of architectures, but I think
# that should not be part of the data model.
:hasArchitecture a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :System ;
  rdfs:range xsd:string .

:hasConfigurationExtension a owl:DatatypeProperty ;
  rdfs:domain :System ;
  rdfs:range xsd:string ;
  rdfs:comment "A .configure extension to be run when with system is deployed." .


## Stratum-specific properties

:producesStratumArtifact a owl:ObjectProperty , rdf:Seq ;
  rdfs:domain :Stratum ;
  rdfs:range :StratumArtifact ;
  rdfs:comment "Describes how this artifact is split once all chunks are built." .

:hasStratumBuildDependency a owl:ObjectProperty ;
  rdfs:domain :Stratum ;
  rdfs:range :Stratum .

:containsChunkReference a owl:ObjectProperty ;
  rdfs:domain :Stratum ;
  rdfs:range :ChunkReference ;
  owl:minCardinality 1 .


## ChunkReference-specific properties

:refersToChunk a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range :Chunk .

:repo a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range xsd:string ;
  rdfs:comment "Git repo that this chunk's build instructions should be run in. Can be a keyed URL according to the repo-alias mapping, which isn't currently defined in this data model." .

:ref a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range xsd:string ;
  rdfs:comment "Ref of the Git repo that should be checked out before building. Usually a SHA1." .

:unpetrifyRef a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range xsd:string ;
  rdfs:comment "Name of the ref that should be checked out (useful when 'ref' is a SHA1 to keep track of the actual branch/tag name)." .

:hasChunkBuildDependency a owl:ObjectProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range :Chunk .

:prefix a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range xsd:string ;
  rdfs:comment "Value of the PREFIX environment variable in the build environment (defaults to /usr)" .

# FIXME: it's possible to specify in OWL that 'bootstrap' and 'normal' are the
# only valid values.
:buildMode a owl:DatatypeProperty , owl:FunctionalProperty ;
  rdfs:domain :ChunkReference ;
  rdfs:range xsd:string .


## Chunk-specific properties

# build-system isn't included here, as it overlaps with the *-commands
# fields in an unfortunate way.

# Note that representing lists of things in RDF is a bit of a pain.
# http://smiy.sourceforge.net/olo/spec/orderedlistontology.html might
# be worth investigating.

:producesChunkArtifact a owl:ObjectProperty , rdf:Seq ;
  rdfs:domain :Chunk ;
  rdfs:range :ChunkArtifact ;
  rdfs:comment "Describes how this artifact is split once built." .

:CommandSequence a owl:Class ;
  rdfs:subClassOf rdf:Seq ;
  rdfs:comment "An ordered sequence of commands." .

:preConfigureCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:configureCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:postConfigureCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:preBuildCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:buildCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:postBuildCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:preInstallCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:installCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .

:postInstallCommands a owl:ObjectProperty , owl:FunctionalProperty ;
  rdfs:domain :Chunk ;
  rdfs:range :CommandSequence .


# Artifact properties

:includes a owl:DatatypeProperty , rdf:Seq ;
  rdfs:domain :Artifact ;
  rdfs:range xsd:string ;
  rdfs:comment "A regular expression pattern. The results of a build are matched against this pattern and any that match will be included in that artifact." .