-
Notifications
You must be signed in to change notification settings - Fork 772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: env_file configmap name length #1743
Conversation
Welcome @ThijsBroersen! |
@@ -851,8 +851,15 @@ func GetContentFromFile(file string) (string, error) { | |||
// FormatEnvName format env name | |||
func FormatEnvName(name string) string { | |||
envName := strings.Trim(name, "./") | |||
// only take string after the last slash only if the string contains a slash | |||
if strings.Contains(envName, "/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This helps, does this break anything though @AhmedGrati with regards to how we use env?
This also cleans up the really long configmap names, but I'm unsure if they would have conflicts when there are multiple containers.
If you can also add a test case for this under k8sutils_test.go that'd be awesome. Otherwise, good PR 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think it will work as long as env_file names are unique. When different env_file's with the same name are references (from different directories) it will clash.
Could also just only cap at the last, let's say 60 chars? And not filter by last /
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want anything changed? If not could it be merged soon? I could really use this in a new version of Kompose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I think that the names generated should be from env_file names from the last slash.. I really doubt that there will be multiple env file names in different directories for a docker compose project.
HOWEVER if there is, I think that they should be the same name, but one of them filename_1
, etc. if there are more of the same file AND Kompose does a warning.
However, I don't feel comfortable merging the PR until we have these two tasks:
- tests added to k8sutils_test.go
- test for if there are two env file names in different directories
- implement renaming to filename_number if there are multiple env files of the same name but in different directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, just took a short browse. Added a new env-multiple
fixture and test but now sure how to implement this. My thinking would be to check existing configmaps before inserting the new. If a configmap with the same name exists, append a 1 and try again. If that also exists a 2, and so on..
Could you give me a pointer? Or perhaps someone else wants to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't actually get it @ThijsBroersen. Can you please clarify it more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @ThijsBroersen. Maybe a unit test for this would make it even better 🙏.
.gitpod.yml
Outdated
# This configuration file was automatically generated by Gitpod. | ||
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) | ||
# and commit this file to your remote git repository to share the goodness with others. | ||
|
||
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart | ||
|
||
tasks: | ||
- init: go get && go build ./... && go test ./... && make | ||
command: go run . | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should not be added.
@@ -851,8 +851,15 @@ func GetContentFromFile(file string) (string, error) { | |||
// FormatEnvName format env name | |||
func FormatEnvName(name string) string { | |||
envName := strings.Trim(name, "./") | |||
// only take string after the last slash only if the string contains a slash | |||
if strings.Contains(envName, "/") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't actually get it @ThijsBroersen. Can you please clarify it more?
I'm good with this PR! LGTM! I understand about writing a golang test, I've opened up an issue here so we make sure we add a future test: #1745 |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cdrage, ThijsBroersen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
You'll have to rebase the issue to pass the new tests |
ping @ThijsBroersen can u please rebase? |
fix filename to configmap name transformer
I rebased as requested but the new tests will likely still fail because I did not found a way yet to take into account duplicate names. Should I comment out the new test in |
Thanks for the contribution @ThijsBroersen. I'm Gonna take care of the tests. |
fix filename to configmap name transformer
What type of PR is this?
bug
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #1738
Special notes for your reviewer:
I was unable to run tests, could not figure out what system requirements were needed to run the tests.Tests are adjusted to match new configmap name