Real-world Examples
Docker Compose Schema
Common Docker Compose Structure
services:
web:
image: nginx:latest
ports:
- "80:80"
environment:
- NODE_ENV=production
volumes:
- ./app:/app
CSL Implementation
config DockerCompose {
services: {
*: { // Wildcard service names
image?: string @regex(".+:.+");
build?: {
context: string;
dockerfile?: string;
};
ports?: string[] @regex("^\\d+:\\d+$");
environment?: {
*: string | number | boolean;
};
volumes?: string[];
networks?: string[];
constraints {
conflicts build with image;
validate exists(ports) ? environment.NODE_ENV != "test" : true;
}
};
};
volumes?: {
*: {}; // Anonymous volumes
};
networks?: {
*: { // Network definitions
driver?: "bridge" | "overlay";
external?: boolean;
};
};
}
Key CSL Features Used
- Wildcard service names (
*:
)
- Type unions for environment values
- Conflict constraints between build/image
- Regex validation for image tags and ports
GitHub Actions Workflow
Typical GitHub Actions File
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: npm test
CSL Schema
config GitHubActions {
name: string;
on: string | string[] | {
push?: { branches?: string[] };
pull_request?: { paths?: string[] };
};
env?: {
*: string | number;
};
jobs: {
*: { // Job names
runs-on: "ubuntu-latest" | "macos-latest" | "windows-latest";
needs?: string[];
steps: {
name?: string;
uses?: string @regex("^actions/");
run?: string;
with?: {
*: string | number | boolean;
};
constraints {
validate exists(uses) || exists(run);
conflicts uses with run;
validate uses ? with : true;
}
}[];
};
};
}
Key Validation Rules
- Mutually exclusive
uses
and run
- Action path validation for trusted sources
- Environment variable type safety
- Supported runner OS constraints
AWS CloudFormation Template
Sample Resource
Resources:
MyBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-app-bucket
AccessControl: Private
CorsConfiguration:
CorsRules:
- AllowedOrigins: ["*"]
CSL Schema
config CloudFormation {
Resources: {
*: { // Resource names
Type: string @start_with("AWS::");
Properties: any{}; // Flexible properties
DependsOn?: string | string[];
Metadata?: any{};
constraints {
validate Type == "AWS::S3::Bucket" ?
Properties.BucketName @regex("^[a-z0-9-]+$") :
true;
}
};
};
Parameters?: {
*: {
Type: "String" | "Number" | "List";
Default?: string | number;
AllowedValues?: any[];
};
};
Outputs?: {
*: {
Value: string;
Export?: { Name: string };
};
};
}
Notable Implementations
- Dynamic resource type validation
- Complex regex constraints for specific resources
- Flexible
any{}
for AWS property complexity
- Parameter type safety
Docker Compose Schema
Common Docker Compose Structure
services:
web:
image: nginx:latest
ports:
- "80:80"
environment:
- NODE_ENV=production
volumes:
- ./app:/app
CSL Implementation
config DockerCompose {
services: {
*: { // Wildcard service names
image?: string @regex(".+:.+");
build?: {
context: string;
dockerfile?: string;
};
ports?: string[] @regex("^\\d+:\\d+$");
environment?: {
*: string | number | boolean;
};
volumes?: string[];
networks?: string[];
constraints {
conflicts build with image;
validate exists(ports) ? environment.NODE_ENV != "test" : true;
}
};
};
volumes?: {
*: {}; // Anonymous volumes
};
networks?: {
*: { // Network definitions
driver?: "bridge" | "overlay";
external?: boolean;
};
};
}
Key CSL Features Used
- Wildcard service names (
*:
) - Type unions for environment values
- Conflict constraints between build/image
- Regex validation for image tags and ports
GitHub Actions Workflow
Typical GitHub Actions File
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: npm test
CSL Schema
config GitHubActions {
name: string;
on: string | string[] | {
push?: { branches?: string[] };
pull_request?: { paths?: string[] };
};
env?: {
*: string | number;
};
jobs: {
*: { // Job names
runs-on: "ubuntu-latest" | "macos-latest" | "windows-latest";
needs?: string[];
steps: {
name?: string;
uses?: string @regex("^actions/");
run?: string;
with?: {
*: string | number | boolean;
};
constraints {
validate exists(uses) || exists(run);
conflicts uses with run;
validate uses ? with : true;
}
}[];
};
};
}
Key Validation Rules
- Mutually exclusive
uses
andrun
- Action path validation for trusted sources
- Environment variable type safety
- Supported runner OS constraints
AWS CloudFormation Template
Sample Resource
Resources:
MyBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: my-app-bucket
AccessControl: Private
CorsConfiguration:
CorsRules:
- AllowedOrigins: ["*"]
CSL Schema
config CloudFormation {
Resources: {
*: { // Resource names
Type: string @start_with("AWS::");
Properties: any{}; // Flexible properties
DependsOn?: string | string[];
Metadata?: any{};
constraints {
validate Type == "AWS::S3::Bucket" ?
Properties.BucketName @regex("^[a-z0-9-]+$") :
true;
}
};
};
Parameters?: {
*: {
Type: "String" | "Number" | "List";
Default?: string | number;
AllowedValues?: any[];
};
};
Outputs?: {
*: {
Value: string;
Export?: { Name: string };
};
};
}
Notable Implementations
- Dynamic resource type validation
- Complex regex constraints for specific resources
- Flexible
any{}
for AWS property complexity - Parameter type safety