Skip to content

Feature 1635 - customizing service name with prefix, flag --prefix (-x)#1833

Closed
sosan wants to merge 13 commits intokubernetes:mainfrom
sosan:feature-1635
Closed

Feature 1635 - customizing service name with prefix, flag --prefix (-x)#1833
sosan wants to merge 13 commits intokubernetes:mainfrom
sosan:feature-1635

Conversation

@sosan
Copy link
Copy Markdown
Contributor

@sosan sosan commented Feb 23, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

The --prefix flag serves the purpose of allowing users to specify prefixes to be added to the names of services

Which issue(s) this PR fixes:

Feature #1635

Special notes for your reviewer:

I haven't had time to document the --prefix flag
documentation will be cooming soon in the following commits.

…a prefix to add the default used in naming services.

Added the appendPrefixName function, which takes a pointer to a KomposeObject and an array of prefixes. It appends the first prefix from the array to each service name in the KomposeObject after ensuring consistency using the cleanPrefix function. The cleanPrefix function ensures the format of prefixes, preventing issues with leading or trailing dashes affecting resulting service names.

Add unit tests for 'appendPrefixName' and 'cleanPrefix'

Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
…a prefix to add the default used in naming services.

Added the appendPrefixName function, which takes a pointer to a KomposeObject and an array of prefixes. It appends the first prefix from the array to each service name in the KomposeObject after ensuring consistency using the cleanPrefix function. The cleanPrefix function ensures the format of prefixes, preventing issues with leading or trailing dashes affecting resulting service names.

Add unit tests for 'appendPrefixName' and 'cleanPrefix'

Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 23, 2024
@k8s-ci-robot k8s-ci-robot requested review from cdrage and kadel February 23, 2024 23:49
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 23, 2024
Copy link
Copy Markdown
Member

@TessaIO TessaIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch @sosan. I left some comments below.

@cdrage
Copy link
Copy Markdown
Member

cdrage commented Mar 1, 2024

@TessaIO shouldn't we have this as a label instead? or do you think CLI parameter would be fine?

@TessaIO
Copy link
Copy Markdown
Member

TessaIO commented Mar 1, 2024

@TessaIO shouldn't we have this as a label instead? or do you think CLI parameter would be fine?

That's actually true if we want to offer users flexibility to specify per-service prefixes that's the option to go (I mean labels here). wdyt @sosan?

@cdrage
Copy link
Copy Markdown
Member

cdrage commented Mar 1, 2024

@TessaIO shouldn't we have this as a label instead? or do you think CLI parameter would be fine?

That's actually true if we want to offer users flexibility to specify per-service prefixes that's the option to go (I mean labels here). wdyt @sosan?

Yeah just thinking about it again, I think I'm good for terminal / cli based prefixes being added, we could always customize the name individually via labels instead.

sosan added 2 commits March 5, 2024 19:29
… local variables (prefixArray) from array to string

Changed to function name: prependPrefixName
Renamed tests to explain better tests behavior

Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
@sosan
Copy link
Copy Markdown
Contributor Author

sosan commented Mar 5, 2024

Updated cli

Sounds like a good idea to me. That way, we can fine-tune the names individually using labels

Copy link
Copy Markdown
Member

@TessaIO TessaIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments are left below.

Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
Copy link
Copy Markdown
Member

@TessaIO TessaIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Leaving final approve to @cdrage

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sosan, TessaIO

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2024
Copy link
Copy Markdown
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change requested

sosan added 4 commits March 23, 2024 18:19
Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
…nged container name :(

tests e2e, tests
use case from terminal to use prefix
complete user_guide.md with prefix -x
changed architecture.md to comment new version interface Loader
Copy link
Copy Markdown
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are going to add prefix, we should also add suffix...

I do not believe we should have -x either. Prefix and suffix should honestly be fixed after generation. I am not opposed to having this merged in as there is an issue opened for it, but we should also add suffix too.

@sosan
Copy link
Copy Markdown
Contributor Author

sosan commented Apr 2, 2024

we should also add suffix too.

ok, roger that

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 8, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 11, 2024
@TessaIO
Copy link
Copy Markdown
Member

TessaIO commented Apr 18, 2024

ping @cdrage

convertCmd.Flags().BoolVar(&GenerateNetworkPolicies, "generate-network-policies", false, "Specify whether to generate network policies or not")

convertCmd.Flags().BoolVar(&WithKomposeAnnotation, "with-kompose-annotation", true, "Add kompose annotations to generated resource")
convertCmd.Flags().StringVarP(&GlobalPrefixAdd, "prefix", "x", "", "Adds a custom prefix to service names")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove -x please. Are you able to add suffix to this PR as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Add a suffix with flag? Labels?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just flag like how you did it with suffix

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually honestly.... I'm not entirely sure why we need this. Thoughts @TessaIO

I think we are adding way too many labels or flags for just suffix : prefix naming.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 19, 2024
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

sosan added 3 commits April 22, 2024 16:38
fixed UnaddressableFieldAssign to function addPrefixToServiceName

Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
Signed-off-by: jose luis <2064537+sosan@users.noreply.github.com>
@cdrage
Copy link
Copy Markdown
Member

cdrage commented Apr 25, 2024

Hey sorry @sosan for some reason I didn't realize that we reached a conclusion on #1635 (comment) that we should actually close this PR, and I apologize the work you've put into this back and forth.

Going forward I do not think we should be adding too many suffix and prefix / name customizations unless it's "generic", if someone wants to edit the entire -tcp suffix, they could do it with a sed / ctrl +f / ctrl + replace after converting.

There's too much work and labels / parameters to be added to make something small like this happen.

@cdrage cdrage closed this Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants