Configuration
Project layout
Here is a recommended project layout
Agent
When in agent mode, the spectral.json
configuration file contains multiple project declarations. Each project in this file will point to its ruleset and inputs. Spectral will run and remain up, putting each scan job on a schedule.
Rules and input distribution are up to the user. For example, the agentcould run in each application host, and scan all deployed applications or application resources (e.g. logs) on that host. In this case the responsibility of updating the central agent config and putting rules on that machine is on the deployment infrastructure.
CI
When in CI mode, Spectral runs and reports its findings once. Typically in this mode we focus Spectral on a single project (although in a monorepo environment we can give it multiple projects, similar to the agent mode).
Configuration Lookup
You have several options for configuration lookup:
- Specify explicitly:
$ spectral -c config-file.json
. The configuration file in this case specifies explicitly where rules, ignores, and more are located. - Run without specifying a configuration file:
$ spectral
. In this case Spectral will look for.spectral/spectral.json
. - If Spectral did not fine a
.spectral/spectral.json
it will run in Project Mode, meaning it will use all-defaults to scan the current folder, using rules located at.spectral/rules
and ignores located in.spectral/project-name.ignores.json
. Project name is the current folder name.
Here is a sample project layout that works well, using the .spectral/
folder:
Spectral Central
When using Central (Spectral's Event Hub), you give Spectral your URL, and a single project configuration.