Skip to content

Allow passing a Namespace/KubeNamespace object as namespaceΒ #2794

@sweco-sedalh

Description

@sweco-sedalh

Description of the feature or enhancement:

Allow, in addition to a string, passing an object (Namespace/KubeNamespace) as the metadata.namespace when constructing objects (both CDK8s and CDK8s+)

Use Case:

I commonly find myself writing something along the lines of:

const ns = new Namespace(this, "namespace");

new Role(this, "role", {
  metadata: {
    namespace: ns.name
  }
});

Proposed Solution:

Allow instead writing:

const ns = new Namespace(this, "namespace");

new Role(this, "role", {
  metadata: {
    namespace: ns
  }
});

By changing the type of namespace to string | Namespace | undefined and, on construction, check if it is an object and in that case call .name.

Other:

The code example above is for CDK8s+, but the same concept could also be useful for non-+ (KubeNamespace etc.), at least within each context (objects in CDK8s+ accepting Namespace, Kube*-objects accepting KubeNamespace), but there could also be compatibility between them (allow CDK8s+ objects to accept KubeNamespace, the opposite is likely not feasibly though).

  • πŸ‘‹ I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a πŸš€ Feature Request

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestNew/Enhanced functionality wantedneeds-triagePriority and effort undetermined yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions