Back to articles
Pkl Has a Free Configuration API from Apple That Replaces YAML and JSON
NewsDevOps

Pkl Has a Free Configuration API from Apple That Replaces YAML and JSON

via Dev.to DevOpsAlex Spinov

Pkl is a configuration language from Apple that catches errors before deployment. Type-safe, programmable configs that generate YAML, JSON, or any format. Basic Syntax // config.pkl name = "my-app" port = 8080 debug = false database { host = "localhost" port = 5432 name = "mydb" maxConnections = 20 } features { enableNewUI = true maxUploadSizeMB = 50 } Type Safety // AppConfig.pkl — define your schema class DatabaseConfig { host: String port: UInt16 // Must be 0-65535 name: String maxConnections: Int(isBetween(1, 100)) // Validated! } class AppConfig { name: String port: UInt16 debug: Boolean database: DatabaseConfig } // If someone sets maxConnections = 200, Pkl catches it at generation time Generate YAML/JSON # Generate YAML pkl eval config.pkl -f yaml # Output: # name: my-app # port: 8080 # database: # host: localhost # port: 5432 # Generate JSON pkl eval config.pkl -f json # Generate for Kubernetes pkl eval k8s-deployment.pkl -f yaml > deployment.yaml Programmable Configs // enviro

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
6 views

Related Articles