├── packages ├── pkl.csv │ ├── PklProject.deps.json │ └── PklProject ├── pkl.lua │ ├── PklProject.deps.json │ ├── tests │ │ └── fixtures │ │ │ ├── comment.lua │ │ │ └── sample.lua │ └── PklProject ├── pkl.table │ ├── PklProject.deps.json │ └── PklProject ├── pkl.toml │ ├── PklProject.deps.json │ ├── PklProject │ ├── tests │ │ ├── toml.pkl │ │ └── toml.pkl-expected.pcf │ └── examples │ │ ├── converters.pkl │ │ ├── dates.pkl │ │ └── basic.pkl ├── com.circleci.v2 │ ├── PklProject.deps.json │ ├── PklProject │ ├── tests │ │ └── Config.pkl │ └── examples │ │ ├── concurrent_workflow.pkl │ │ └── typed_orb_steps.pkl ├── io.prometheus │ ├── PklProject.deps.json │ ├── tests │ │ ├── configuration.pkl-expected.pcf │ │ ├── rule.pkl-expected.pcf │ │ ├── rule.pkl │ │ └── configuration.pkl │ ├── PklProject │ ├── examples │ │ ├── configuration.pkl │ │ └── rule.pkl │ └── PrometheusObject.pkl ├── org.apache.spark │ ├── PklProject.deps.json │ ├── tests │ │ ├── PropertiesBase.pkl-expected.pcf │ │ ├── utils.pkl-expected.pcf │ │ ├── PropertiesBase.pkl │ │ └── utils.pkl │ ├── PklProject │ └── PropertiesBase.pkl ├── org.openapis.v3 │ ├── PklProject.deps.json │ ├── PklProject │ ├── License.pkl │ ├── tests │ │ ├── Document.pkl │ │ └── expressions.pkl │ ├── Contact.pkl │ ├── ExternalDocs.pkl │ ├── Tag.pkl │ ├── Reference.pkl │ ├── RequestBody.pkl │ ├── Server.pkl │ ├── Security.pkl │ ├── Example.pkl │ ├── Header.pkl │ ├── ServerVariable.pkl │ ├── Info.pkl │ ├── Response.pkl │ ├── SecurityScheme.pkl │ ├── OAuthFlows.pkl │ └── MediaType.pkl ├── pkl.experimental.net │ ├── PklProject.deps.json │ ├── PklProject │ └── tests │ │ ├── u128.pkl-expected.pcf │ │ └── net.pkl-expected.pcf ├── pkl.experimental.uri │ ├── PklProject.deps.json │ └── PklProject ├── pkl.experimental.syntax │ ├── PklProject.deps.json │ ├── tests │ │ ├── ObjectBodyNode.pkl-expected.pcf │ │ ├── ExpressionNode.pkl-expected.pcf │ │ ├── ClassNode.pkl │ │ ├── ModuleNode.pkl-expected.pcf │ │ └── ClassOrModuleNode.pkl │ ├── PklProject │ ├── TypeAnnotationNode.pkl │ ├── QualifiedIdentifierNode.pkl │ ├── AnnotationNode.pkl │ ├── ParameterNode.pkl │ ├── Node.pkl │ ├── TypeAliasNode.pkl │ ├── IdentifierNode.pkl │ ├── ClassNode.pkl │ └── DocCommentNode.pkl ├── pkl.experimental.deepToTyped │ ├── PklProject.deps.json │ └── PklProject ├── k8s.contrib │ ├── tests │ │ ├── fixtures │ │ │ ├── custom.yml │ │ │ ├── multipleVersions.yml │ │ │ ├── datasizes.yml │ │ │ ├── glusterfs.yml │ │ │ └── CustomType.pkl │ │ └── convert.pkl │ ├── PklProject.deps.json │ └── PklProject ├── com.influxdata.telegraf │ ├── PklProject.deps.json │ ├── plugins │ │ ├── serializers │ │ │ ├── OutputDataFormat.pkl │ │ │ └── JsonOutputDataFormat.pkl │ │ ├── parsers │ │ │ └── InputDataFormat.pkl │ │ ├── outputs │ │ │ ├── DiscardOutput.pkl │ │ │ ├── Output.pkl │ │ │ ├── FileOutput.pkl │ │ │ └── PrometheusClientOutput.pkl │ │ ├── processors │ │ │ ├── Processor.pkl │ │ │ └── StarlarkProcessor.pkl │ │ └── inputs │ │ │ ├── SolrInput.pkl │ │ │ ├── CpuInput.pkl │ │ │ ├── DiskInput.pkl │ │ │ ├── NetInput.pkl │ │ │ ├── FileInput.pkl │ │ │ ├── OpenTelemetry.pkl │ │ │ ├── Input.pkl │ │ │ ├── ExecInput.pkl │ │ │ └── HttpInput.pkl │ ├── PklProject │ ├── tests │ │ ├── Telegraf.pkl │ │ └── Telegraf.pkl-expected.pcf │ └── examples │ │ ├── opentelemetry-output.pkl │ │ └── simple.pkl ├── org.openapis.v3.contrib │ ├── PklProject.deps.json │ ├── tests │ │ └── fixtures │ │ │ └── SelfReference.pkl │ ├── PklProject │ └── examples │ │ ├── Finch.pkl │ │ ├── SampleAPI.pkl │ │ └── SwallowSchema.pkl ├── org.json_schema │ ├── PklProject.deps.json │ └── PklProject ├── k8s.contrib.appEnvCluster │ ├── PklProject.deps.json │ └── PklProject ├── pkl.pipe │ ├── examples │ │ ├── k8s_deployment.yaml │ │ ├── k8s_service_and_pod.yaml │ │ ├── k8s_deployment_images.pkl │ │ ├── k8s_name_and_kind.pkl │ │ └── github_repos_stars.pkl │ ├── PklProject.deps.json │ ├── tests │ │ ├── examples.pkl │ │ └── examples.pkl-expected.pcf │ ├── PklProject │ ├── kubeval.pkl │ ├── json.pkl │ ├── yaml.pkl │ └── shellshortcuts.pkl ├── org.json_schema.contrib │ ├── PklProject.deps.json │ ├── internal │ │ ├── Type.pkl │ │ └── ModulesGenerator.pkl │ ├── PklProject │ └── tests │ │ ├── TypesGenerator.pkl-expected.pcf │ │ └── ref.pkl ├── k8s.contrib.crd │ ├── PklProject │ ├── PklProject.deps.json │ └── tests │ │ └── ModuleGenerator.pkl └── basePklProject.pkl ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── .gitignore ├── .gitattributes ├── settings.gradle.kts ├── MAINTAINERS.adoc ├── SECURITY.adoc ├── README.adoc ├── CONTRIBUTING.adoc └── NOTICE.txt /packages/pkl.csv/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.lua/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.table/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.toml/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/com.circleci.v2/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/io.prometheus/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/org.apache.spark/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/org.openapis.v3/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.experimental.net/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.experimental.uri/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/freynder/pkl-pantry/main/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/pkl.experimental.deepToTyped/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": {} 4 | } -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/fixtures/custom.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Custom 3 | metadata: 4 | name: my-custom-type 5 | spec: 6 | field1: foo 7 | field2: bar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | 3 | # Ignore Gradle project-specific cache directory 4 | .gradle 5 | 6 | # Ignore Gradle build output directory 7 | build 8 | 9 | .DS_Store 10 | 11 | .out/ 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | mavenCentral() 4 | gradlePluginPortal() 5 | } 6 | } 7 | 8 | plugins { 9 | id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0" 10 | } 11 | 12 | rootProject.name = "pkl-pantry" 13 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1": { 5 | "type": "local", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.1", 7 | "path": "../pkl.toml" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3@2": { 5 | "type": "local", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.openapis.v3@2.1.2", 7 | "path": "../org.openapis.v3" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /packages/org.json_schema/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { 5 | "type": "local", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3", 7 | "path": "../pkl.experimental.uri" 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /packages/pkl.lua/tests/fixtures/comment.lua: -------------------------------------------------------------------------------- 1 | -- This is a copy of the sample file from the Parser doc comment 2 | --[[ 3 | This file has a header comment. 4 | ]] 5 | foo="bar" 6 | count=2 7 | -- line comment here 8 | enable=true 9 | frob=nil 10 | ports={80, 443} 11 | ips={ 12 | localhost = "127.0.0.1"; 13 | ["example.com"] = "93.184.215.14"; 14 | } 15 | _ENV[" "]="space" -------------------------------------------------------------------------------- /MAINTAINERS.adoc: -------------------------------------------------------------------------------- 1 | = MAINTAINERS 2 | 3 | This page lists all active Maintainers of this repository. 4 | 5 | See link:CONTRIBUTING.adoc[] for general contribution guidelines. 6 | 7 | == Maintainers (in alphabetical order) 8 | 9 | * https://github.com/bioball[Daniel Chao] 10 | * https://github.com/stackoverflow[Islon Scherer] 11 | * https://github.com/holzensp[Philip Hölzenspies] 12 | -------------------------------------------------------------------------------- /packages/k8s.contrib.appEnvCluster/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-k8s/k8s@1": { 5 | "type": "remote", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1", 7 | "checksums": { 8 | "sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a" 9 | } 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /packages/org.apache.spark/tests/PropertiesBase.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["rendering properties"] { 3 | """ 4 | spark.core.numbers = 5 5 | spark.driver.something = some driver setting 6 | spark.executor.something = some executor setting 7 | spark.shards.1.setting.this-node.memory = 5g 8 | spark.kubernetes.some.type.of.memory = 10Gi 9 | spark.some.type.of.duration = 5min 10 | 11 | """ 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/io.prometheus/tests/configuration.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["basic configuration"] { 3 | """ 4 | global: 5 | scrape_timeout: 10s 6 | scrape_configs: 7 | - job_name: my-job 8 | kubernetes_sd_configs: 9 | - role: pod 10 | relabel_configs: 11 | - regex: .*? 12 | remote_write: 13 | - url: https://example.com/remote_write 14 | sigv4: 15 | region: us-west-2 16 | 17 | """ 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/fixtures/multipleVersions.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: foo.bar.baz 5 | --- 6 | apiVersion: apiextensions.k8s.io/v1 7 | kind: CustomResourceDefinition 8 | metadata: 9 | name: foo.bar.baz 10 | --- 11 | apiVersion: apiextensions.k8s.io/v1beta1 12 | kind: CustomResourceDefinition 13 | metadata: 14 | name: foo.bar.biz 15 | --- 16 | apiVersion: apiextensions.k8s.io/v1 17 | kind: CustomResourceDefinition 18 | metadata: 19 | name: foo.bar.qux -------------------------------------------------------------------------------- /packages/pkl.pipe/examples/k8s_deployment.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: apps/v1 3 | kind: Deployment 4 | metadata: 5 | name: nginx-deployment 6 | labels: 7 | app: nginx 8 | spec: 9 | replicas: 3 10 | selector: 11 | matchLabels: 12 | app: nginx 13 | template: 14 | metadata: 15 | labels: 16 | app: nginx 17 | spec: 18 | containers: 19 | - name: nginx 20 | image: nginx:1.14.2 21 | ports: 22 | - containerPort: 80 23 | - name: splunk 24 | image: splunkforwarder:1234 25 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [versions] 2 | pkl = "0.26.+" 3 | kotlin = "1.9.0" 4 | junit = "5.10.0" 5 | spotless = "6.25.0" 6 | 7 | [libraries] 8 | junitEngine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" } 9 | junitParams = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" } 10 | pklCore = { group = "org.pkl-lang", name = "pkl-core", version.ref = "pkl" } 11 | 12 | [plugins] 13 | pkl = { id = "org.pkl-lang", version.ref = "pkl" } 14 | spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } 15 | -------------------------------------------------------------------------------- /packages/pkl.pipe/examples/k8s_service_and_pod.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: v1 3 | kind: Pod 4 | metadata: 5 | name: nginx 6 | labels: 7 | app.kubernetes.io/name: proxy 8 | spec: 9 | containers: 10 | - name: nginx 11 | image: nginx:stable 12 | ports: 13 | - containerPort: 80 14 | name: http-web-svc 15 | 16 | --- 17 | apiVersion: v1 18 | kind: Service 19 | metadata: 20 | name: nginx-service 21 | spec: 22 | selector: 23 | app.kubernetes.io/name: proxy 24 | ports: 25 | - name: name-of-service-port 26 | protocol: TCP 27 | port: 80 28 | targetPort: http-web-svc 29 | -------------------------------------------------------------------------------- /packages/org.apache.spark/tests/utils.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["convertIndexedProperty"] { 3 | Map("foo.bar.1.biz.11", "eleven", "foo.bar.1.biz.12", "twelve", "foo.bar.2.biz.22", "two") 4 | Map("foo.bar.1.biz", 1, "foo.bar.2.biz", 2) 5 | } 6 | ["flattenMapKeys"] { 7 | Map(List(".1", ".11"), "eleven", List(".1", ".12"), "twelve", List(".2", ".22"), "two") 8 | } 9 | ["convertProperty"] { 10 | Map("foo.bar.baz", 1) 11 | Map("foo.env.FOO", "foo", "foo.env.BAR", "bar") 12 | Map("foo.env.FOO.buz.BAR", "bar") 13 | Map("spark.kubernetes.baz", "5Gi") 14 | Map("spark.memory", "5g") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/k8s.contrib/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-k8s/k8s@1": { 5 | "type": "remote", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1", 7 | "checksums": { 8 | "sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a" 9 | } 10 | }, 11 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { 12 | "type": "local", 13 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3", 14 | "path": "../pkl.experimental.uri" 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /packages/pkl.lua/tests/fixtures/sample.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This is an example config file written in Lua. 3 | It consists of key/value pairs and only literals, no expressions. 4 | ]] 5 | greeting="Hello, world!" 6 | snippet=[=[ 7 | Long Lua strings can be written inside brackets like this: [[ 8 | This is a multiline string. 9 | It ends at the close double-bracket.]] 10 | ]=] 11 | hex_floats={ 12 | 0x10.0, 13 | 0x0.fffff, 14 | -0x32p3, 15 | } 16 | tableKeys={ 17 | identifier = true; 18 | ["string"] = "yes"; 19 | [42] = "the meaning of life"; 20 | [3.14159] = "pi"; 21 | [true] = "very true"; 22 | [{1, 2, 3}] = "even tables can be keys"; 23 | -- but nil and NaN cannot 24 | } 25 | -------------------------------------------------------------------------------- /packages/io.prometheus/tests/rule.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["basic rule"] { 3 | """ 4 | groups: 5 | - name: alerting_rules 6 | interval: 5m 7 | rules: 8 | - alert: HighRequestLatency 9 | expr: job:request_latency_seconds:mean5m{job="myjob"} > 0.5 10 | for: 10m 11 | labels: 12 | prod: true 13 | priority: 1 14 | severity: page 15 | annotations: 16 | summary: High request latency 17 | - name: recording_rules 18 | interval: 10h 19 | rules: 20 | - record: job:http_inprogress_requests:sum 21 | expr: sum by (job) (http_inprogress_requests) 22 | 23 | """ 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/fixtures/datasizes.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Pod 3 | metadata: 4 | name: various-datasizes 5 | spec: 6 | containers: 7 | - name: kilobytes 8 | resources: 9 | requests: 10 | memory: 1k 11 | 12 | - name: kebibytes 13 | resources: 14 | requests: 15 | memory: 1Ki 16 | 17 | - name: mebibytes 18 | resources: 19 | requests: 20 | memory: 1Mi 21 | 22 | - name: exbibytes 23 | resources: 24 | requests: 25 | memory: 1Ei 26 | 27 | - name: exabytes 28 | resources: 29 | requests: 30 | memory: 1E 31 | 32 | - name: fractional-gigabytes 33 | resources: 34 | requests: 35 | memory: 0.5Gi -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/tests/ObjectBodyNode.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["for generator"] { 3 | """ 4 | { 5 | for (person in people) { 6 | person.name 7 | } 8 | } 9 | """ 10 | """ 11 | { 12 | for (person: Person in people) { 13 | person.name 14 | } 15 | } 16 | """ 17 | """ 18 | { 19 | for (personIndex, person in people) { 20 | person.name 21 | } 22 | } 23 | """ 24 | """ 25 | { 26 | for (personIndex: Int, person: Person in people) { 27 | person.name 28 | } 29 | } 30 | """ 31 | } 32 | ["when generator"] { 33 | """ 34 | { 35 | when (test) { 36 | conditionalProperty = true 37 | } 38 | } 39 | """ 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /SECURITY.adoc: -------------------------------------------------------------------------------- 1 | = Security 2 | 3 | For the protection of our community, the Pkl team does not disclose, discuss, or confirm security issues until our investigation is complete and any necessary updates are generally available. 4 | 5 | == Reporting a security vulnerability 6 | 7 | If you have discovered a security vulnerability within the Pkl Pantry project, please report it to us. 8 | We welcome reports from everyone, including security researchers, developers, and users. 9 | 10 | Security vulnerabilities may be reported on the link:https://security.apple.com/submit[Report a vulnerability] form. 11 | When submitting a vulnerability, select "Apple Devices and Software" as the affected platform, and "Open Source" as the affected area. 12 | 13 | For more information, see https://pkl-lang.org/security.html. 14 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1": { 5 | "type": "local", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.0.3", 7 | "path": "../pkl.experimental.syntax" 8 | }, 9 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { 10 | "type": "local", 11 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3", 12 | "path": "../pkl.experimental.uri" 13 | }, 14 | "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1": { 15 | "type": "local", 16 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.0.4", 17 | "path": "../org.json_schema" 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/fixtures/glusterfs.yml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Endpoints 3 | metadata: 4 | name: glusterfs-cluster 5 | subsets: 6 | - addresses: 7 | - ip: 10.240.106.152 8 | ports: 9 | - port: 1 10 | - addresses: 11 | - ip: 10.240.79.157 12 | ports: 13 | - port: 1 14 | --- 15 | apiVersion: v1 16 | kind: Pod 17 | metadata: 18 | name: glusterfs 19 | spec: 20 | containers: 21 | - name: glusterfs 22 | image: nginx 23 | volumeMounts: 24 | - mountPath: "/mnt/glusterfs" 25 | name: glusterfsvol 26 | volumes: 27 | - name: glusterfsvol 28 | glusterfs: 29 | endpoints: glusterfs-cluster 30 | path: kube_vol 31 | readOnly: true 32 | --- 33 | apiVersion: v1 34 | kind: Service 35 | metadata: 36 | name: glusterfs-cluster 37 | spec: 38 | ports: 39 | - port: 1 -------------------------------------------------------------------------------- /packages/pkl.pipe/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-pantry/k8s.contrib@1": { 5 | "type": "local", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/k8s.contrib@1.0.3", 7 | "path": "../k8s.contrib" 8 | }, 9 | "package://pkg.pkl-lang.org/pkl-k8s/k8s@1": { 10 | "type": "remote", 11 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1", 12 | "checksums": { 13 | "sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a" 14 | } 15 | }, 16 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { 17 | "type": "local", 18 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3", 19 | "path": "../pkl.experimental.uri" 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /packages/pkl.experimental.uri/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | amends "../basePklProject.pkl" 17 | 18 | package { 19 | version = "1.0.3" 20 | } 21 | -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/tests/fixtures/SelfReference.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module SelfReference 17 | 18 | import "SelfReference.pkl" 19 | 20 | myself: SelfReference 21 | -------------------------------------------------------------------------------- /packages/pkl.toml/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A [TOML](https://toml.io/en/) [Renderer]. 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.0.1" 21 | } 22 | -------------------------------------------------------------------------------- /packages/pkl.lua/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A parser and renderer for a subset of [Lua](https://www.lua.org). 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.1.1" 21 | } 22 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Modules for describing [OpenAPI](https://www.openapis.org/) v3.x 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "2.1.2" 21 | } 22 | -------------------------------------------------------------------------------- /packages/com.circleci.v2/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Templates for defining [CircleCI](https://circleci.com) configuration. 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.1.3" 21 | } 22 | -------------------------------------------------------------------------------- /packages/pkl.experimental.net/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Experimental library for handling network (IP and MAC) addresses. 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.2.1" 21 | } 22 | -------------------------------------------------------------------------------- /packages/pkl.csv/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A [RFC4180](https://www.ietf.org/rfc/rfc4180.txt) compliant CSV [Renderer] and [Parser]. 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.0.1" 21 | } 22 | -------------------------------------------------------------------------------- /packages/io.prometheus/tests/rule.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module io.prometheus.tests.rule 17 | 18 | amends "pkl:test" 19 | 20 | examples { 21 | ["basic rule"] { 22 | import("../examples/rule.pkl").output.text 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/pkl.experimental.deepToTyped/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// An experimental module that does a deep-conversion of [Dynamic] into [Typed]. 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.0.2" 21 | } 22 | -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | amends "../basePklProject.pkl" 17 | 18 | package { 19 | version = "1.0.4" 20 | } 21 | 22 | dependencies { 23 | ["openapi"] = import("../org.openapis.v3/PklProject") 24 | } 25 | -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/examples/Finch.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module darwins.Finch 17 | 18 | /// What is this beak good for? 19 | beakIsGoodFor: "nuts"|"fruits"|"insects" 20 | 21 | output { 22 | renderer = new JsonRenderer {} 23 | } 24 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Experimental Pkl syntax library 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.0.3" 21 | apiTests = import*("tests/*.pkl").keys.toListing() 22 | } 23 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | = Pkl Pantry 2 | 3 | This is a monorepo of packages that are maintained and published by the Pkl team. 4 | 5 | == Using packages 6 | 7 | Packages within this repository are published as `package://pkg.pkl-lang.org/pkl-pantry/@`. 8 | 9 | === Direct imports 10 | 11 | Modules from package can be imported directly. For example, the below line imports module `toml.pkl` from package link:packages/pkl.toml/[`pkl.toml`] at version `1.0.0`: 12 | 13 | [source,pkl] 14 | ---- 15 | import "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0#/toml.pkl" 16 | ---- 17 | 18 | === In a project 19 | 20 | If using a link:https://pkl-lang.org/main/current/language-reference/index.html#projects[project], add a package as a dependency: 21 | 22 | [source,pkl] 23 | ---- 24 | amends "pkl:Project" 25 | 26 | dependencies { 27 | ["toml"] { uri = "package://pkg.pkl-lang.org/pkl-pantry/pkl.toml@1.0.0" } 28 | } 29 | ---- 30 | 31 | == Documentation 32 | 33 | The documentation for all packages published here can be found in our 34 | link:https://pkl-lang.org/package-docs[Package Docs] website. 35 | -------------------------------------------------------------------------------- /packages/io.prometheus/tests/configuration.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module io.prometheus.tests.configuration 17 | 18 | amends "pkl:test" 19 | 20 | examples { 21 | ["basic configuration"] { 22 | import("../examples/configuration.pkl").output.text 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /packages/io.prometheus/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Templates for configuring [Prometheus](https://prometheus.io), 17 | /// an open-source systems monitoring and alerting toolkit. 18 | amends "../basePklProject.pkl" 19 | 20 | package { 21 | version = "1.1.3" 22 | } 23 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/internal/Type.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.json_schema.contrib.internal.Type 17 | 18 | import "@jsonschema/JsonSchema.pkl" 19 | import "Type.pkl" 20 | 21 | moduleName: String 22 | 23 | name: String 24 | 25 | typealias TypeNames = Map 26 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/TypeAnnotationNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.TypeAnnotationNode 17 | 18 | extends "Node.pkl" 19 | 20 | import "TypeNode.pkl" 21 | 22 | type: TypeNode 23 | 24 | function render(currentIndent: String) = ": \(type.render(currentIndent))" 25 | -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/fixtures/CustomType.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module CustomType 17 | 18 | extends "@k8s/K8sResource.pkl" 19 | 20 | fixed apiVersion = "v1" 21 | 22 | fixed kind = "Custom" 23 | 24 | spec: CustomSpec? 25 | 26 | class CustomSpec { 27 | field1: String? 28 | 29 | field2: String? 30 | } -------------------------------------------------------------------------------- /packages/pkl.table/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// [TableRenderer] generates pretty human-readable and markdown-compatible tables! 17 | amends "../basePklProject.pkl" 18 | 19 | package { 20 | version = "1.1.0" 21 | description = "Generates pretty human-readable, markdown-compatible, and HTML tables." 22 | } 23 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/License.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// License information for the exposed API. 17 | module org.openapis.v3.License 18 | 19 | /// The license name used for the API. 20 | name: String 21 | 22 | /// A URL to the license used for the API. 23 | /// 24 | /// MUST be in the format of a URL. 25 | url: Uri? 26 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/serializers/OutputDataFormat.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Base class for [output data formats](https://docs.influxdata.com/telegraf/v1.17/data_formats/output/). 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | abstract module com.influxdata.telegraf.plugins.serializers.OutputDataFormat 19 | 20 | data_format: String 21 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/parsers/InputDataFormat.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Base class for [input data formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | abstract module com.influxdata.telegraf.plugins.parsers.InputDataFormat 19 | 20 | data_format: String 21 | -------------------------------------------------------------------------------- /packages/k8s.contrib.appEnvCluster/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Template that captures the hierarchical pattern of Application, Environment, and Cluster. 17 | amends "../basePklProject.pkl" 18 | 19 | dependencies { 20 | ["k8s"] { 21 | uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" 22 | } 23 | } 24 | 25 | package { 26 | version = "1.0.2" 27 | } -------------------------------------------------------------------------------- /packages/k8s.contrib/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Utilities for handling k8s configuration in Pkl. 17 | amends "../basePklProject.pkl" 18 | 19 | dependencies { 20 | ["k8s"] { 21 | uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" 22 | } 23 | ["uri"] = import("../pkl.experimental.uri/PklProject") 24 | } 25 | 26 | package { 27 | version = "1.0.3" 28 | } -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/outputs/DiscardOutput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The Discard output plugin simply drops all metrics that are sent to it. 17 | /// 18 | /// It is only meant to be used for testing purposes. 19 | @ModuleInfo { minPklVersion = "0.25.0" } 20 | module com.influxdata.telegraf.plugins.outputs.DiscardOutput 21 | 22 | extends "Output.pkl" 23 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/tests/Document.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3.tests.Document 17 | 18 | amends "pkl:test" 19 | 20 | local allExamples = import*("../examples/*.pkl") 21 | 22 | examples { 23 | for (example in allExamples.keys) { 24 | [example.drop("../examples/".length).dropLast(4)] { 25 | allExamples[example].output.text 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Templates for configuring [Telegraf](https://docs.influxdata.com/telegraf), 17 | /// a plugin-driven server agent for collecting and reporting metrics. 18 | amends "../basePklProject.pkl" 19 | 20 | dependencies { 21 | ["toml"] = import("../pkl.toml/PklProject") 22 | } 23 | 24 | package { 25 | version = "1.2.0" 26 | } 27 | -------------------------------------------------------------------------------- /packages/com.circleci.v2/tests/Config.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module com.circleci.v2.tests.Config 17 | 18 | amends "pkl:test" 19 | 20 | local allExamples = import*("../examples/*.pkl") 21 | 22 | examples { 23 | for (example in allExamples.keys) { 24 | [example.drop("../examples/".length).replaceLast("pkl", "yaml")] { 25 | allExamples[example].output.text 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/pkl.toml/tests/toml.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.toml.tests.toml 17 | 18 | amends "pkl:test" 19 | 20 | examples { 21 | ["basic.pkl"] { 22 | import("../examples/basic.pkl").output.text 23 | } 24 | ["converters.pkl"] { 25 | import("../examples/converters.pkl").output.text 26 | } 27 | ["dates.pkl"] { 28 | import("../examples/dates.pkl").output.text 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/tests/Telegraf.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module com.influxdata.telegraf.tests.Telegraf 17 | 18 | amends "pkl:test" 19 | 20 | local allExamples = import*("../examples/*.pkl") 21 | 22 | examples { 23 | for (name in allExamples.keys) { 24 | [name.drop("../examples".length + 1).replaceLast("pkl", "toml")] { 25 | allExamples[name].output.text 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /packages/pkl.experimental.net/tests/u128.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["toString"] { 3 | "00000000000000000000000000000001" 4 | "ffffffffffffffffffffffffffffffff" 5 | "Type constraint `isBetween(0, 4294967295)` violated. Value: 4294967296" 6 | } 7 | ["and"] { 8 | "00000000000000000000000000000000" 9 | "00000000000000000000000000000000" 10 | "74ab3ef809bfce41ab38bef110efba83" 11 | "74ab3ef809bfce41ab38bef110efba83" 12 | } 13 | ["or"] { 14 | "74ab3ef809bfce41ab38bef110efba83" 15 | "74ab3ef809bfce41ab38bef110efba83" 16 | "ffffffffffffffffffffffffffffffff" 17 | "ffffffffffffffffffffffffffffffff" 18 | } 19 | ["shl"] { 20 | "00000000000000000000000000000001" 21 | "00000000000000000000000000000002" 22 | "00000000000000000000000000080000" 23 | "00000000000000000000000100000000" 24 | "00000000000000000000000200000000" 25 | "00000000000000000008000000000000" 26 | "00000000000000010000000000000000" 27 | "00000000000000020000000000000000" 28 | "00000000001000000000000000000000" 29 | } 30 | ["add"] { 31 | "00000000000000000000000000000002" 32 | "e9567df0137f9c8356717de221df7506" 33 | "74ab3ef809bfce41ab38bef110efba83" 34 | } 35 | ["seq"] { 36 | 65 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/tests/Telegraf.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["opentelemetry-output.toml"] { 3 | """ 4 | [[outputs.opentelemetry]] 5 | service_address = "localhost:4312" 6 | timeout = "10s" 7 | tls_ca = "/path/to/ca/cert" 8 | tls_cert = "/path/to/cert" 9 | tls_key = "/path/to/key" 10 | tls_server_name = "tls-server.com" 11 | compression = "gzip" 12 | 13 | [outputs.opentelemetry.coralogix] 14 | private_key = "my secret value" 15 | application = "myapp" 16 | subsystem = "my subsystem" 17 | 18 | [outputs.opentelemetry.attributes] 19 | "service.name" = "foo" 20 | "service.version" = "1.0.0" 21 | 22 | [outputs.opentelemetry.headers] 23 | x-api-key = "my-api-key" 24 | """ 25 | } 26 | ["simple.toml"] { 27 | """ 28 | [[outputs.file]] 29 | data_format = "json" 30 | json_timestamp_units = "5s" 31 | 32 | 33 | [[inputs.cpu]] 34 | percpu = false 35 | totalcpu = true 36 | 37 | [inputs.cpu.tags] 38 | tag1 = "foo" 39 | tag2 = "bar" 40 | 41 | [[inputs.http]] 42 | urls = [ "https://server.company.org/metrics" ] 43 | method = "GET" 44 | 45 | [global_tags] 46 | user = "alice" 47 | """ 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/org.json_schema/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Modules for [JSON Schema](https://json-schema.org). 17 | /// 18 | /// This package includes utilities for resolving JSON Schema references, as well as generating Pkl modules from a 19 | /// JSON Schema document. 20 | amends "../basePklProject.pkl" 21 | 22 | dependencies { 23 | ["uri"] = import("../pkl.experimental.uri/PklProject") 24 | } 25 | 26 | package { 27 | version = "1.0.4" 28 | } 29 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/QualifiedIdentifierNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// One or more identifiers, separated by dots, e.g. `foo.bar.baz` 17 | @Unlisted 18 | module pkl.experimental.syntax.QualifiedIdentifierNode 19 | 20 | extends "Node.pkl" 21 | 22 | import "IdentifierNode.pkl" 23 | 24 | parts: Listing(!isEmpty) 25 | 26 | function render(currentIndent: String) = parts.toList().map((p) -> p.render(currentIndent)).join(".") 27 | -------------------------------------------------------------------------------- /packages/pkl.pipe/tests/examples.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.pipe.tests.examples 17 | amends "pkl:test" 18 | 19 | examples { 20 | ["k8s deployment images"] { 21 | import("../examples/k8s_deployment_images.pkl").output.text 22 | } 23 | ["k8s name and kind list"] { 24 | import("../examples/k8s_name_and_kind.pkl").output.text 25 | } 26 | ["github repos and stars"] { 27 | import("../examples/github_repos_stars.pkl").output.text 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Contact.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Contact information for the exposed API. 17 | module org.openapis.v3.Contact 18 | 19 | /// The identifying name of the contact person/organization. 20 | name: String? 21 | 22 | /// The URL pointing to the contact information. MUST be in the format of a URL. 23 | url: Uri? 24 | 25 | /// The email address of the contact person/organization. 26 | /// 27 | /// MUST be in the format of an email address. 28 | email: String? 29 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/AnnotationNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.AnnotationNode 17 | 18 | extends "Node.pkl" 19 | 20 | import "QualifiedIdentifierNode.pkl" 21 | import "ObjectBodyNode.pkl" 22 | 23 | identifier: QualifiedIdentifierNode 24 | 25 | body: ObjectBodyNode? 26 | 27 | function render(currentIndent: String) = 28 | "\(currentIndent)@\(identifier.render(currentIndent))" + 29 | if (body == null) "" else " " + body.render(currentIndent) 30 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/ExternalDocs.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Allows referencing an external resource for extended documentation. 17 | module org.openapis.v3.ExternalDocs 18 | 19 | /// A short description of the target documentation. 20 | /// 21 | /// CommonMark syntax MAY be used for rich text representation. 22 | @SourceCode { language = "Markdown" } 23 | description: String? 24 | 25 | /// The URL for the target documentation. 26 | /// 27 | /// Value MUST be in the format of a URL. 28 | url: Uri? 29 | -------------------------------------------------------------------------------- /packages/pkl.pipe/tests/examples.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["k8s deployment images"] { 3 | """ 4 | nginx:1.14.2 5 | splunkforwarder:1234 6 | """ 7 | } 8 | ["k8s name and kind list"] { 9 | """ 10 | v1.Pod: nginx 11 | v1.Service: nginx-service 12 | """ 13 | } 14 | ["github repos and stars"] { 15 | """ 16 | cups: 1584 17 | swift-lldb: 666 18 | swift: 60875 19 | swift-llbuild: 977 20 | swift-package-manager: 8960 21 | swift-llvm: 814 22 | swift-clang: 672 23 | swift-evolution: 13735 24 | swift-corelibs-foundation: 4700 25 | swift-corelibs-libdispatch: 2249 26 | swift-corelibs-xctest: 1003 27 | example-package-playingcard: 267 28 | example-package-fisheryates: 174 29 | example-package-deckofplayingcards: 163 30 | example-package-dealer: 276 31 | swift-3-api-guidelines-review: 452 32 | swift-docker: 1242 33 | swift-integration-tests: 95 34 | swift-cmark: 222 35 | swift-internals: 184 36 | fstools: 40 37 | swift-compiler-rt: 95 38 | swift-xcode-playground-support: 248 39 | ccs-caldavclientlibrary: 38 40 | ccs-caldavtester: 47 41 | ccs-calendarserver: 448 42 | ccs-pyosxframeworks: 25 43 | ccs-pycalendar: 67 44 | ccs-pykerberos: 107 45 | ccs-pyopendirectory: 22 46 | """ 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Utilities for [JSON Schema](https://json-schema.org). 17 | /// 18 | /// This package includes utilities for generating Pkl from a given JSON Schema document. 19 | amends "../basePklProject.pkl" 20 | 21 | dependencies { 22 | ["jsonschema"] = import("../org.json_schema/PklProject") 23 | ["uri"] = import("../pkl.experimental.uri/PklProject") 24 | ["syntax"] = import("../pkl.experimental.syntax/PklProject") 25 | } 26 | 27 | package { 28 | version = "1.0.9" 29 | } 30 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/processors/Processor.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Processor plugins transform, decorate, and/or filter metrics collected by input plugins, 17 | /// passing the transformed metrics to the output plugins 18 | @ModuleInfo { minPklVersion = "0.25.0" } 19 | abstract module com.influxdata.telegraf.plugins.processors.Processor 20 | 21 | extends "../Plugin.pkl" 22 | 23 | /// This is the order in which processors are executed. 24 | /// 25 | /// If this is not specified, then processor execution order will be random. 26 | order: Number? 27 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/tests/ExpressionNode.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["binary operators - basic"] { 3 | #""foo" + "bar""# 4 | } 5 | ["binary operators - precedence: no parentheses when child precedence is higher"] { 6 | "5 * 5 + 5 * 5" 7 | } 8 | ["binary operators - precedence: parenthese added when child precedence is lower"] { 9 | "(5 + 5) * (5 + 5)" 10 | } 11 | ["unary operators"] { 12 | "!false" 13 | } 14 | ["unary operators - parenthesizes binary expressions"] { 15 | "-(5 + 10)" 16 | } 17 | ["member access - single identifier"] { 18 | "foo" 19 | } 20 | ["member access - method call"] { 21 | "foo(bar, biz)" 22 | } 23 | ["if/else"] { 24 | """ 25 | if (foo == "foo") 26 | "foo" 27 | else 28 | "bar" 29 | """ 30 | """ 31 | if (foo == "foo") 32 | "foo" 33 | else 34 | "bar" 35 | """ 36 | } 37 | ["super access"] { 38 | "super.someProperty" 39 | "super.someProperty(true)" 40 | } 41 | ["super subscript"] { 42 | #"super["test"]"# 43 | } 44 | ["subscript"] { 45 | #"test["key"]"# 46 | """ 47 | (if (test) 48 | testTrue 49 | else 50 | testFalse)["test" + "Key"] 51 | """ 52 | } 53 | ["read"] { 54 | #"read("env:HOME")"# 55 | #"read*("env:HOME")"# 56 | #"read?("env:HOME")"# 57 | } 58 | ["trace"] { 59 | "trace(test)" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/pkl.pipe/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Tools for constructing pipelines and one-liners in Pkl, by processing text, JSON, or YAML. 17 | /// 18 | /// Use Pkl's `--expression` (or `-x`) argument to provide a Pkl expression that will be evaluated 19 | /// in the context of the content passed to `stdin`. 20 | /// The Pkl property `pipe` (also aliased as `stdin`) represents the content that was passed to `stdin`. 21 | amends "../basePklProject.pkl" 22 | 23 | package { 24 | version = "1.0.2" 25 | } 26 | 27 | dependencies { 28 | ["k8s.contrib"] = import("../k8s.contrib/PklProject") 29 | } 30 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Tag.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Adds metadata to a single tag that is used by the Operation Object. 17 | /// 18 | /// It is not mandatory to have a Tag Object per tag defined in the Operation Object instances. 19 | module org.openapis.v3.Tag 20 | 21 | import "ExternalDocs.pkl" 22 | 23 | /// The name of the tag. 24 | name: String 25 | 26 | /// A short description for the tag. 27 | /// 28 | /// CommonMark syntax MAY be used for rich text representation. 29 | @SourceCode { language = "Markdown" } 30 | description: String? 31 | 32 | /// Additional external documentation for this tag. 33 | externalDocs: ExternalDocs? 34 | -------------------------------------------------------------------------------- /packages/pkl.pipe/examples/k8s_deployment_images.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This example shows how to parse a Kubernetes deployment object to get a list of all container images. 17 | /// It is the equivalent of the CLI invocation: 18 | /// 19 | /// ``` 20 | /// pkl eval yaml.pkl -x 'pipe.spec.template.spec.containers.toList().map((c) -> c.image).join("\n")' < examples/k8s_deployment.yaml 21 | /// ``` 22 | module pkl.pipe.examples.k8s_deployment_images 23 | amends "../yaml.pkl" 24 | 25 | input = read("./k8s_deployment.yaml") 26 | 27 | output { 28 | text = module.pipe.spec.template.spec.containers.toList().map((c) -> c.image).join("\n") 29 | } 30 | -------------------------------------------------------------------------------- /packages/pkl.pipe/examples/k8s_name_and_kind.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This example shows how to parse a Kubernetes deployment object to get a list of all container images. 17 | /// It is the equivalent of the CLI invocation: 18 | /// 19 | /// ``` 20 | /// pkl eval yaml.pkl -x 'pipe.map((r) -> "\(r.apiVersion).\(r.kind): \(r.metadata.name)").join("\n")' < examples/service_and_pod.yaml 21 | /// ``` 22 | module pkl.pipe.examples.k8s_name_and_kind 23 | amends "../yaml.pkl" 24 | 25 | input = read("./k8s_service_and_pod.yaml") 26 | 27 | output { 28 | text = module.pipe.map((r) -> "\(r.apiVersion).\(r.kind): \(r.metadata.name)").join("\n") 29 | } 30 | -------------------------------------------------------------------------------- /packages/io.prometheus/examples/configuration.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module io.prometheus.examples.configuration 17 | 18 | amends "../Configuration.pkl" 19 | 20 | global { 21 | scrape_timeout = 10.s 22 | } 23 | 24 | scrape_configs { 25 | new { 26 | job_name = "my-job" 27 | kubernetes_sd_configs { 28 | new { 29 | role = "pod" 30 | } 31 | } 32 | relabel_configs { 33 | new { 34 | regex = ".*?" 35 | } 36 | } 37 | } 38 | } 39 | 40 | remote_write { 41 | new { 42 | url = "https://example.com/remote_write" 43 | sigv4 { 44 | region = "us-west-2" 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/ParameterNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Node representing a method or function argument declaration. 17 | @Unlisted 18 | module pkl.experimental.syntax.ParameterNode 19 | 20 | extends "Node.pkl" 21 | 22 | import "TypeAnnotationNode.pkl" 23 | import "IdentifierNode.pkl" 24 | 25 | /// The name of the parameter. May be `_` for an unbound parameter. 26 | name: IdentifierNode 27 | 28 | /// The type of the parameter. 29 | typeAnnotation: TypeAnnotationNode? 30 | 31 | function render(currentIndent: String) = List(name.render(currentIndent), typeAnnotation?.render(currentIndent)) 32 | .filterNonNull() 33 | .join("") 34 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/processors/StarlarkProcessor.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The starlark processor calls a Starlark function for each matched metric, allowing for custom programmatic metric processing. 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | open module com.influxdata.telegraf.plugins.processors.StarlarkProcessor 19 | 20 | extends "Processor.pkl" 21 | 22 | /// Source of the Starlark script. 23 | @SourceCode { language = "Starlark" } 24 | source: String? 25 | 26 | /// File containing a Starlark script. 27 | script: String? 28 | 29 | /// The constants of the Starlark script. 30 | constants: Mapping? 31 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Reference.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A reference to other components in the specification, internally and externally. 17 | /// 18 | /// The Reference Object is defined by [JSON Reference](https://datatracker.ietf.org/doc/html/draft-pbryan-zyp-json-ref-03) 19 | /// and follows the same structure, behavior and rules. 20 | /// 21 | /// For this specification, reference resolution is accomplished as defined by the JSON Reference specification 22 | /// and not by the JSON Schema specification. 23 | /// 24 | /// https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object 25 | module org.openapis.v3.Reference 26 | 27 | /// The reference URI 28 | `$ref`: Uri 29 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/tests/expressions.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3.tests.expressions 17 | 18 | amends "pkl:test" 19 | 20 | import "../expressions.pkl" 21 | 22 | facts { 23 | ["Expression"] { 24 | "$method" is expressions.Expression 25 | "$request.header.accept" is expressions.Expression 26 | "$request.path.id" is expressions.Expression 27 | "$request.body#/user/uuid" is expressions.Expression 28 | "$url" is expressions.Expression 29 | "$response.body#/status" is expressions.Expression 30 | "$response.header.Server" is expressions.Expression 31 | !("bar" is expressions.Expression) 32 | !("$request.header.über" is expressions.Expression) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/tests/ClassNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.tests.ClassNode 17 | 18 | amends "pkl:test" 19 | 20 | import "../ClassNode.pkl" 21 | 22 | facts { 23 | ["extending"] { 24 | new ClassNode { 25 | classHeader { 26 | name { 27 | value = "MyClass" 28 | } 29 | extendsClause { 30 | type { 31 | name { 32 | parts { 33 | new { 34 | value = "Base" 35 | } 36 | } 37 | } 38 | } 39 | } 40 | } 41 | 42 | }.render("") == """ 43 | class MyClass extends Base { 44 | 45 | } 46 | """ 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/tests/ModuleNode.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["full declaration"] { 3 | """ 4 | #!/usr/bin/env pkl eval 5 | /// This is a module doc comment! 6 | @test { annotation = true } 7 | open module pkl.experimental.syntax.tests.ModuleNode 8 | 9 | amends "pkl:test" 10 | 11 | """ 12 | } 13 | ["short methods are rendered inline"] { 14 | """ 15 | /// Adds five to its argument. 16 | const local function addFive(input: Int) = input + 5 17 | 18 | """ 19 | } 20 | ["methods with long values are rendered indented"] { 21 | """ 22 | /// Adds five to its argument. 23 | const local function myReallyLongMethodForAddingFiveToAnInteger(inputIntegerValue: Int) = 24 | inputIntegerValue + 5 25 | 26 | """ 27 | } 28 | ["methods with long values but short first lines are rendered inline"] { 29 | """ 30 | /// Adds five to its argument and returns a dynamic object containing the result. 31 | const local function myLongMethodForReturningADynamicObject(inputIntegerValue: Int) = new Dynamic { 32 | value = inputIntegerValue + 5 33 | } 34 | 35 | """ 36 | } 37 | ["typealiases"] { 38 | """ 39 | typealias Short = "A"|"B" 40 | 41 | typealias Long = 42 | "Apple" 43 | |"Blackberry" 44 | |"Cherry" 45 | |"Durian" 46 | |"Elderberry" 47 | |"Fig" 48 | |"Guava" 49 | |"Huckleberry" 50 | |"I_can't_think_of_a_fruit_that_starts_with_I" 51 | 52 | """ 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/SolrInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The [Solr input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/solr/README.md) 17 | /// collcts stats via the [MBean Request Handler](https://solr.apache.org/guide/6_6/mbean-request-handler.html). 18 | @ModuleInfo { minPklVersion = "0.25.0" } 19 | open module com.influxdata.telegraf.plugins.inputs.SolrInput 20 | 21 | extends "./Input.pkl" 22 | 23 | /// One or more URLs of Solr servers 24 | servers: Listing(!isEmpty) 25 | 26 | /// Optional list of one or more Solr cores 27 | /// 28 | /// Defaults to all 29 | cores: Listing? 30 | 31 | /// Optional HTTP Basic Auth Credentials. 32 | username: String? 33 | password: String? 34 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/CpuInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The `cpu` plugin gather metrics on the system CPUs. 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | module com.influxdata.telegraf.plugins.inputs.CpuInput 19 | 20 | extends "Input.pkl" 21 | 22 | /// Whether to report per-CPU stats or not. 23 | /// 24 | /// Default: `true` 25 | percpu: Boolean? 26 | 27 | /// Whether to report total system CPU stats or not. 28 | /// 29 | /// Default: `true` 30 | totalcpu: Boolean? 31 | 32 | /// If true, collect raw CPU time metrics. 33 | /// 34 | /// Default: `false` 35 | collect_cpu_time: Boolean? 36 | 37 | /// If true, compute and report the sum of all non-idle CPU states. 38 | /// 39 | /// Default: `false` 40 | report_active: Boolean? 41 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/serializers/JsonOutputDataFormat.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The [JSON output data format](https://docs.influxdata.com/telegraf/v1.17/data_formats/output/json/) 17 | /// serializes Telegraf metrics into JSON documents. 18 | @ModuleInfo { minPklVersion = "0.25.0" } 19 | module com.influxdata.telegraf.plugins.serializers.JsonOutputDataFormat 20 | 21 | extends "OutputDataFormat.pkl" 22 | 23 | data_format: "json" 24 | 25 | /// Files to write to. 26 | /// 27 | /// `"stdout"` is a specially handled file. 28 | files: Listing 29 | 30 | /// The resolution to use for the metric timestamp. 31 | /// 32 | /// Durations are truncated to the power of 10 less than the specified units. 33 | json_timestamp_units: Duration 34 | -------------------------------------------------------------------------------- /packages/pkl.toml/examples/converters.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.toml.examples.converters 17 | 18 | import "../toml.pkl" 19 | 20 | class Dog { 21 | breed: String 22 | sleepTime: Duration 23 | } 24 | 25 | dogs { 26 | new Dog { 27 | breed = "Golden Retreiver" 28 | sleepTime = 12.h 29 | } 30 | new Dog { 31 | breed = "GERMAN SHEPHERD" 32 | sleepTime = 10.h 33 | } 34 | new Dog { 35 | breed = "greyhound" 36 | sleepTime = 18.h 37 | } 38 | } 39 | 40 | output { 41 | renderer = new toml.Renderer { 42 | converters { 43 | [Dog] = (dog: Dog) -> (dog) { 44 | breed = dog.breed.toLowerCase() 45 | } 46 | [Duration] = (dur: Duration) -> "\(dur.value)\(dur.unit)" 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/Node.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// An abstraction for a Pkl code snippet. 17 | /// 18 | /// Nodes are used for building syntax trees, which can be used to render Pkl source code. 19 | @ModuleInfo { minPklVersion = "0.25.0" } 20 | @Unlisted 21 | abstract module pkl.experimental.syntax.Node 22 | 23 | hidden pcfRenderer: ValueRenderer = new PcfRenderer { useCustomStringDelimiters = true } 24 | 25 | /// The indentation when rendering. 26 | hidden indent: String = " " 27 | 28 | /// The max column width to use when rendering. 29 | hidden maxColumnWidth: Int = 100 30 | 31 | abstract function render(currentIndent: String): String 32 | 33 | function parenthesize(str: String) = "(" + str + ")" 34 | 35 | output { 36 | text = render("") 37 | } 38 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/examples/opentelemetry-output.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | amends "../Telegraf.pkl" 17 | 18 | outputs { 19 | opentelemetry { 20 | new { 21 | service_address = "localhost:4312" 22 | timeout = 10.s 23 | tls_ca = "/path/to/ca/cert" 24 | tls_cert = "/path/to/cert" 25 | tls_key = "/path/to/key" 26 | tls_server_name = "tls-server.com" 27 | compression = "gzip" 28 | coralogix { 29 | application = "myapp" 30 | private_key = "my secret value" 31 | subsystem = "my subsystem" 32 | } 33 | attributes { 34 | ["service.name"] = "foo" 35 | ["service.version"] = "1.0.0" 36 | } 37 | headers { 38 | ["x-api-key"] = "my-api-key" 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/pkl.pipe/examples/github_repos_stars.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This example shows how to map a Github API response for repos in an org 17 | /// into a list of "reponame: stars". It is the equivalent of the CLI invocation: 18 | /// 19 | /// ``` 20 | /// curl https://api.github.com/orgs/apple/repos | pkl eval json.pkl -x 'pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n")' 21 | /// ``` 22 | module pkl.pipe.examples.github_repos_stars 23 | amends "../json.pkl" 24 | 25 | // This does the equivalent of stdin redirection, eg: 26 | // pkl eval json.pkl -x '...' < ./github.json 27 | input = read("./github.json") 28 | 29 | output { 30 | // This is equivalent to `pkl eval -x` 31 | text = module.pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n") 32 | } 33 | -------------------------------------------------------------------------------- /packages/com.circleci.v2/examples/concurrent_workflow.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module com.circleci.v2.examples.concurrent_workflow 17 | 18 | // Adapdation of https://circleci.com/docs/sample-config/#concurrent-workflow 19 | amends "../Config.pkl" 20 | 21 | jobs { 22 | ["build"] { 23 | docker { 24 | new { image = "cimg/base:2023.03" } 25 | } 26 | steps { 27 | "checkout" 28 | module.run(#"echo "this is the build job""#) 29 | } 30 | } 31 | ["test"] { 32 | docker { 33 | new { image = "cimg/base:2023.03"} 34 | } 35 | steps { 36 | "checkout" 37 | module.run(#"echo "this is the build job""#) 38 | } 39 | } 40 | } 41 | 42 | workflows { 43 | ["build_and_test"] { 44 | jobs { 45 | "build" 46 | "test" 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/RequestBody.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3.RequestBody 17 | 18 | import "MediaType.pkl" 19 | 20 | /// A brief description of the request body. 21 | /// 22 | /// This could contain examples of use. CommonMark syntax MAY be used for rich text representation. 23 | @SourceCode { language = "Markdown" } 24 | description: String? 25 | 26 | /// The content of the request body. 27 | /// 28 | /// The key is a media type or media type range and the value describes it. For requests that match multiple 29 | /// keys, only the most specific key is applicable. e.g. text/plain overrides text/* 30 | content: Mapping? 31 | 32 | /// Determines if the request body is required in the request. 33 | /// 34 | /// Defaults to false. 35 | required: Boolean? 36 | -------------------------------------------------------------------------------- /packages/k8s.contrib.crd/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Utilities for [Kubernetes Custom Resources](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/). 17 | /// 18 | /// This package includes utilities for generating Pkl for a given CRD. 19 | amends "../basePklProject.pkl" 20 | 21 | dependencies { 22 | ["jsonschema"] = import("../org.json_schema/PklProject") 23 | ["jsonschema.contrib"] = import("../org.json_schema.contrib/PklProject") 24 | ["deepToTyped"] = import("../pkl.experimental.deepToTyped/PklProject") 25 | ["uri"] = import("../pkl.experimental.uri/PklProject") 26 | ["syntax"] = import("../pkl.experimental.syntax/PklProject") 27 | 28 | ["k8s"] { uri = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1" } 29 | } 30 | 31 | package { 32 | version = "1.0.8" 33 | } 34 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/examples/simple.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | amends "../Telegraf.pkl" 17 | 18 | import "../plugins/serializers/JsonOutputDataFormat.pkl" 19 | 20 | global_tags { 21 | ["user"] = "alice" 22 | } 23 | 24 | inputs { 25 | http { 26 | new { 27 | method = "GET" 28 | urls { 29 | "https://server.company.org/metrics" 30 | } 31 | } 32 | } 33 | cpu { 34 | new { 35 | percpu = false 36 | totalcpu = true 37 | tags { 38 | ["tag1"] = "foo" 39 | ["tag2"] = "bar" 40 | } 41 | } 42 | } 43 | } 44 | 45 | outputs { 46 | file { 47 | new { 48 | files { 49 | "my/file.txt" 50 | } 51 | data_format = new JsonOutputDataFormat { 52 | json_timestamp_units = 5.s 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /packages/k8s.contrib.crd/PklProject.deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "resolvedDependencies": { 4 | "package://pkg.pkl-lang.org/pkl-k8s/k8s@1": { 5 | "type": "remote", 6 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1", 7 | "checksums": { 8 | "sha256": "75c6d66d94c335417a3c502e107aaeadf7a60b4e1d34b2c979afe11193205a1a" 9 | } 10 | }, 11 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1": { 12 | "type": "local", 13 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.deepToTyped@1.0.2", 14 | "path": "../pkl.experimental.deepToTyped" 15 | }, 16 | "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1": { 17 | "type": "local", 18 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema.contrib@1.0.9", 19 | "path": "../org.json_schema.contrib" 20 | }, 21 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1": { 22 | "type": "local", 23 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.syntax@1.0.3", 24 | "path": "../pkl.experimental.syntax" 25 | }, 26 | "package://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1": { 27 | "type": "local", 28 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/pkl.experimental.uri@1.0.3", 29 | "path": "../pkl.experimental.uri" 30 | }, 31 | "package://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1": { 32 | "type": "local", 33 | "uri": "projectpackage://pkg.pkl-lang.org/pkl-pantry/org.json_schema@1.0.4", 34 | "path": "../org.json_schema" 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /packages/pkl.toml/examples/dates.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.toml.examples.dates 17 | 18 | import "../toml.pkl" 19 | 20 | // Offset Date-Time 21 | odt1 = new toml.DateTime { value = "1979-05-27T07:32:00Z" } 22 | odt2 = new toml.DateTime { value = "1979-05-27T00:32:00-07:00" } 23 | odt3 = new toml.DateTime { value = "1979-05-27T00:32:00.999999-07:00" } 24 | odt4 = new toml.DateTime { value = "1979-05-27 07:32:00Z" } 25 | 26 | // Local Date-Time 27 | ldt1 = new toml.DateTime { value = "1979-05-27T07:32:00" } 28 | ldt2 = new toml.DateTime { value = "1979-05-27T00:32:00.999999" } 29 | 30 | // Local Date 31 | ld1 = new toml.Date { value = "1979-05-27" } 32 | 33 | // Local Time 34 | lt1 = new toml.Time { value = "07:32:00" } 35 | lt2 = new toml.Time { value = "00:32:00.999999" } 36 | 37 | output { 38 | renderer = new toml.Renderer {} 39 | } 40 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Server.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// An object representing a Server. 17 | module org.openapis.v3.Server 18 | 19 | import "ServerVariable.pkl" 20 | 21 | /// A URL to the target host. 22 | /// 23 | /// This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the 24 | /// location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named 25 | /// in {brackets}. 26 | url: String 27 | 28 | /// An optional string describing the host designated by the URL. 29 | /// 30 | /// CommonMark syntax MAY be used for rich text representation. 31 | @SourceCode { language = "Markdown" } 32 | description: String? 33 | 34 | /// A map between a variable name and its value. 35 | /// 36 | /// The value is used for substitution in the server's URL template. 37 | variables: Mapping? 38 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Security.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Various security data types. 17 | module org.openapis.v3.Security 18 | 19 | /// Lists the required security schemes to execute this operation. 20 | /// 21 | /// The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the 22 | /// Components Object. 23 | /// 24 | /// Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a 25 | /// request to be authorized. This enables support for scenarios where multiple query parameters or HTTP headers 26 | /// are required to convey security information. 27 | /// 28 | /// When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object, only one of the 29 | /// Security Requirement Objects in the list needs to be satisfied to authorize the request. 30 | typealias Requirement = Mapping> 31 | -------------------------------------------------------------------------------- /packages/io.prometheus/examples/rule.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module io.prometheus.examples.rule 17 | 18 | amends "../Rule.pkl" 19 | 20 | groups { 21 | new AlertingRuleGroup { 22 | name = "alerting_rules" 23 | interval = 5.min 24 | rules { 25 | new { 26 | alert = "HighRequestLatency" 27 | expr = #"job:request_latency_seconds:mean5m{job="myjob"} > 0.5"# 28 | `for` = 10.min 29 | labels { 30 | ["prod"] = true 31 | ["priority"] = 1 32 | ["severity"] = "page" 33 | } 34 | annotations { 35 | ["summary"] = "High request latency" 36 | } 37 | } 38 | } 39 | } 40 | new RecordingRuleGroup { 41 | name = "recording_rules" 42 | interval = 10.h 43 | rules { 44 | new { 45 | `record` = "job:http_inprogress_requests:sum" 46 | expr = "sum by (job) (http_inprogress_requests)" 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/org.apache.spark/PklProject: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Definitions for [Apache Spark](https://spark.apache.org). 17 | /// 18 | /// Apache Spark is a distributed computing framework used for processing and analyzing large datasets. 19 | /// It can be applied to data that is structured (like database tables) or unstructured (like log files). 20 | /// Data can be processed one-off or on a schedule, or continuously as a stream of items from a queue. 21 | amends "../basePklProject.pkl" 22 | 23 | package { 24 | version = "1.0.2" 25 | description = """ 26 | Definitions for [Apache Spark](https://spark.apache.org). 27 | 28 | Apache Spark is a distributed computing framework used for processing and analyzing large datasets. 29 | It can be applied to data that is structured (like database tables) or unstructured (like log files). 30 | Data can be processed one-off or on a schedule, or continuously as a stream of items from a queue. 31 | """ 32 | } 33 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Example.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3.Example 17 | 18 | /// Short description for the example 19 | summary: String? 20 | 21 | /// Long description for the example. 22 | /// 23 | /// CommonMark syntax MAY be used for rich text representation. 24 | @SourceCode { language = "Markdown" } 25 | description: String? 26 | 27 | /// Embedded literal example. The value field and externalValue field are mutually exclusive. 28 | /// 29 | /// To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to 30 | /// contain the example, escaping where necessary. 31 | value: Any?(!(this != null && externalValue != null)) 32 | 33 | /// A URL that points to the literal example. 34 | /// 35 | /// This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The 36 | /// value field and externalValue field are mutually exclusive. 37 | externalValue: Uri? 38 | -------------------------------------------------------------------------------- /packages/io.prometheus/PrometheusObject.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Base module for Prometheus configuration objects 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | abstract module io.prometheus.PrometheusObject 19 | 20 | typealias MetricNameFormat = String(matches(Regex(#"[a-zA-Z_:][a-zA-Z0-9_:]*"#))) 21 | 22 | typealias LabelNameFormat = String(matches(Regex(#"[a-zA-Z_][a-zA-Z0-9_]*"#))) 23 | 24 | typealias Labels = Mapping 25 | 26 | typealias Scheme = *"http"|"https" 27 | 28 | local function convertDuration(dur: Duration) = 29 | if (dur.unit == "min") dur.value.toString() + "m" 30 | else if (dur.unit == "ns") convertDuration(dur.toUnit("ms")) 31 | else if (dur.unit == "us") convertDuration(dur.toUnit("ms")) 32 | else dur.value.toString() + dur.unit 33 | 34 | output { 35 | renderer = new YamlRenderer { 36 | converters { 37 | [Duration] = (dur: Duration) -> convertDuration(dur) 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Header.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The Header Object follows the structure of the Parameter Object with the 17 | /// following changes: 18 | /// 19 | /// * name MUST NOT be specified, it is given in the corresponding headers map. 20 | /// * in MUST NOT be specified, it is implicitly in header. 21 | /// * All traits that are affected by the location MUST be applicable to a 22 | /// location of header (for example, style). 23 | module org.openapis.v3.Header 24 | 25 | extends "BaseParameter.pkl" 26 | 27 | import "Schema.pkl" 28 | import "Reference.pkl" 29 | 30 | /// Determines whether this parameter is mandatory. 31 | required: Boolean? 32 | 33 | /// Describes how the parameter value will be serialized depending on the type of the parameter value. 34 | /// 35 | /// In this case, it's a header, so it should always be "simple". 36 | style: "simple"? 37 | 38 | /// The schema defining the type used for the parameter. 39 | schema: (*Schema|Reference)? 40 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/DiskInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The [disk input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/disk/README.md) 17 | /// gathers metrics about disk usage. 18 | /// 19 | /// Note that `used_percent` is calculated by doing `used / (used + free)`, 20 | /// _not_ `used / total`, which is how the unix `df` command does it. 21 | /// See for more details. 22 | @ModuleInfo { minPklVersion = "0.25.0" } 23 | module com.influxdata.telegraf.plugins.inputs.DiskInput 24 | 25 | extends "Input.pkl" 26 | 27 | /// By default stats will be gathered for all mount points. 28 | /// 29 | /// Set mount_points will restrict the stats to only the specified mount points. 30 | mount_points: Listing? 31 | 32 | typealias FsType = "tmpfs"|"devtmpfs"|"devfs"|"iso9660"|"overlay"|"aufs"|"squashfs" 33 | 34 | /// Ignore mount points by filesystem type. 35 | ignore_fs: Listing? 36 | -------------------------------------------------------------------------------- /packages/pkl.pipe/kubeval.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A Pkl implementation of a Kubernetes manifest validation tool, inspired by 17 | /// [kubeval](https://github.com/instrumenta/kubeval) 18 | /// 19 | /// Example usage: 20 | /// 21 | /// ``` 22 | /// pkl eval <(pkl eval -m package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/kubeval.pkl> < deployment.yaml) 23 | /// # or 24 | /// pkl eval <(pkl eval -p input=deployment.yaml package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/kubeval.pkl) 25 | /// ``` 26 | @ModuleInfo { minPklVersion = "0.24.0" } 27 | module pkl.pipe.kubeval 28 | amends "yaml.pkl" 29 | 30 | import "@k8s.contrib/convert.pkl" 31 | 32 | parser { 33 | useMapping = true 34 | } 35 | 36 | input = (read?("prop:input").ifNonNull((it) -> read(it as String)) as Resource?) ?? super.input 37 | 38 | output = (convert) { 39 | resourcesToConvert = 40 | let (pipe = module.pipe) 41 | if (pipe is List) 42 | pipe 43 | else 44 | List(pipe) 45 | }.output 46 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/ServerVariable.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// An object representing a Server Variable for server URL template 17 | /// substitution. 18 | module org.openapis.v3.ServerVariable 19 | 20 | /// An enumeration of string values to be used if the substitution options are from a limited set. 21 | /// 22 | /// The array SHOULD NOT be empty. 23 | enum: Listing(!isEmpty, isDistinct)? 24 | 25 | /// The default value to use for substitution, which SHALL be sent if an alternate value is not supplied. 26 | /// 27 | /// Note this behavior is different than the Schema Object's treatment of default values, because in those cases 28 | /// parameter values are optional. If the enum is defined, the value SHOULD exist in the enum's values. 29 | default: String(enum == null || enum.toList().contains(this)) 30 | 31 | /// An optional description for the server variable. 32 | /// 33 | /// CommonMark syntax MAY be used for rich text representation. 34 | @SourceCode { language = "Markdown" } 35 | description: String? 36 | -------------------------------------------------------------------------------- /packages/org.apache.spark/PropertiesBase.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | abstract module org.apache.spark.PropertiesBase 17 | 18 | import "pkl:semver" 19 | import "utils.pkl" 20 | 21 | /// The Spark version to use these properties with. 22 | hidden targetSparkVersion: String? 23 | 24 | function since(sparkVersion: String): Boolean = 25 | if (targetSparkVersion == null) true 26 | else 27 | let (parsedVersion = semver.Version(sparkVersion)) 28 | if (!parsedVersion.isGreaterThan(semver.Version(targetSparkVersion))) 29 | throw("This property exists since Spark version \(parsedVersion), but target Spark version is \(targetSparkVersion).") 30 | else 31 | true 32 | 33 | hidden effectiveProperties: Map = 34 | module.toMap().flatMap((key, value) -> utils.convertProperty(key, value)) 35 | 36 | /// Indicates that the annotated property cannot be set by the user. 37 | class Reserved extends Annotation 38 | 39 | output { 40 | value = effectiveProperties 41 | renderer = new PropertiesRenderer {} 42 | } 43 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/NetInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The [net input plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/net/NET_README.md) 17 | /// gathers metrics about network interface and protocol usage (Linux only). 18 | @ModuleInfo { minPklVersion = "0.25.0" } 19 | module com.influxdata.telegraf.plugins.inputs.NetInput 20 | 21 | extends "Input.pkl" 22 | 23 | /// By default, telegraf gathers stats from any up interface (excluding loopback). 24 | /// 25 | /// Setting interfaces will tell it to gather these explicit interfaces, regardless of status. 26 | /// When specifying an interface, glob-style patterns are also supported. 27 | /// 28 | /// Example: 29 | /// ``` 30 | /// interfaces { "eth*", "enp0s[0-1]", "lo" } 31 | /// ``` 32 | interfaces: Listing? 33 | 34 | /// On linux systems telegraf also collects protocol stats. 35 | /// 36 | /// Setting this property to `true` will skip reporting of protocol metrics. 37 | /// 38 | /// Default: `false` 39 | ignore_protocol_stats: Boolean? 40 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Info.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The object provides metadata about the API. 17 | /// 18 | /// The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation 19 | /// tools for convenience. 20 | module org.openapis.v3.Info 21 | 22 | import "Contact.pkl" 23 | import "License.pkl" 24 | 25 | /// The title of the API 26 | title: String 27 | 28 | /// The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API 29 | /// implementation version). 30 | version: String 31 | 32 | /// A short description of the API. 33 | /// 34 | /// CommonMark syntax MAY be used for rich text representation. 35 | @SourceCode { language = "Markdown" } 36 | description: String? 37 | 38 | /// A URL to the Terms of Service for the API. 39 | /// 40 | /// MUST be in the format of a URL. 41 | termsOfService: Uri? 42 | 43 | /// The contact information for the exposed API. 44 | contact: Contact? 45 | 46 | /// The license information for the exposed API. 47 | license: License? 48 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/tests/TypesGenerator.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["numbers"] { 3 | "Number" 4 | "Number(isBetween(5, 10))" 5 | "Number(this <= 5)" 6 | "Number(this > 5)" 7 | "Number(this < 5)" 8 | "Int(this % 5 == 0)" 9 | "Number(isPositive)" 10 | "Number(isPositive)" 11 | "Int" 12 | "UInt8" 13 | } 14 | ["number literals"] { 15 | "Number(this == 5)" 16 | "Number(this == 5 || this == 6 || this == 7)" 17 | } 18 | ["strings"] { 19 | "String" 20 | "String(!isEmpty)" 21 | "String(length >= 5)" 22 | "String(length <= 10)" 23 | "String(length.isBetween(5, 10))" 24 | "String(matches(Regex(\"[a-z]\")))" 25 | "Uri" 26 | "String(isRegex)" 27 | } 28 | ["string literals"] { 29 | "\"Hello\"" 30 | "\"Hello\"" 31 | "\"Bart\"|\"Lisa\"" 32 | } 33 | ["booleans"] { 34 | "Boolean" 35 | } 36 | ["boolean literals"] { 37 | "Boolean(this == true)" 38 | "Boolean(this == false)" 39 | "Boolean(this == false)" 40 | "Boolean" 41 | } 42 | ["arrays"] { 43 | "Listing" 44 | "Listing" 45 | "Listing" 46 | "Listing(isDistinct)" 47 | "Listing" 48 | "Listing" 49 | } 50 | ["mappings"] { 51 | "Mapping" 52 | "Mapping" 53 | } 54 | ["nullables"] { 55 | "String(length >= 10)?" 56 | "(String(length >= 10)|Number(this >= 10))?" 57 | } 58 | ["unions"] { 59 | "String(length >= 5)|Int(this % 10 == 0)" 60 | "String(length >= 5)|Int(this % 10 == 0)" 61 | } 62 | ["not"] { 63 | "String(this != \"foo\")" 64 | "String(!length.isBetween(5, 10))" 65 | } 66 | ["allOf"] { 67 | "String(length.isBetween(5, 10))" 68 | } 69 | ["types from $ref"] { 70 | "Foo" 71 | "unknown" 72 | } 73 | ["boolean schemas"] { 74 | "Any" 75 | "nothing" 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/FileInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The `file` plugin parses the **complete** contents of a file **every interval** 17 | /// using the selected input data format. 18 | /// 19 | /// **Note:** If you wish to parse only newly appended lines use the `tail` input plugin instead. 20 | @ModuleInfo { minPklVersion = "0.25.0" } 21 | open module com.influxdata.telegraf.plugins.inputs.FileInput 22 | 23 | extends "Input.pkl" 24 | 25 | import "../parsers/InputDataFormat.pkl" 26 | 27 | /// Files to parse each interval. 28 | /// 29 | /// Accept standard unix glob matching rules, as well as `**` to match recursive files and directories. 30 | files: Listing 31 | 32 | /// Name a tag containing the name of the file the data was parsed from. 33 | /// 34 | /// Leave empty to disable. 35 | file_tag: String? 36 | 37 | /// The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) 38 | /// to consume. 39 | /// 40 | /// Each data format has its own unique set of configuration options. 41 | data_format: InputDataFormat? 42 | -------------------------------------------------------------------------------- /packages/org.apache.spark/tests/PropertiesBase.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.apache.spark.tests.PropertiesBase 17 | 18 | amends "pkl:test" 19 | 20 | import "../PropertiesBase.pkl" 21 | 22 | local class SampleSparkProperties extends PropertiesBase { 23 | `spark.core.numbers`: Int? 24 | `spark.{driver|executor}.something`: Mapping? 25 | `spark.shards.[0-9].setting.[node].memory`: Mapping>? 26 | `spark.kubernetes.some.type.of.memory`: DataSize? 27 | `spark.some.type.of.duration`: Duration? 28 | } 29 | 30 | examples { 31 | ["rendering properties"] { 32 | new SampleSparkProperties { 33 | `spark.{driver|executor}.something` { 34 | ["driver"] = "some driver setting" 35 | ["executor"] = "some executor setting" 36 | } 37 | `spark.core.numbers` = 5 38 | `spark.shards.[0-9].setting.[node].memory` { 39 | ["1"] { 40 | ["this-node"] = 5.gib 41 | } 42 | } 43 | `spark.kubernetes.some.type.of.memory` = 10.gib 44 | `spark.some.type.of.duration` = 5.min 45 | }.output.text 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/OpenTelemetry.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This [OpenTelemetry input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/opentelemetry) 17 | /// receives traces, metrics and logs from OpenTelemetry clients and agents via gRPC. 18 | @ModuleInfo { minPklVersion = "0.25.0" } 19 | module com.influxdata.telegraf.plugins.inputs.OpenTelemetry 20 | 21 | extends "Input.pkl" 22 | 23 | /// Address and port to listen on. 24 | /// 25 | /// Default if unset: `0.0.0.0:4317` 26 | service_address: String? 27 | 28 | /// New connection timeout 29 | /// 30 | /// Default if unset: 5s 31 | timeout: Duration? 32 | 33 | /// Supports: "prometheus-v1", "prometheus-v2" 34 | /// 35 | /// Default: "prometheus-v1" 36 | metrics_schema: (*"prometheus-v1"|"prometheus-v2")? 37 | 38 | /// Optional TLS Config. 39 | /// 40 | /// Set one or more allowed client CA certificate file names to 41 | /// enable mutually authenticated TLS connections 42 | tls_allowed_cacerts: Listing? 43 | 44 | /// Add service certificate 45 | tls_cert: String? 46 | 47 | /// Add service key 48 | tls_key: String? 49 | 50 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/Input.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Telegraf input plugins are used with the InfluxData time series platform 17 | /// to collect metrics from the system, services, or third party APIs. 18 | /// 19 | /// All metrics are gathered from the inputs you enable and configure in the configuration file. 20 | @ModuleInfo { minPklVersion = "0.25.0" } 21 | abstract module com.influxdata.telegraf.plugins.inputs.Input 22 | 23 | extends "../Plugin.pkl" 24 | 25 | /// How often to gather this metric. 26 | /// 27 | /// Normal plugins use a single global interval, 28 | /// but if one particular input should be run less or more often, 29 | /// you can configure that here. 30 | interval: Duration? 31 | 32 | /// Override the base name of the measurement. 33 | /// 34 | /// Default: name of the input 35 | name_override: String? 36 | 37 | /// Specifies a prefix to attach to the measurement name. 38 | name_prefix: String? 39 | 40 | /// Specifies a suffix to attach to the measurement name. 41 | name_suffix: String? 42 | 43 | /// A map of tags to apply to a specific input’s measurements. 44 | tags: Mapping? 45 | -------------------------------------------------------------------------------- /packages/pkl.pipe/json.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// CLI tool for working with JSON in Pkl, kind of like [jq](https://stedolan.github.io/jq/). 17 | /// 18 | /// Example usage: 19 | /// 20 | /// # Get my IP address 21 | /// curl https://ifconfig.co/json | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/json.pk -x 'pipe.ip' 22 | /// 23 | /// # Get repos and stars for Github org 24 | /// curl https://api.github.com/orgs/apple/repos | pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/json.pkl -x 'pipe.toList().map((r) -> "\(r.name): \(r.stargazers_count)").join("\n")' 25 | @ModuleInfo { minPklVersion = "0.24.0" } 26 | module pkl.pipe.json 27 | extends "./text.pkl" 28 | 29 | import "pkl:json" 30 | 31 | local parsed = new json.Parser { 32 | useMapping = read?("prop:useMapping")?.toBoolean() ?? false 33 | }.parse(input) 34 | 35 | pipe: (List|json.Value)? = if (parsed is Listing) parsed.toList() else parsed 36 | stdin: (List|json.Value)? = pipe 37 | 38 | output { 39 | value = pipe 40 | when (read?("prop:pkl.outputFormat") == null) { 41 | renderer = module.jsonRenderer 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /CONTRIBUTING.adoc: -------------------------------------------------------------------------------- 1 | :uri-github-issue-pkl: https://github.com/apple/pkl-pantry/issues/new 2 | :uri-seven-rules: https://cbea.ms/git-commit/#seven-rules 3 | 4 | = Pkl Pantry Contributors Guide 5 | 6 | Welcome to the Pkl community, and thank you for contributing! 7 | This guide explains how to get involved. 8 | 9 | * <> 10 | * <> 11 | * <> 12 | 13 | == Licensing 14 | 15 | Pkl Pantry is released under the Apache 2.0 license. 16 | This is why we require that, by submitting a pull request, you acknowledge that you have the right to license your contribution to Apple and the community, and agree that your contribution is licensed under the Apache 2.0 license. 17 | 18 | == Issue Tracking 19 | 20 | To file a bug or feature request, use {uri-github-issue-pkl}[GitHub]. 21 | Be sure to include the following information: 22 | 23 | * Context 24 | ** What are/were you trying to achieve? 25 | ** What's the impact of this bug/feature? 26 | 27 | For bug reports, additionally include the following information: 28 | 29 | * The output of `pkl --version`. 30 | * The complete error message. 31 | * The simplest possible steps to reproduce. 32 | * Output produced from the template. 33 | * Error messages from the target system. 34 | 35 | == Pull Requests 36 | 37 | When preparing a pull request, follow this checklist: 38 | 39 | * Imitate the conventions of surrounding code. 40 | * Format the files in your PR with the JetBrains IDE formatter. 41 | * Follow the {uri-seven-rules}[seven rules] of great Git commit messages: 42 | ** Separate subject from body with a blank line. 43 | ** Limit the subject line to 50 characters. 44 | ** Capitalize the subject line. 45 | ** Do not end the subject line with a period. 46 | ** Use the imperative mood in the subject line. 47 | ** Wrap the body at 72 characters. 48 | ** Use the body to explain what and why vs. how. 49 | 50 | == Maintainers 51 | 52 | The project’s maintainers (those with write access to the upstream repository) are listed in link:MAINTAINERS.adoc[]. 53 | -------------------------------------------------------------------------------- /packages/pkl.pipe/yaml.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// CLI tool for working with YAML in Pkl, kind of like [yq](https://github.com/mikefarah/yq) or 17 | /// [yq](https://github.com/kislyuk/yq). 18 | /// 19 | /// Example usage: 20 | /// 21 | /// # Get the number of replicas in a Kubernetes deployment YAML file 22 | /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/yaml.pkl -x 'pipe.spec.replicas' < deployment.yaml 23 | /// 24 | @ModuleInfo { minPklVersion = "0.24.0" } 25 | module pkl.pipe.yaml 26 | extends "./text.pkl" 27 | 28 | import "pkl:yaml" 29 | 30 | hidden parser: yaml.Parser = new { 31 | useMapping = read?("prop:useMapping")?.toBoolean() ?? false 32 | } 33 | 34 | local yamlDocs: List = parser.parseAll(input) 35 | 36 | pipe: (List|yaml.Value)? = 37 | if (yamlDocs.isEmpty) null 38 | // If there is a single document, set pipe to the value of the single doc, 39 | // rather than force the user to always use `pipe[0]` 40 | else yamlDocs.singleOrNull ?? yamlDocs 41 | stdin: (List|yaml.Value)? = pipe 42 | 43 | output { 44 | value = pipe 45 | when (read?("prop:pkl.outputFormat") == null) { 46 | renderer = module.yamlRenderer 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | Copyright © 2024 Apple Inc. and the Pkl project authors 2 | 3 | Portions of this software includes code from "Gradle" by Gradle, Inc. 4 | 5 | Copyright 2015 the original author or authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | https://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | 19 | 20 | Portions of this software is originally derived from "pluralize" by Blake Embrey. 21 | 22 | The MIT License (MIT) 23 | 24 | Copyright (c) 2013 Blake Embrey (hello@blakeembrey.com) 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a copy 27 | of this software and associated documentation files (the "Software"), to deal 28 | in the Software without restriction, including without limitation the rights 29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30 | copies of the Software, and to permit persons to whom the Software is 31 | furnished to do so, subject to the following conditions: 32 | 33 | The above copyright notice and this permission notice shall be included in 34 | all copies or substantial portions of the Software. 35 | 36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 42 | THE SOFTWARE. 43 | -------------------------------------------------------------------------------- /packages/k8s.contrib/tests/convert.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module k8s.contrib.tests.convert 17 | amends "pkl:test" 18 | 19 | import "pkl:yaml" 20 | import "pkl:reflect" 21 | 22 | import "../convert.pkl" 23 | 24 | local absolutePathToPklPantry = reflect.Module(module).uri.replaceFirst("packages/k8s.contrib/tests/convert.pkl", "") 25 | 26 | /// Run conversion, replacing full file import paths with paths stemming from "$pklPantryBaseDir". 27 | /// 28 | /// Before: 29 | /// 30 | /// `import "file:///User/me/work/pkl-pantry/packages/k8s/K8sObject.pkl"` 31 | /// 32 | /// After: 33 | /// 34 | /// `import "$pklPantryBaseDir/packages/k8s/K8sObject.pkl"` 35 | local function doConvert(uri: String) = 36 | let (converter = (convert) { 37 | resourcesToConvert = new yaml.Parser { useMapping = true }.parseAll(read(uri)).filterNonNull() as List 38 | 39 | customResourceTemplates { 40 | ["Custom"] { 41 | ["v1"] = import("./fixtures/CustomType.pkl") 42 | } 43 | } 44 | }) 45 | converter.output.text.replaceAll(absolutePathToPklPantry, "$pklPantryBaseDir/") 46 | 47 | examples = new { 48 | for (file, _ in read*("fixtures/*.yml")) { 49 | [file.replaceAll(Regex(".*fixtures/"), "")] { 50 | doConvert(file) 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/TypeAliasNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.TypeAliasNode 17 | 18 | extends "Node.pkl" 19 | 20 | import "IdentifierNode.pkl" 21 | import "TypeNode.pkl" 22 | import "DocCommentNode.pkl" 23 | import "AnnotationNode.pkl" 24 | 25 | docComment: DocCommentNode? 26 | 27 | name: IdentifierNode 28 | 29 | type: TypeNode 30 | 31 | annotations: Listing? 32 | 33 | modifiers: Listing<"external"|"local">(isDistinct)? 34 | 35 | local function renderAlias(currentIndent: String) = 36 | let (typeRendered = type.render(currentIndent)) 37 | new Listing { 38 | renderHeader(currentIndent) 39 | when (!typeRendered.startsWith("\n")) { // if the type is rendered starting on the next line, do not add a space 40 | " " 41 | } 42 | typeRendered 43 | }.join("") 44 | 45 | function renderHeader(currentIndent: String) = new Listing { 46 | ...?modifiers 47 | "typealias" 48 | name.render(currentIndent) 49 | "=" 50 | }.join(" ") 51 | 52 | function render(currentIndent: String) = List( 53 | docComment?.render(currentIndent), 54 | annotations?.toList()?.map((an) -> an.render(currentIndent))?.join("\n"), 55 | currentIndent + renderAlias(currentIndent) 56 | ).filterNonNull().join("\n") 57 | -------------------------------------------------------------------------------- /packages/org.apache.spark/tests/utils.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.apache.spark.tests.utils 17 | 18 | amends "pkl:test" 19 | 20 | import "../utils.pkl" 21 | 22 | examples { 23 | ["convertIndexedProperty"] { 24 | utils.convertIndexedProperty("foo.bar.[baz].biz.[buz]", new Mapping { 25 | ["1"] = new Mapping { 26 | ["11"] = "eleven" 27 | ["12"] = "twelve" 28 | } 29 | ["2"] = new Mapping { 30 | ["22"] = "two" 31 | } 32 | }) 33 | utils.convertIndexedProperty("foo.bar.[baz].biz", new Mapping { 34 | ["1"] = 1 35 | ["2"] = 2 36 | }) 37 | } 38 | ["flattenMapKeys"] { 39 | utils.flattenMapKeys(new Mapping { 40 | ["1"] = new Mapping { 41 | ["11"] = "eleven" 42 | ["12"] = "twelve" 43 | } 44 | ["2"] = new Mapping { 45 | ["22"] = "two" 46 | } 47 | }, List()) 48 | } 49 | ["convertProperty"] { 50 | utils.convertProperty("foo.bar.baz", 1) 51 | utils.convertProperty("foo.env.[baz]", new Mapping { ["FOO"] = "foo"; ["BAR"] = "bar" }) 52 | utils.convertProperty("foo.env.[baz].buz.{baz}", new Mapping { ["FOO"] = new Mapping { ["BAR"] = "bar" } }) 53 | utils.convertProperty("spark.kubernetes.baz", 5.gib) 54 | utils.convertProperty("spark.memory", 5.gib) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/outputs/Output.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Telegraf processor plugins write metrics to various destinations 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | abstract module com.influxdata.telegraf.plugins.outputs.Output 19 | 20 | extends "../Plugin.pkl" 21 | 22 | /// Name an instance of a plugin. 23 | alias: String? 24 | 25 | /// The maximum time between flushes. 26 | /// 27 | /// Use this setting to override the agent `flush_interval` on a per plugin basis. 28 | flush_interval: Duration? 29 | 30 | /// The amount of time to jitter the flush interval. 31 | /// 32 | /// Use this setting to override the agent `flush_jitter` on a per plugin basis. 33 | flush_jitter: Duration? 34 | 35 | /// The maximum number of metrics to send at once. 36 | /// 37 | /// Use this setting to override the agent `metric_batch_size` on a per plugin basis. 38 | metric_batch_size: Number? 39 | 40 | /// The maximum number of unsent metrics to buffer. 41 | /// 42 | /// Use this setting to override the agent `metric_buffer_limit` on a per plugin basis. 43 | metric_buffer_limit: Number? 44 | 45 | /// Override the original name of the measurement. 46 | name_override: String? 47 | 48 | /// Specifies a prefix to attach to the measurement name. 49 | name_prefix: String? 50 | 51 | /// Specifies a suffix to attach to the measurement name. 52 | name_suffix: String? 53 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/Response.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Describes a single response from an API Operation, including design-time, static links to operations based on the 17 | /// response. 18 | module org.openapis.v3.Response 19 | 20 | import "Header.pkl" 21 | import "Reference.pkl" 22 | import "MediaType.pkl" 23 | import "Link.pkl" 24 | 25 | /// A short description of the response. 26 | /// 27 | /// CommonMark syntax MAY be used for rich text representation. 28 | @SourceCode { language = "Markdown" } 29 | description: String 30 | 31 | /// Maps a header name to its definition. 32 | /// 33 | /// RFC7230 states header names are case insensitive. If a response header is defined with the name "Content-Type", 34 | /// it SHALL be ignored. 35 | headers: Mapping? 36 | 37 | /// A map containing descriptions of potential response payloads. 38 | /// 39 | /// The key is a media type or media type range and the value describes it. For responses that match multiple keys, 40 | /// only the most specific key is applicable. e.g. text/plain overrides text/* 41 | content: Mapping? 42 | 43 | /// A map of operations links that can be followed from the response. 44 | /// 45 | /// The key of the map is a short name for the link, following the naming constraints of the names for Component Objects. 46 | links: Mapping? 47 | -------------------------------------------------------------------------------- /packages/pkl.experimental.net/tests/net.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["expandIPv6AddressString"] { 3 | "fe80:0000:0000:0000:0000:0000:0000:0000" 4 | "fe80:0000:0000:0000:0000:0000:0000:0001" 5 | "0000:0000:0000:0000:0000:0000:0000:00aa" 6 | } 7 | ["expandIPv6AddressString with scoped addresses"] { 8 | "fe80:0000:0000:0000:0000:0000:0000:0000%1" 9 | "fe80:0000:0000:0000:0000:0000:0000:0000%0" 10 | "fe80:0000:0000:0000:0005:0006:0007:0008%1" 11 | "fe80:0000:0000:0000:0000:0000:0000:0000%000" 12 | "fe80:0000:0000:0000:0000:0000:0000:0000%001" 13 | } 14 | ["expandIPv6AddressString with IPv4 suffix"] { 15 | "ffff:ffff:ffff:ffff:0000:0000:255.255.255.255" 16 | "0000:0000:0000:0000:0000:0000:1.2.3.4" 17 | "2001:0db8:0000:0000:0000:0000:1.2.3.4" 18 | "000a:000b:000c:000d:000e:000f:1.0.30.0" 19 | } 20 | ["compressIPv6AddressString"] { 21 | "1:2:3:4:5:6:7:8" 22 | "fe80::1:0:0:1" 23 | "fe80::1:0:0:1" 24 | "1:2:3:4:0:6:7:8" 25 | "1:2:3:4:0:6:7:8" 26 | "::" 27 | "::" 28 | "fe80:0:a:b:c:d:e:f" 29 | "2001:0:0:1::1" 30 | "2001:db8::1:0:0:1" 31 | } 32 | ["compressIPv6AddressString with scoped addresses"] { 33 | "fe80::5:6:7:8%0" 34 | "fe80::1:0%0" 35 | "fe80::%0" 36 | "fe80::%1" 37 | "fe80::%0" 38 | "fe80::%1" 39 | } 40 | ["compressIPv6AddressString with IPv4 suffix"] { 41 | "::ffff:1.2.3.4" 42 | "::ffff:1.20.0.4" 43 | "fe80::1.2.3.4" 44 | "fe80::0.0.0.0" 45 | "::0.0.0.0" 46 | } 47 | ["IPv6Address.toString()"] { 48 | "fe80::1" 49 | "101:1001:1010:110:100:1000:1100:1110" 50 | "::" 51 | "::1" 52 | "fe80::" 53 | "fe80::1:0" 54 | "::ffff:127.0.0.1" 55 | "64:ff9b::192.0.2.33" 56 | "2001:db8:122:344::c000:221" 57 | "fe80::1%1" 58 | "ff11::1%2" 59 | "fe80::%0" 60 | } 61 | ["IPv6Address.toExpandedString()"] { 62 | "fe80:0000:0000:0000:0000:0000:0000:0001" 63 | "0000:0000:0000:0000:0000:0000:0000:0000" 64 | "0000:0000:0000:0000:0000:0000:0000:0001" 65 | "2001:0db8:0000:0000:0000:0000:0000:0000" 66 | "fe80:0000:0000:0000:0000:0000:0000:0001%1" 67 | "fe80:0000:0000:0000:0000:0000:0000:0001%0" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/IdentifierNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// A token representing a name. 17 | /// 18 | /// Identifiers get surrounded by backticks (`) if they conflict with a keyword, or if 19 | /// they don't match the normal identifier pattern. 20 | @Unlisted 21 | module pkl.experimental.syntax.IdentifierNode 22 | 23 | extends "Node.pkl" 24 | 25 | /// The raw value of the identifier. 26 | /// 27 | /// It's not possible to encode a backtick into an identifier. 28 | value: String(!contains("`")) 29 | 30 | local keywords: Set = new Listing { 31 | "abstract" 32 | "amends" 33 | "as" 34 | "case" 35 | "class" 36 | "const" 37 | "delete" 38 | "else" 39 | "extends" 40 | "external" 41 | "false" 42 | "final" 43 | "fixed" 44 | "for" 45 | "function" 46 | "hidden" 47 | "if" 48 | "import" 49 | "in" 50 | "is" 51 | "let" 52 | "local" 53 | "module" 54 | "new" 55 | "nothing" 56 | "null" 57 | "open" 58 | "out" 59 | "outer" 60 | "override" 61 | "protected" 62 | "read" 63 | "record" 64 | "super" 65 | "switch" 66 | "this" 67 | "throw" 68 | "trace" 69 | "true" 70 | "typealias" 71 | "unknown" 72 | "vararg" 73 | "when" 74 | }.toSet() 75 | 76 | function render(_) = 77 | if (value.matches(Regex(#"[A-Za-z$_][A-Za-z\d$_]*"#)) && !keywords.contains(value)) 78 | value 79 | else 80 | "`" + value + "`" 81 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/ClassNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.ClassNode 17 | 18 | extends "ClassOrModuleNode.pkl" 19 | 20 | import "Node.pkl" 21 | import "IdentifierNode.pkl" 22 | import "AnnotationNode.pkl" 23 | import "DocCommentNode.pkl" 24 | import "TypeNode.pkl" 25 | 26 | docComment: DocCommentNode? 27 | 28 | annotations: Listing? 29 | 30 | classHeader: ClassHeader 31 | 32 | class ClassHeader extends Node { 33 | modifiers: Listing<"abstract"|"external"|"local"|"open">(isDistinct)? 34 | name: IdentifierNode 35 | extendsClause: ClassExtendsClause? 36 | 37 | function render(currentIndent: String) = currentIndent + new Listing { 38 | modifiers?.join(" ") 39 | "class \(name.render(currentIndent))" 40 | extendsClause?.render(currentIndent) 41 | "{" 42 | }.toList().filterNonNull().join(" ") 43 | } 44 | 45 | class ClassExtendsClause extends Node { 46 | type: TypeNode.DeclaredTypeNode 47 | 48 | function render(currentIndent: String) = "extends " + type.render(currentIndent) 49 | } 50 | 51 | function render(currentIndent: String) = List( 52 | docComment?.render(currentIndent), 53 | annotations?.toList()?.map((a) -> a.render(currentIndent))?.join("\n"), 54 | classHeader.render(currentIndent), 55 | super.render(currentIndent + indent), 56 | "\(currentIndent)}" 57 | ) 58 | .filterNonNull() 59 | .join("\n") 60 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/ExecInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// [Exec Input Plugin](https://github.com/influxdata/telegraf/blob/master/plugins/inputs/exec/README.md) 17 | /// 18 | /// The exec plugin executes all the commands in parallel on every interval and parses metrics from their output in any one of the accepted Input Data Formats. 19 | @ModuleInfo { minPklVersion = "0.25.0" } 20 | module com.influxdata.telegraf.plugins.inputs.ExecInput 21 | 22 | extends "Input.pkl" 23 | 24 | import ".../parsers/InputDataFormat.pkl" 25 | 26 | /// Commands array. 27 | commands: Listing 28 | 29 | /// Environment variables. 30 | hidden env: Mapping 31 | 32 | /// The environment variables as exposed to the exec input plugin. 33 | /// 34 | /// This is an internal property that is derived from [env]. 35 | fixed environment: Listing = env 36 | .toMap() 37 | .entries 38 | .map((entry) -> "\(entry.key)=\(entry.value)") 39 | .toListing() 40 | 41 | /// Timeout for each command to complete. 42 | timeout: Duration? 43 | 44 | /// Measurement name suffix (for separating different commands). 45 | name_suffix: String? 46 | 47 | /// The [input data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md) 48 | /// to consume. 49 | /// 50 | /// Each data format has its own unique set of configuration options. 51 | data_format: InputDataFormat? 52 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/SecurityScheme.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Contact information for the exposed API. 17 | module org.openapis.v3.SecurityScheme 18 | 19 | import "OAuthFlows.pkl" 20 | 21 | typealias SecuritySchemeType = "apiKey"|"http"|"oauth2"|"openIdConnect" 22 | 23 | /// The type of the security scheme. 24 | type: SecuritySchemeType 25 | 26 | /// A short description for security scheme. 27 | /// 28 | /// CommonMark syntax MAY be used for rich text representation. 29 | @SourceCode { language = "Markdown" } 30 | description: String? 31 | 32 | /// The name of the header, query or cookie parameter to be used. 33 | name: String 34 | 35 | /// The location of the API key. 36 | `in`: "query"|"header"|"cookie" 37 | 38 | scheme: String((this == "bearer").implies(bearerFormat != null)) 39 | 40 | /// A hint to the client to identify how the bearer token is formatted. 41 | /// 42 | /// Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation 43 | /// purposes. 44 | bearerFormat: String(type == "http")? 45 | 46 | /// An object containing configuration information for the flow types supported. 47 | flows: OAuthFlows?((type == "oauth2").implies(this != null)) 48 | 49 | /// OpenId Connect URL to discover OAuth2 configuration values. 50 | /// 51 | /// This MUST be in the form of a URL. 52 | openIdConnectUrl: Uri?((type == "openIdConnect").implies(this != null)) 53 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/OAuthFlows.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Specific OAuth flow types. 17 | module org.openapis.v3.OAuthFlows 18 | 19 | /// Configuration for the OAuth Implicit flow. 20 | implicit: OAuthFlow(authorizationUrl != null)? 21 | 22 | /// Configuration for the OAuth Resource Owner Password flow. 23 | password: OAuthFlow(tokenUrl != null)? 24 | 25 | /// Configuration for the OAuth Client Credentials flow. 26 | /// 27 | /// Previously called application in OpenAPI 2.0. 28 | clientCredentials: OAuthFlow(tokenUrl != null)? 29 | 30 | /// Configuration for the OAuth Authorization Code flow. 31 | /// 32 | /// Previously called accessCode in OpenAPI 2.0. 33 | authorizationCode: OAuthFlow(tokenUrl != null && authorizationUrl != null)? 34 | 35 | /// Definition of an OAuth flow. 36 | class OAuthFlow { 37 | 38 | /// The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. 39 | refreshUrl: Uri? 40 | 41 | /// The available scopes for the OAuth2 security scheme. 42 | /// 43 | /// A map between the scope name and a short description for it. The map MAY be empty. 44 | scopes: Mapping 45 | 46 | /// The authorization URL to be used for this flow. 47 | /// 48 | /// This MUST be in the form of a URL. 49 | authorizationUrl: Uri? 50 | 51 | /// The token URL to be used for this flow. 52 | /// 53 | /// This MUST be in the form of a URL. 54 | tokenUrl: Uri? 55 | } 56 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/outputs/FileOutput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This plugin writes telegraf metrics to files. 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | open module com.influxdata.telegraf.plugins.outputs.FileOutput 19 | 20 | extends "Output.pkl" 21 | 22 | import ".../serializers/OutputDataFormat.pkl" 23 | 24 | files: Listing? 25 | 26 | /// Use batch serialization format instead of line based delimiting. 27 | /// 28 | /// The batch format allows for the production of non line based output formats 29 | /// and may more efficiently encode and write metrics. 30 | /// 31 | /// Defaults to false. 32 | use_batch_format: Boolean? 33 | 34 | /// The file will be rotated after the time interval specified. 35 | /// 36 | /// When set to 0 no time based rotation is performed. 37 | /// 38 | /// Defaults to no rotation 39 | rotation_interval: Duration? 40 | 41 | /// The logfile will be rotated when it becomes larger than the specified size. 42 | /// 43 | /// When set to 0, no size based rotation is performed. 44 | rotation_max_size: DataSize? 45 | 46 | /// Maximum number of rotated archives to keep, any older logs are deleted. 47 | /// 48 | /// If set to -1, no archives are removed. 49 | rotation_max_archives: Int? 50 | 51 | /// The [data format](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md) 52 | /// to output. 53 | /// 54 | /// Each data format has its own unique set of configuration options. 55 | data_format: OutputDataFormat 56 | -------------------------------------------------------------------------------- /packages/basePklProject.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module basePklProject 17 | 18 | amends "pkl:Project" 19 | 20 | import "pkl:reflect" 21 | 22 | local myModule = reflect.Module(module) 23 | 24 | local packageName: String = 25 | findRootModule(reflect.Module(module)) 26 | .relativePathTo(module) 27 | .last 28 | 29 | local function findRootModule(mod: reflect.Module): Module = 30 | let (supermodule = mod.supermodule) 31 | if (supermodule == null || !supermodule.isAmend) mod.reflectee 32 | else findRootModule(supermodule) 33 | 34 | local allTests = import*("**/tests/**.pkl").keys.filter((it) -> !it.contains("tests/fixtures/")) 35 | 36 | package { 37 | name = packageName 38 | apiTests = tests // api tests are shared with module tests 39 | baseUri = "package://pkg.pkl-lang.org/pkl-pantry/\(name)" 40 | packageZipUrl = "https://github.com/apple/pkl-pantry/releases/download/\(name)@\(version)/\(name)@\(version).zip" 41 | license = "Apache-2.0" 42 | authors { 43 | "The Pkl Authors " 44 | } 45 | exclude { 46 | "examples/**" 47 | "tests/**" 48 | } 49 | description = myModule.docComment 50 | issueTracker = "https://github.com/apple/pkl-pantry/issues" 51 | sourceCode = "https://github.com/apple/pkl-pantry/tree/\(name)@\(version)/packages/\(name)" 52 | sourceCodeUrlScheme = "https://github.com/apple/pkl-pantry/blob/\(name)@\(version)/packages/\(name)%{path}#L%{line}-%{endLine}" 53 | } 54 | 55 | tests { 56 | for (test in allTests) { 57 | when (test.split("/").first == package.name) { 58 | test.replaceFirst(package.name, ".") 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/tests/ref.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.json_schema.contrib.tests.ref 17 | 18 | amends "pkl:test" 19 | 20 | import "@jsonschema/JsonSchema.pkl" 21 | import "@uri/URI.pkl" 22 | import "../ref.pkl" 23 | 24 | facts { 25 | ["resolveRef()"] { 26 | local schema: JsonSchema = new { 27 | properties { 28 | ["foo"] { 29 | type = "string" 30 | } 31 | } 32 | definitions { 33 | ["bar"] { 34 | properties { 35 | ["baz"] { 36 | title = "This is a baz" 37 | type = "object" 38 | } 39 | } 40 | _inline_ { 41 | ["bizzy"] { 42 | type = "array" 43 | } 44 | } 45 | } 46 | } 47 | } 48 | ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar"; $$baseSchema = schema }) == schema.definitions!!["bar"] 49 | ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar/properties/baz"; $$baseSchema = schema }) == schema.definitions!!["bar"].properties!!["baz"] 50 | ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/properties/foo"; $$baseSchema = schema }) == schema.properties!!["foo"] 51 | ref.resolveRef(new URI {}, new JsonSchema { $ref = "#/definitions/bar/bizzy"; $$baseSchema = schema }) == schema.definitions!!["bar"]._inline_!!["bizzy"] 52 | ref.resolveRef(new URI {}, new JsonSchema { description = "This is a bizzy"; $ref = "#/definitions/bar/bizzy"; $$baseSchema = schema }) == new JsonSchema { 53 | description = "This is a bizzy" 54 | type = "array" 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /packages/pkl.toml/tests/toml.pkl-expected.pcf: -------------------------------------------------------------------------------- 1 | examples { 2 | ["basic.pkl"] { 3 | """ 4 | title = "TOML Example" 5 | contributors = [ "Foo Bar ", { name = "Baz Qux", email = "bazqux@example.com", url = "https://example.com/bazqux" } ] 6 | 7 | [owner] 8 | name = "Tom Preston-Werner" 9 | organization = "Github" 10 | bio = ""\" 11 | GitHub Cofounder & CEO 12 | Likes tater tots and beer""\" 13 | dob = 1979-05-27T07:32:00Z 14 | 15 | [database] 16 | server = "192.168.1.1" 17 | ports = [ 8001, 8001, 8002 ] 18 | connection_max = 5000 19 | enabled = true 20 | 21 | [servers.alpha] 22 | ip = "10.0.0.1" 23 | dc = "eqdc10" 24 | 25 | [servers.beta] 26 | ip = "10.0.0.2" 27 | dc = "eqdc10" 28 | country = "中国" 29 | 30 | [clients] 31 | data = [ [ "gamma", "delta" ], [ 1, 2 ] ] 32 | hosts = [ "alpha", "omega" ] 33 | 34 | [[products]] 35 | name = "Hammer Bro" 36 | sku = 738594937 37 | 38 | [[products]] 39 | 40 | [[products]] 41 | name = "Nail" 42 | sku = 284758393 43 | color = "gray" 44 | 1-1 = "〇😀" 45 | 46 | [[fruits]] 47 | name = "apple" 48 | 49 | [fruits.physical] 50 | color = "red" 51 | shape = "round" 52 | 53 | [[fruits.varieties]] 54 | name = "red delicious" 55 | 56 | [[fruits.varieties]] 57 | name = "granny smith" 58 | 59 | [[fruits]] 60 | name = "banana" 61 | 62 | [[fruits.varieties]] 63 | name = "plantain" 64 | 65 | [dog."tater.man"] 66 | age = nan 67 | maxAge = inf 68 | 69 | [dog."tater.man".type] 70 | name = "pug" 71 | """ 72 | } 73 | ["converters.pkl"] { 74 | """ 75 | [[dogs]] 76 | breed = "golden retreiver" 77 | sleepTime = "12h" 78 | 79 | [[dogs]] 80 | breed = "german shepherd" 81 | sleepTime = "10h" 82 | 83 | [[dogs]] 84 | breed = "greyhound" 85 | sleepTime = "18h" 86 | """ 87 | } 88 | ["dates.pkl"] { 89 | """ 90 | odt1 = 1979-05-27T07:32:00Z 91 | odt2 = 1979-05-27T00:32:00-07:00 92 | odt3 = 1979-05-27T00:32:00.999999-07:00 93 | odt4 = 1979-05-27 07:32:00Z 94 | ldt1 = 1979-05-27T07:32:00 95 | ldt2 = 1979-05-27T00:32:00.999999 96 | ld1 = 1979-05-27 97 | lt1 = 07:32:00 98 | lt2 = 00:32:00.999999 99 | """ 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /packages/k8s.contrib.crd/tests/ModuleGenerator.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module k8s.contrib.crd.tests.ModuleGenerator 17 | 18 | amends "pkl:test" 19 | 20 | import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/ResourceRequirements.pkl" 21 | import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/core/v1/EnvVar.pkl" 22 | import "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.0.1#/api/networking/v1/NetworkPolicy.pkl" 23 | 24 | import "../generate.pkl" 25 | 26 | local generator = (generate) { 27 | sourceContents = read("fixtures/crds.yaml") 28 | source = "dummy://test_uri" 29 | converters { 30 | ["restateclusters.restate.dev"] { 31 | [List("spec", "compute", "env", "env")] = EnvVar 32 | [List("spec", "compute", "resources")] = ResourceRequirements 33 | [List("spec", "security", "networkPeers", "ingress", "ingres")] = NetworkPolicy.NetworkPolicyPeer 34 | [List("spec", "security", "networkPeers", "admin", "admin")] = NetworkPolicy.NetworkPolicyPeer 35 | [List("spec", "security", "networkPeers", "metrics", "metric")] = NetworkPolicy.NetworkPolicyPeer 36 | } 37 | } 38 | } 39 | 40 | local generator2 = (generator) { 41 | k8sImportPath = "@k8s" 42 | } 43 | 44 | local generator3 = (generator) { 45 | k8sImportPath = "package://pkg.pkl-lang.org/pkl-k8s/k8s@1.1.0" 46 | } 47 | 48 | examples { 49 | for (filename, value in generator.output.files!!) { 50 | [filename] { 51 | value.text 52 | } 53 | } 54 | 55 | for (filename, value in generator2.output.files!!) { 56 | ["\(filename) -- dependency notation for k8s"] { 57 | value.text 58 | } 59 | } 60 | 61 | for (filename, value in generator3.output.files!!) { 62 | ["\(filename).pkl -- different version of k8s"] { 63 | value.text 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/tests/ClassOrModuleNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.tests.ClassOrModuleNode 17 | 18 | amends "pkl:test" 19 | 20 | import "../ClassOrModuleNode.pkl" 21 | import "../TypeNode.pkl" 22 | 23 | facts { 24 | ["property definitions"] { 25 | new ClassOrModuleNode.PropertyDefinitionNode { 26 | name { 27 | value = "myProperty" 28 | } 29 | typeAnnotation { 30 | type = new TypeNode.StringLiteralTypeNode { 31 | value = "my string" 32 | } 33 | } 34 | }.render("") == """ 35 | myProperty: "my string" 36 | """ 37 | } 38 | ["property definitions - annotations"] { 39 | local prop = new ClassOrModuleNode.PropertyDefinitionNode { 40 | name { 41 | value = "myProperty" 42 | } 43 | typeAnnotation { 44 | type = new TypeNode.DeclaredTypeNode { 45 | name { 46 | parts { 47 | new { value = "MyType" } 48 | } 49 | } 50 | } 51 | } 52 | docComment { 53 | value = """ 54 | This has been deprecated 55 | 56 | because of stuff. 57 | """ 58 | } 59 | annotations { 60 | new { 61 | identifier { 62 | parts { 63 | new { value = "Deprecated" } 64 | } 65 | } 66 | } 67 | } 68 | } 69 | prop.render("") == """ 70 | /// This has been deprecated 71 | /// 72 | /// because of stuff. 73 | @Deprecated 74 | myProperty: MyType 75 | """ 76 | prop.render(" ") == """ 77 | /// This has been deprecated 78 | /// 79 | /// because of stuff. 80 | @Deprecated 81 | myProperty: MyType 82 | """ 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /packages/com.circleci.v2/examples/typed_orb_steps.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This example uses steps from the [circleci/node](https://circleci.com/developer/orbs/orb/circleci/node) orb. 17 | /// 18 | /// It defins local classes that extend [AbstractStep], so that step definitions are type safe. 19 | amends "../Config.pkl" 20 | 21 | /// Install custom versions of Node.js, and optionally NPM/Yarn, in any 22 | /// execution environment (Docker/Linux, macOS, machine) that does not have 23 | /// it preinstalled. 24 | local class NodeInstall extends AbstractStep { 25 | fixed hidden __name__ = "node/install" 26 | 27 | /// Install Yarn? 28 | /// 29 | /// Default: `false` 30 | `install-yarn`: Boolean? 31 | 32 | /// Where should Node.js be installed? 33 | /// 34 | /// Default: `/usr/local` 35 | `node-install-dir`: String? 36 | 37 | /// Specify the full version tag to install. 38 | /// 39 | /// To install the latest version, set the version to `latest`. 40 | /// If unspecified, the version listed in .nvmrc will be installed. 41 | /// If no .nvmrc file exists the active LTS version of Node.js will be installed by default. 42 | /// For a full list of releases, see the following: 43 | `node-version`: String? 44 | 45 | /// Pick a version of Yarn to install. 46 | /// 47 | /// If no version is specified, the latest stable version will be installed: 48 | `yarn-version`: String? 49 | } 50 | 51 | jobs { 52 | ["test"] { 53 | machine { 54 | image = "ubuntu-2004:current" 55 | } 56 | steps { 57 | "checkout" 58 | new NodeInstall { `node-version` = "v20.11.1" } 59 | new RunStep { command = "npm install" } 60 | new RunStep { command = "npm test" } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/outputs/PrometheusClientOutput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// This plugin starts a Prometheus Client, it exposes all metrics on /metrics (default) to be polled by a Prometheus server. 17 | @ModuleInfo { minPklVersion = "0.25.0" } 18 | open module com.influxdata.telegraf.plugins.outputs.PrometheusClientOutput 19 | 20 | extends "Output.pkl" 21 | 22 | /// Address to listen on. 23 | listen: String? 24 | 25 | /// Metric version controls the mapping from Prometheus metrics into Telegraf metrics. 26 | /// 27 | /// See "Metric Format Configuration" in plugins/inputs/prometheus/README.md for details. 28 | /// Defaults to `1`. 29 | metric_version: Int(isBetween(1,2))? 30 | 31 | /// Username for optional basic authentication. 32 | basic_username: String? 33 | 34 | /// Password for optional basic authentication. 35 | basic_password: String? 36 | 37 | /// If set, the IP Ranges which are allowed to access metrics. 38 | /// 39 | /// Defaults to no restrictions. 40 | ip_range: Listing? 41 | 42 | /// Path to publish the metrics on. 43 | /// 44 | /// Defaults to `/metrics`. 45 | path: String? 46 | 47 | /// Expiration interval for each metric. 48 | /// 49 | /// Set to `0` for no expiration. 50 | /// Defaults to 60 seconds. 51 | expiration_interval: Duration? 52 | 53 | /// Collectors to disable, valid entries are "gocollector" and "process". 54 | /// 55 | /// Defaults to `gocollector' and `process' being enabled. 56 | collectors_exclude: Listing<"gocollector"|"process">(isDistinct)? 57 | 58 | /// Send string metrics as Prometheus labels. 59 | /// 60 | /// Defaults to `true`. 61 | string_as_label: Boolean? 62 | 63 | /// Path to certificate for optional TLS. 64 | tls_cert: String? 65 | 66 | /// Path to key for optional TLS. 67 | tls_key: String? 68 | 69 | /// Path to CA Certificate files to enable optional mTLS. 70 | tls_allowed_cacerts: Listing? 71 | 72 | /// Export metric collection time. 73 | /// 74 | /// Defaults to `false`. 75 | export_timestamp: Boolean? 76 | -------------------------------------------------------------------------------- /packages/org.json_schema.contrib/internal/ModulesGenerator.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.json_schema.contrib.internal.ModulesGenerator 17 | 18 | import "@jsonschema/JsonSchema.pkl" 19 | import "@jsonschema/Parser.pkl" 20 | import "@uri/URI.pkl" 21 | import "utils.pkl" 22 | import "ModuleGenerator.pkl" 23 | 24 | /// The root schema, used to resolve [JsonSchema.$ref] values. 25 | rootSchema: JsonSchema 26 | 27 | /// The URI representing the root schema, used to resolve [JsonSchema.$ref] values. 28 | baseUri: URI 29 | 30 | local isExternalSchema = (baseUri: URI) -> (schema: JsonSchema) -> 31 | if (schema.$$refUri == null) false 32 | else 33 | let (resolvedUri = baseUri.resolveUri(schema.$$refUri!!)) 34 | baseUri.scheme != resolvedUri.scheme 35 | || baseUri.authority() != resolvedUri.authority() 36 | || baseUri.path != resolvedUri.path 37 | 38 | function gatherAllSchemas(schema: JsonSchema, baseUri: URI): List> = 39 | let (externalSchemas = utils.findMatchingSubschemas(schema, isExternalSchema.apply(baseUri))) 40 | externalSchemas.values.flatMap((it) -> 41 | let (resolvedUri = baseUri.resolveUri(it.$$refUri!!).basePath) 42 | let (jsonSchemaBlob = read?(resolvedUri.toString())) 43 | if (jsonSchemaBlob == null) 44 | let (_ = trace("WARN: Failed to read external URI \(resolvedUri)")) 45 | List() 46 | else 47 | let (parsedJsonSchema = (Parser.parse(jsonSchemaBlob)) { 48 | $$baseSchema = this 49 | }) 50 | gatherAllSchemas(parsedJsonSchema, resolvedUri) 51 | ).add(Pair(schema, baseUri)) 52 | 53 | local schemas = gatherAllSchemas(rootSchema, baseUri) 54 | 55 | modules: List = schemas.fold(List(), (acc: List, schema) -> 56 | acc.add(new ModuleGenerator { 57 | rootSchema = schema.first 58 | baseUri = schema.second 59 | existingTypes = acc.flatMap((it) -> it.moduleTypes.entries).toMap((it) -> it.first, (it) -> it.second) 60 | }) 61 | ) 62 | -------------------------------------------------------------------------------- /packages/pkl.pipe/shellshortcuts.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Shell aliases for using Pkl pipe tools. 17 | /// 18 | /// To make using the Pkl pipe tools even easier, this module produces a shell aliases file 19 | /// that is compatible with both bash and zsh. 20 | /// 21 | /// Usage: 22 | /// 23 | /// ``` 24 | /// # First, generate the aliases file 25 | /// pkl eval package://pkg.pkl-lang.org/pkl-pantry/pkl.pipe@#/shellshortcuts.pkl > ~/.pklpipe 26 | /// 27 | /// # Then add it to your profile or rc file. 28 | /// 29 | /// # For zsh, use: 30 | /// echo 'source ~/.pklpipe' >> ~/.zshrc 31 | /// 32 | /// # For bash with a login shell, use: 33 | /// echo 'source ~/.pklpipe' >> ~/.bash_profile 34 | /// 35 | /// # Then use the shortcuts in commands like: 36 | /// curl https://ifconfig.co/json | pjq 'pipe.ip' 37 | /// ``` 38 | @ModuleInfo { minPklVersion = "0.24.0" } 39 | module pkl.pipe.shellshortcuts 40 | 41 | import "pkl:reflect" 42 | 43 | local modules: Mapping = new { 44 | ["ptq"] = import("./text.pkl") 45 | ["pjq"] = import("./json.pkl") 46 | ["pyq"] = import("./yaml.pkl") 47 | ["pkubeval"] = import("./kubeval.pkl") 48 | } 49 | 50 | output { 51 | text = modules 52 | .toMap() 53 | .entries 54 | .map((el) -> 55 | shellFuncForPath( 56 | el.first, 57 | reflect.Module(el.second).uri 58 | ) 59 | ).join("\n") + "\n" 60 | } 61 | 62 | /// [shellFuncForPath] renders a function definition which is compatible with 63 | /// both bash and zsh. If a single argument is passed to the function, it will 64 | /// be passed to a Pkl invocation with `--expression`; if no arguments are passed, 65 | /// the Pkl module will be invoked without any arguments. 66 | local function shellFuncForPath(functionName: String, modulePath: String): String = #""" 67 | function \#(functionName) { 68 | if [[ -n $1 && "$1" != -* ]]; then 69 | pkl eval \#(modulePath) --expression "$1" "${@:2}" 70 | else 71 | pkl eval \#(modulePath) $@ 72 | fi 73 | } 74 | """# 75 | -------------------------------------------------------------------------------- /packages/org.openapis.v3/MediaType.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// Each Media Type Object provides schema and examples for the media type identified by its key. 17 | module org.openapis.v3.MediaType 18 | 19 | import "Schema.pkl" 20 | import "Encoding.pkl" 21 | import "Reference.pkl" 22 | 23 | /// Common media types that are used with OpenAPI specs. 24 | typealias MediaTypeName = 25 | "application/json" 26 | |"application/xml" 27 | |"application/x-www-form-urlencoded" 28 | |"multipart/form-data" 29 | |"text/plain; charset=utf-8" 30 | |"text/html" 31 | |String 32 | 33 | /// The schema defining the content of the request, response, or parameter. 34 | schema: (*Schema|Reference)? 35 | 36 | /// Example of the parameter's potential value. The example SHOULD match the 37 | /// specified schema and encoding properties if present. The example field is 38 | /// mutually exclusive of the examples field. Furthermore, if referencing a 39 | /// schema that contains an example, the example value SHALL override the 40 | /// example provided by the schema. To represent examples of media types that 41 | /// cannot naturally be represented in JSON or YAML, a string value can contain 42 | /// the example with escaping where necessary. 43 | example: Any?(!(this != null && examples != null)) 44 | 45 | /// Examples of the parameter's potential value. Each example SHOULD contain 46 | /// a value in the correct format as specified in the parameter encoding. 47 | /// The examples field is mutually exclusive of the example field. 48 | /// Furthermore, if referencing a schema that contains an example, 49 | /// the examples value SHALL override the example provided by the schema. 50 | examples: Mapping? 51 | 52 | /// A map between a property name and its encoding information. The key, being 53 | /// the property name, MUST exist in the schema as a property. The encoding 54 | /// object SHALL only apply to requestBody objects when the media type is 55 | /// multipart or application/x-www-form-urlencoded. 56 | encoding: Mapping? 57 | -------------------------------------------------------------------------------- /packages/com.influxdata.telegraf/plugins/inputs/HttpInput.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | /// The HTTP input plugin collects metrics from one or more HTTP(S) endpoints. 17 | /// 18 | /// The endpoint should have metrics formatted in one of the supported 19 | /// [input data formats](https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md). 20 | /// Each data format has its own unique set of configuration options which can be added to the input configuration. 21 | @ModuleInfo { minPklVersion = "0.25.0" } 22 | open module com.influxdata.telegraf.plugins.inputs.HttpInput 23 | 24 | extends "./Input.pkl" 25 | 26 | import "../parsers/InputDataFormat.pkl" 27 | 28 | /// One or more URLs from which to read formatted metrics. 29 | urls: Listing 30 | 31 | /// HTTP method. 32 | method: "GET"|"POST"|"PUT"|"PATCH" 33 | 34 | /// Optional HTTP headers. 35 | headers: Mapping? 36 | 37 | /// HTTP entity-body to send with POST/PUT requests. 38 | body: String? 39 | 40 | /// HTTP Content-Encoding for write request body. 41 | /// 42 | /// Can be set to "gzip" to compress body or "identity" to apply no encoding. 43 | content_encoding: ("gzip"|"identity")? 44 | 45 | /// Optional file with Bearer token file content is added as an Authorization header. 46 | bearer_token: String? 47 | 48 | /// Optional HTTP Basic Auth Credentials. 49 | username: String? 50 | password: String? 51 | 52 | /// HTTP Proxy support. 53 | http_proxy_url: String? 54 | 55 | /// Optional TLS Config. 56 | tls_ca: String? 57 | tls_cert: String? 58 | tls_key: String? 59 | 60 | /// Use TLS but skip chain & host verification. 61 | insecure_skip_verify: Boolean? 62 | 63 | /// Amount of time allowed to complete the HTTP request. 64 | timeout: Duration? 65 | 66 | /// List of success status codes. 67 | success_status_codes: Listing? 68 | 69 | /// Data format to consume. 70 | /// 71 | /// Each data format has its own unique set of configuration options, read more about them here: 72 | /// 73 | data_format: InputDataFormat? 74 | -------------------------------------------------------------------------------- /packages/pkl.toml/examples/basic.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.toml.examples.basic 17 | 18 | import "../toml.pkl" 19 | 20 | title = "TOML Example" 21 | 22 | owner { 23 | name = "Tom Preston-Werner" 24 | organization = "Github" 25 | bio = """ 26 | GitHub Cofounder & CEO 27 | Likes tater tots and beer 28 | """ 29 | dob = new toml.DateTime { value = "1979-05-27T07:32:00Z" } 30 | } 31 | 32 | database { 33 | server = "192.168.1.1" 34 | ports { 35 | 8001 36 | 8001 37 | 8002 38 | } 39 | connection_max = 5000 40 | enabled = true 41 | } 42 | 43 | servers { 44 | alpha { 45 | ip = "10.0.0.1" 46 | dc = "eqdc10" 47 | } 48 | beta { 49 | ip = "10.0.0.2" 50 | dc = "eqdc10" 51 | country = "中国" 52 | } 53 | } 54 | 55 | clients { 56 | data { 57 | new { 58 | "gamma" 59 | "delta" 60 | } 61 | new { 62 | 1 63 | 2 64 | } 65 | } 66 | hosts { 67 | "alpha" 68 | "omega" 69 | } 70 | } 71 | 72 | 73 | products { 74 | new { 75 | name = "Hammer Bro" 76 | sku = 738594937 77 | } 78 | new {} 79 | new { 80 | name = "Nail" 81 | sku = 284758393 82 | color = "gray" 83 | `1-1` = "〇😀" 84 | } 85 | } 86 | 87 | fruits { 88 | new { 89 | name = "apple" 90 | physical { 91 | color = "red" 92 | shape = "round" 93 | } 94 | varieties { 95 | new { name = "red delicious" } 96 | new { name = "granny smith" } 97 | } 98 | } 99 | new { 100 | name = "banana" 101 | varieties { 102 | new { name = "plantain" } 103 | } 104 | } 105 | } 106 | 107 | contributors { 108 | "Foo Bar " 109 | new { 110 | name = "Baz Qux" 111 | email = "bazqux@example.com" 112 | url = "https://example.com/bazqux" 113 | } 114 | } 115 | 116 | dog { 117 | `tater.man` { 118 | type { 119 | name = "pug" 120 | } 121 | age = NaN 122 | maxAge = Infinity 123 | } 124 | } 125 | 126 | output { 127 | renderer = new toml.Renderer {} 128 | } 129 | -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/examples/SampleAPI.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3_0.examples.SampleAPI 17 | 18 | amends "@openapi/Document.pkl" 19 | 20 | import "@openapi/Components.pkl" 21 | import "@openapi/HTTPResponse.pkl" 22 | import "../SchemaGenerator.pkl" 23 | 24 | // User schema 25 | local class User { 26 | firstName: String 27 | middleName: String? 28 | lastName: String 29 | } 30 | 31 | info { 32 | title = "Sample API" 33 | description = "Example API to demonstrate the form of an OpenAPI PKL document" 34 | version = "0.1.0" 35 | } 36 | 37 | servers { 38 | // staging 39 | new { 40 | url = "https://staging-api.example.com" 41 | description = "Staging server" 42 | } 43 | 44 | // production 45 | new { 46 | url = "https://api.example.com/{basePath}" 47 | description = "Production server" 48 | variables { 49 | ["basePath"] { 50 | default = "v1" 51 | } 52 | } 53 | } 54 | } 55 | 56 | paths { 57 | ["/users"] { 58 | get { 59 | summary = "Returns a list of users" 60 | description = """ 61 | This is an endpoint that returns a list of users from the configured storage backend. 62 | Blah blah blah. 63 | """ 64 | responses { 65 | [HTTPResponse.OK] { 66 | description = "A JSON array of usernames" 67 | content { 68 | ["application/json"] { 69 | schema = Components.componentRef("schemas", "UserList") 70 | } 71 | } 72 | } 73 | ["4XX"] { 74 | description = "Any client-side error" 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | // define components 82 | components { 83 | schemas { 84 | ["User"] = SchemaGenerator.generate(User) 85 | ["UserList"] { 86 | type = "array" 87 | items = Components.componentRef("schemas", "User") 88 | } 89 | } 90 | links { 91 | ["someLink"] { 92 | requestBody = "$url#/foo/bar" 93 | } 94 | } 95 | } 96 | 97 | output { 98 | renderer = new JsonRenderer {} 99 | } 100 | -------------------------------------------------------------------------------- /packages/org.openapis.v3.contrib/examples/SwallowSchema.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module org.openapis.v3_0.examples.SwallowSchema 17 | 18 | import "../SchemaGenerator.pkl" 19 | 20 | /// A friend of a Swallow. 21 | class SwallowFriend { 22 | /// The name of the friend. 23 | name: String 24 | 25 | /// Is this friend also a Swallow? 26 | isSwallow: Boolean 27 | 28 | /// Any extra attributes for the friend. 29 | tags: Mapping 30 | } 31 | 32 | /// This is a Swallow 33 | class Swallow { 34 | 35 | /// Does this Swallow have a gulp? 36 | hasGulp: Boolean 37 | 38 | /// One of the variants for this swallow. 39 | variants: Listing<"African"|"European"> 40 | 41 | /// What is the air speed of this swallow? 42 | airSpeed: Number? 43 | 44 | /// Is this Swallow a Duck? 45 | /// 46 | /// This is deprecated because no swallows are ever ducks. 47 | @Deprecated 48 | isDuck: Boolean? 49 | 50 | /// How old is this Swallow? 51 | age: UInt8 52 | 53 | /// What are the nicknames? 54 | nicknames: Listing 55 | 56 | /// Who is the best friend of this Swallow? 57 | bestFriend: SwallowFriend 58 | 59 | /// Who are the friends of this Swallow? 60 | friends: Listing 61 | 62 | /// Any extra attributes. 63 | tags: Mapping 64 | 65 | /// The typical size of a flight path of this Swallow. 66 | typicalFlightPathSize: DataSize 67 | 68 | /// This is a list. It really should not be used, but sometimes people make mistakes. Regardless, 69 | /// it should turn into an array type. 70 | list: List 71 | 72 | /// Swoop! 73 | /// 74 | /// This should not appear in the schema output. 75 | swoop: (String) -> String = (input) -> "SWOOP \(input)" 76 | 77 | /// Swoopwoop! 78 | /// 79 | /// This should also not appear in the schema output. 80 | function swoopwoop() = "swoopwoop!" 81 | 82 | /// soar! 83 | /// 84 | /// Don't show me in the schema because I don't show up in any rendered output. 85 | hidden soar: Boolean? 86 | } 87 | 88 | local generator = new SchemaGenerator { 89 | converters { 90 | [DataSize] { 91 | type = "string" 92 | description = "A data size description" 93 | } 94 | } 95 | } 96 | 97 | output = generator.generate(Swallow).output 98 | -------------------------------------------------------------------------------- /packages/pkl.experimental.syntax/DocCommentNode.pkl: -------------------------------------------------------------------------------- 1 | //===----------------------------------------------------------------------===// 2 | // Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // https://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | //===----------------------------------------------------------------------===// 16 | module pkl.experimental.syntax.DocCommentNode 17 | 18 | extends "Node.pkl" 19 | 20 | /// The doc comment itself, without the comment tokens (`///`). 21 | value: String 22 | 23 | local function wrapTextImpl(words: List, width: Int) = 24 | words.fold(Pair("", ""), (pair, word) -> 25 | let (result: String = pair.first) 26 | let (currentLine: String = pair.second) 27 | if (currentLine.length + word.length > width) 28 | Pair( 29 | if (result == "") currentLine 30 | else result + "\n" + currentLine, 31 | word 32 | ) 33 | else 34 | Pair( 35 | result, 36 | if (currentLine == "") word 37 | else currentLine + " " + word 38 | ) 39 | ) 40 | 41 | /// Wrap [text] at the specified column [width]. 42 | local function wrapParagraph(text: String, width: Int) = 43 | let (words = text.split(Regex("\\s+"))) 44 | let (result = words.fold(Pair("", ""), (pair, word) -> 45 | let (aggregate: String = pair.first) 46 | let (currentLine: String = pair.second) 47 | if (currentLine.length + word.length > width) 48 | Pair( 49 | if (aggregate == "") currentLine 50 | else aggregate + "\n" + currentLine, 51 | word 52 | ) 53 | else 54 | Pair( 55 | aggregate, 56 | if (currentLine == "") word 57 | else currentLine + " " + word 58 | ) 59 | )) 60 | List(result.first, result.second).filter((elem) -> !elem.isEmpty).join("\n") 61 | 62 | local function wrapText(text: String, width: Int) = 63 | let (paragraphs = text.split("\n\n")) 64 | paragraphs 65 | .map((it) -> wrapParagraph(it, width)) 66 | .join("\n\n") 67 | 68 | /// Configures this node to wrap lines when rendering. 69 | hidden autoWrap: Boolean = false 70 | 71 | function render(currentIndent: String) = 72 | let (wrapped = 73 | if (autoWrap) wrapText(value, maxColumnWidth - currentIndent.length) 74 | else value 75 | ) 76 | wrapped 77 | .split("\n") 78 | .map((line) -> 79 | if (line.isEmpty) "\(currentIndent)///" 80 | else "\(currentIndent)/// \(line)" 81 | ) 82 | .join("\n") 83 | --------------------------------------------------------------------------------