Skip to content
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 issue https://github.com/kubernetes/kompose/issues/1683 #1684

Merged
merged 6 commits into from
Jan 2, 2024

Conversation

realgam3
Copy link
Contributor

@realgam3 realgam3 commented Aug 4, 2023

What type of PR is this?

/kind bug

Which issue(s) this PR fixes:

Fixes #1683

Special notes for your reviewer:

  • Convert absolute paths to relative paths
  • Replace Windows paths \ to Linux paths /

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 4, 2023
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 4, 2023
pkg/app/app.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AhmedGrati AhmedGrati 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 PR. left some comments.

pkg/app/app.go Outdated Show resolved Hide resolved
@realgam3 realgam3 requested a review from cdrage August 23, 2023 20:09
Copy link
Contributor

@AhmedGrati AhmedGrati 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 PR @realgam3. It looks good overall, but I think adding unit tests showing how the mentioned issues were fixed should be a great addition. wdyt?

@realgam3
Copy link
Contributor Author

Thanks for the PR @realgam3. It looks good overall, but I think adding unit tests showing how the mentioned issues were fixed should be a great addition. wdyt?

The tests are running on Linux so the windows fix is not relevant to the test. and I already fixed the unit test.
But I can add tests for:

What do you think?

@AhmedGrati
Copy link
Contributor

@realgam3 yes please you can add/update existing tests for pod envfile.

@realgam3
Copy link
Contributor Author

realgam3 commented Aug 29, 2023

@realgam3 yes please you can add/update existing tests for pod envfile.

I will, Thank you!

Edit:
Hi, @AhmedGrati

While I'm trying to create test for pod I am using the command:

./kompose -f script/test/fixtures/configmap-pod/docker-compose.yaml convert --stdout -j

To create a JSON file as other tests and I get the error:

INFO Create kubernetes pod instead of pod controller due to restart policy: no 
FATA cannot convert to one file while specifying a json output file or stdout option 

Is it a known issue? or am I missing something?

  • I've added the test JSON template manually checking that it actually looks like what should have been the output of kompose. if -j and --stdout worked...

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 31, 2023
Copy link
Contributor

@AhmedGrati AhmedGrati left a comment

Choose a reason for hiding this comment

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

@realgam3 can we change the test output-k8s-template.json to yaml format?

@domehahn
Copy link

Hi, it would be really cool if the commit was merged. Thanks.

@AhmedGrati
Copy link
Contributor

Hi @domehahn @realgam3, I'm getting time off, I'll review it next week. Thanks for your understanding!

Copy link
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.

Only one comment with regards to using [0] which isn't a good idea.

We also need tests added to kubernetes.go

Sorry for the delayed response in review! It's been a busy couple of weeks.

@@ -220,7 +220,8 @@ func (k *Kubernetes) InitSvc(name string, service kobject.ServiceConfig) *api.Se

// InitConfigMapForEnv initializes a ConfigMap object
func (k *Kubernetes) InitConfigMapForEnv(name string, opt kobject.ConvertOptions, envFile string) *api.ConfigMap {
envs, err := GetEnvsFromFile(envFile)
workDir := filepath.Dir(opt.InputFiles[0])
Copy link
Member

Choose a reason for hiding this comment

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

Using opt.InputFiles[0] throughout the code is kinda scary, I'd advise that we check to see that it's not an empty array.

What would be better is putting this into a function instead similar to

// GetComposeFileDir returns compose file directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One question?

How you can convert docker-compose files without files?
If opt.InputFiles is empty there is nothing to do... if there is a way to use stdin to get the the docker-compose file that's another issue and we need to prepare for it.

GetComposeFileDir also Doesn't check if the InputFiles is empty and it needs to be fixed because it search for / and it will not find it in windows... it's really bad idea to do path operations yourself.

But if you want me to do more checks let me know...

Copy link
Member

Choose a reason for hiding this comment

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

Just checking to see if opt.InputFiles is empty and then fail is enough.

It's just odd having it check the first element of the array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's now ready

@AhmedGrati
Copy link
Contributor

ping @realgam3. Any updates on this?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 18, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed 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. labels Dec 16, 2023
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 16, 2023
@realgam3
Copy link
Contributor Author

ping @realgam3. Any updates on this?

Done

@realgam3 realgam3 requested a review from cdrage December 16, 2023 14:31
@realgam3
Copy link
Contributor Author

@cdrage, @AhmedGrati anything else you need from me?

@AhmedGrati
Copy link
Contributor

AhmedGrati commented Dec 18, 2023

@realgam3 gonna review it ASAP.

@realgam3
Copy link
Contributor Author

@realgam3 gonna review it ASAP.

Any updates / comments?
I don't want to miss the opportunity to push this update, this is an important fix for windows and linux users.

Copy link
Contributor

@AhmedGrati AhmedGrati left a comment

Choose a reason for hiding this comment

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

Leaving final approve to @cdrage!

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 28, 2023
@cdrage cdrage merged commit 92ca12a into kubernetes:main Jan 2, 2024
9 of 10 checks passed
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AhmedGrati, cdrage, realgam3

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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/bug Categorizes issue or PR as related to a bug. 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.

[BUG] pod env_file does not create configmaps
5 participants