Skip to content

Commit

Permalink
Fix constraint in Probe (#14)
Browse files Browse the repository at this point in the history
Add grpc to the set of possible properties
  • Loading branch information
bioball authored Jan 16, 2025
1 parent 68419e8 commit 583e31a
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.1
1.1.2
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kotlin {
jvmToolchain(17)
}

val pklPackageVersion = "1.1.1"
val pklPackageVersion = file("VERSION").readText().trim()

val k8sVersions = listOf(
"v1.19.6",
Expand Down
9 changes: 8 additions & 1 deletion generated-package/K8sObject.pkl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -131,6 +131,13 @@ const function hasNonNullPortNames(l: Listing): Boolean = (l.length > 1).implies
const function exactlyOneSet(a: Any, b: Any, c: Any) =
(a != null).xor(b != null).xor(c != null) && !(a != null && b != null && c != null)

/// Tells if exactly one of the four arguments is non-null.
const function exactlyOneSet4(a: Any, b: Any, c: Any, d: Any) =
(a != null && b == null && c == null && d == null)
|| (a == null && b != null && c == null && d == null)
|| (a == null && b == null && c != null && d == null)
|| (a == null && b == null && c == null && d != null)

/// Tells if [str] is only set when [cond] holds.
const function onlyAllowedIf(str: String?, cond: Boolean) = (str != null).implies(cond)

Expand Down
6 changes: 3 additions & 3 deletions generated-package/PklProject
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,11 +22,11 @@ package {
authors {
"The Pkl Team <pkl-oss@group.apple.com>"
}
version = "1.1.0"
version = "1.1.2"
baseUri = "package://pkg.pkl-lang.org/pkl-k8s/k8s"
packageZipUrl = "https://github.com/apple/pkl-k8s/releases/download/\(name)@\(version)/\(name)@\(version).zip"
sourceCode = "https://github.com/apple/pkl-k8s"
sourceCodeUrlScheme = "https://github.com/apple/pkl-k8s/blob/1.1.0/generated-package%{path}#%{line}-%{endLine}"
sourceCodeUrlScheme = "https://github.com/apple/pkl-k8s/blob/1.1.2/generated-package%{path}#%{line}-%{endLine}"
license = "Apache-2.0"
description = """
Templates for configuring [Kubernetes](https://kubernetes.io),
Expand Down
2 changes: 1 addition & 1 deletion generated-package/api/core/v1/Probe.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ successThreshold: Int32?
initialDelaySeconds: Int32?

/// Exec specifies the action to take.
exec: ExecAction?(module.exactlyOneSet(this, httpGet, tcpSocket))
exec: ExecAction?(module.exactlyOneSet4(this, httpGet, tcpSocket, grpc))

/// GRPC specifies an action involving a GRPC port.
@K8sVersion { introducedIn = "1.23" }
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/pkl/k8s/templates/Overrides.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -478,7 +478,7 @@ val propertyTypeOverrides: MutableMap<Triple<String, String?, String>, String> =
Triple("api.core.v1.ContainerPort", null, "hostPort") to portNumberNullable,
Triple("api.core.v1.EphemeralContainer", null, "imagePullPolicy") to alwaysNeverIfNotPresentNullable,
Triple("api.core.v1.EphemeralContainer", null, "name") to rfc1035Label,
Triple("api.core.v1.Probe", null, "exec") to "ExecAction?(module.exactlyOneSet(this, httpGet, tcpSocket))",
Triple("api.core.v1.Probe", null, "exec") to "ExecAction?(module.exactlyOneSet4(this, httpGet, tcpSocket, grpc))",
Triple(
"api.core.v1.Lifecycle",
"LifecycleHandler",
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/org/pkl/k8s/templates/K8sObject.pkl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -131,6 +131,13 @@ const function hasNonNullPortNames(l: Listing): Boolean = (l.length > 1).implies
const function exactlyOneSet(a: Any, b: Any, c: Any) =
(a != null).xor(b != null).xor(c != null) && !(a != null && b != null && c != null)

/// Tells if exactly one of the four arguments is non-null.
const function exactlyOneSet4(a: Any, b: Any, c: Any, d: Any) =
(a != null && b == null && c == null && d == null)
|| (a == null && b != null && c == null && d == null)
|| (a == null && b == null && c != null && d == null)
|| (a == null && b == null && c == null && d != null)

/// Tells if [str] is only set when [cond] holds.
const function onlyAllowedIf(str: String?, cond: Boolean) = (str != null).implies(cond)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down

0 comments on commit 583e31a

Please sign in to comment.