-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- refactor codegen to allow for the required changes to be made - add support for overlays in codegen - add kubernetes overlay for custom resources
- Loading branch information
1 parent
bceafff
commit fd8162e
Showing
34 changed files
with
970 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
codegen/resources/overlays/kubernetes/apiextensions/CustomResource.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package besom.api.kubernetes.apiextensions | ||
|
||
import besom.util.interpolator.{*, given} | ||
import besom.types.ResourceType | ||
|
||
/** CustomResource represents a resource definition we'd use to create an instance of a Kubernetes CustomResourceDefinition (CRD). | ||
* | ||
* For example, the CoreOS Prometheus operator exposes a CRD `monitoring.coreos.com/ServiceMonitor` to create a `ServiceMonitor`, we'd pass | ||
* a `CustomResourceArgs` containing the `ServiceMonitor` definition to `apiextensions.CustomResource`. | ||
*/ | ||
trait CustomResourceLike extends besom.CustomResource: | ||
/** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest | ||
* internal value, and may reject unrecognized values. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources Kubernetes API Version]] | ||
* @return | ||
*/ | ||
def apiVersion: besom.types.Output[String] | ||
|
||
/** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client | ||
* submits requests to. Cannot be updated. In CamelCase. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds Kubernetes Kinds]] | ||
* @return | ||
*/ | ||
def kind: besom.types.Output[String] | ||
|
||
/** Standard Kubernetes object metadata | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata Kubernetes Metadata]] | ||
* @return | ||
* the object metadata | ||
*/ | ||
def metadata: besom.types.Output[besom.api.kubernetes.meta.v1.outputs.ObjectMeta] | ||
end CustomResourceLike | ||
|
||
trait CustomResourceFactory[ | ||
R <: besom.api.kubernetes.apiextensions.CustomResourceLike, | ||
A <: besom.api.kubernetes.apiextensions.CustomResourceArgsLike | ||
]: | ||
|
||
/** Create a CustomResource resource with the given unique name, arguments, and options. | ||
* | ||
* @param name | ||
* The unique name of the resource. | ||
* @param args | ||
* The arguments to use to populate this resource's properties. | ||
* @param opts | ||
* A bag of options that control this resource's behavior. | ||
*/ | ||
def apply(using ctx: besom.types.Context, dd: besom.types.ResourceDecoder[R], ae: besom.types.ArgsEncoder[A])( | ||
name: besom.util.NonEmptyString, | ||
args: A, | ||
opts: besom.ResourceOptsVariant.Custom ?=> besom.CustomResourceOptions = besom.CustomResourceOptions() | ||
): besom.types.Output[R] = | ||
ctx.readOrRegisterResource[R, A](p"kubernetes:${args.apiVersion}:${args.kind}".map(ResourceType(_)), name, args, opts(using besom.ResourceOptsVariant.Custom)) | ||
|
||
given factoryOutputOps: {} with | ||
extension (output: besom.types.Output[R]) | ||
def urn: besom.types.Output[besom.types.URN] = output.flatMap(_.urn) | ||
def id: besom.types.Output[besom.types.ResourceId] = output.flatMap(_.id) | ||
def apiVersion: besom.types.Output[String] = output.flatMap(_.apiVersion) | ||
def kind: besom.types.Output[String] = output.flatMap(_.kind) | ||
def metadata: besom.types.Output[besom.api.kubernetes.meta.v1.outputs.ObjectMeta] = output.flatMap(_.metadata) |
31 changes: 31 additions & 0 deletions
31
codegen/resources/overlays/kubernetes/apiextensions/CustomResourceArgs.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package besom.api.kubernetes.apiextensions | ||
|
||
/** The set of arguments for constructing a CustomResource resource. | ||
* | ||
* NOTE: This type is fairly loose, since other than `apiVersion` and `kind`, there are no fields required across all CRDs. | ||
*/ | ||
trait CustomResourceArgsLike: | ||
/** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest | ||
* internal value, and may reject unrecognized values. | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources Kubernetes API Version]] | ||
* @return | ||
*/ | ||
def apiVersion: besom.types.Input[String] | ||
|
||
/** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client | ||
* submits requests to. Cannot be updated. In CamelCase. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds Kubernetes Kinds]] | ||
* @return | ||
*/ | ||
def kind: besom.types.Input[String] | ||
|
||
/** Standard Kubernetes object metadata | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata Kubernetes Metadata]] | ||
* @return | ||
* the object metadata | ||
*/ | ||
def metadata: besom.types.Input[scala.Option[besom.api.kubernetes.meta.v1.inputs.ObjectMetaArgs]] |
72 changes: 72 additions & 0 deletions
72
codegen/resources/overlays/kubernetes/apiextensions/CustomResourcePatch.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package besom.api.kubernetes.apiextensions | ||
|
||
import besom.util.interpolator.{*, given} | ||
import besom.types.ResourceType | ||
|
||
/** CustomResourcePatchPatch represents a resource definition we'd use to patch an instance of a Kubernetes CustomResourceDefinition (CRD). | ||
* | ||
* For example, the CoreOS Prometheus operator exposes a CRD `monitoring.coreos.com/ServiceMonitor` to instantiate this as a Pulumi | ||
* resource, one could call `new CustomResourcePatch`, passing the `ServiceMonitor` resource definition as an argument. | ||
*/ | ||
trait CustomResourcePatchLike extends besom.CustomResource: | ||
/** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest | ||
* internal value, and may reject unrecognized values. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources Kubernetes API Version]] | ||
* @return | ||
*/ | ||
def apiVersion: besom.types.Output[String] | ||
|
||
/** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client | ||
* submits requests to. Cannot be updated. In CamelCase. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds Kubernetes Kinds]] | ||
* @return | ||
*/ | ||
def kind: besom.types.Output[String] | ||
|
||
/** Standard Kubernetes object metadata | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata Kubernetes Metadata]] | ||
* @return | ||
* the object metadata | ||
*/ | ||
def metadata: besom.types.Output[besom.api.kubernetes.meta.v1.outputs.ObjectMeta] | ||
end CustomResourcePatchLike | ||
|
||
trait CustomResourcePatchFactory[ | ||
R <: besom.api.kubernetes.apiextensions.CustomResourcePatchLike, | ||
A <: besom.api.kubernetes.apiextensions.CustomResourcePatchArgsLike | ||
]: | ||
|
||
/** Create a CustomResourcePatch resource with the given unique name, arguments, and options. | ||
* | ||
* @param name | ||
* The unique name of the resource. | ||
* @param args | ||
* The arguments to use to populate this resource's properties. | ||
* @param opts | ||
* A bag of options that control this resource's behavior. | ||
*/ | ||
def apply(using ctx: besom.types.Context, dd: besom.types.ResourceDecoder[R], ae: besom.types.ArgsEncoder[A])( | ||
name: besom.util.NonEmptyString, | ||
args: A, | ||
opts: besom.ResourceOptsVariant.Custom ?=> besom.CustomResourceOptions = besom.CustomResourceOptions() | ||
): besom.types.Output[R] = | ||
ctx.readOrRegisterResource[R, A]( | ||
p"kubernetes:${args.apiVersion}:${args.kind}Patch".map(ResourceType(_)), | ||
name, | ||
args, | ||
opts(using besom.ResourceOptsVariant.Custom) | ||
) | ||
|
||
given factoryOutputOps: {} with | ||
extension (output: besom.types.Output[R]) | ||
def urn: besom.types.Output[besom.types.URN] = output.flatMap(_.urn) | ||
def id: besom.types.Output[besom.types.ResourceId] = output.flatMap(_.id) | ||
def apiVersion: besom.types.Output[String] = output.flatMap(_.apiVersion) | ||
def kind: besom.types.Output[String] = output.flatMap(_.kind) | ||
def metadata: besom.types.Output[besom.api.kubernetes.meta.v1.outputs.ObjectMeta] = output.flatMap(_.metadata) |
32 changes: 32 additions & 0 deletions
32
codegen/resources/overlays/kubernetes/apiextensions/CustomResourcePatchArgs.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package besom.api.kubernetes.apiextensions | ||
|
||
/** The set of arguments for constructing a CustomResourcePatch resource. | ||
* | ||
* NOTE: This type is fairly loose, since other than `apiVersion` and `kind`, there are no fields required across all CRDs. | ||
*/ | ||
trait CustomResourcePatchArgsLike: | ||
/** APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest | ||
* internal value, and may reject unrecognized values. | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources Kubernetes API Version]] | ||
* @return | ||
*/ | ||
def apiVersion: besom.types.Input[String] | ||
|
||
/** Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client | ||
* submits requests to. Cannot be updated. In CamelCase. | ||
* | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds Kubernetes Kinds]] | ||
* @return | ||
*/ | ||
def kind: besom.types.Input[String] | ||
|
||
/** Standard Kubernetes object metadata | ||
* @see | ||
* [[https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata Kubernetes Metadata]] | ||
* @return | ||
* the object metadata | ||
*/ | ||
def metadata: besom.types.Input[scala.Option[besom.api.kubernetes.meta.v1.inputs.ObjectMetaArgs]] | ||
|
Oops, something went wrong.