Skip to content

KRM function "ensure-name-substring" should have a parameter "delimiter" #4135

Open
@isihu

Description

@isihu

Describe your problem

I want to provide a kpt package for my users.
I use this function to ensure consistent naming across the resources of the package.
In my kpt package the prefix is set to "example" and added to the resources successfully, e.g. "example-deployment".

When a user clones the kpt package and changes the prefix to "myservice", the name of the deployment becomes "myservice-example-deployment" while I want the name to be "myservice-deployment"

Potential solution

I can provide a delimiter to the functionConfig, like "-". Then the function behaves as follows:

if delimiter in original_resource_name:
  # replace the previous prefix with the new one
  new_resource_name = prefix + delimiter + original_resource_name.split(delimiter, 1)[1] 
else:
  # current behavior
  new_resource_name = prefix + delimiter + original_resource_name 

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions