konveyor / move2kube-api

HTTP REST API for move2kube
https://move2kube.konveyor.io/
Apache License 2.0
6 stars 18 forks source link

feat(api): add source and qa-skip as parameters for plan and outputs endpoints #155

Closed gabriel-farache closed 10 months ago

gabriel-farache commented 10 months ago

In order to allow users to run Move2Kube with the API in a non-interactive mode, I added the remote-source query parameter in the plan endpoint and the skip-qa query parameter in the outputs endpoints.

remote-source is expected a git URL that will be used by the cmd.

skip-qa will set the the flag qa-skip to true when executing the transformation cmd.

This will allow CI pipeline to test the usage of M2K without any interaction or pre-configured file.

Needs https://github.com/konveyor/move2kube/pull/1109 to be merged as it fixes a missing default value for SSHKeys; when skipping the QA, it causes an error.

github-actions[bot] commented 10 months ago

Thanks for making a pull request! 😃 One of the maintainers will review and advise on the next steps.

codecov[bot] commented 10 months ago

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (2e2bd55) 14.55% compared to head (f895e95) 14.48%.

Files Patch % Lines
internal/common/utils.go 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #155 +/- ## ========================================== - Coverage 14.55% 14.48% -0.07% ========================================== Files 2 2 Lines 213 214 +1 ========================================== Hits 31 31 - Misses 178 179 +1 Partials 4 4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

HarikrishnanBalagopal commented 10 months ago

@gabriel-farache Thanks for making the PR! A couple of questions:

  1. Is there a way to sanitize/validate the remote source/git URL?
  2. Is there a way to limit the size of the cloned repo to respect the max-upload-size flag https://github.com/konveyor/move2kube-api/blob/2e2bd550826fb1bc60a2224abcb154fb60b2c05d/cmd/main/move2kubeapi.go#L60 ?

It might require some changes in https://github.com/konveyor/move2kube to use something like https://confluence.atlassian.com/bbkb/how-to-check-your-repository-s-size-and-identify-large-files-1178867192.html $ git count-objects -vH to limit the size.

We can return an error message if the size is too large.

gabriel-farache commented 10 months ago

@gabriel-farache Thanks for making the PR! A couple of questions:

  1. Is there a way to sanitize the remote source URL and make sure that it is a real git URL?
  2. Is there a way to limit the size of the cloned repo to respect the max-upload-size flag https://github.com/konveyor/move2kube-api/blob/2e2bd550826fb1bc60a2224abcb154fb60b2c05d/cmd/main/move2kubeapi.go#L60 ?

It might require some changes in https://github.com/konveyor/move2kube to use something like https://confluence.atlassian.com/bbkb/how-to-check-your-repository-s-size-and-identify-large-files-1178867192.html $ git count-objects -vH to limit the size

@HarikrishnanBalagopal For the 1st point, yes it's doable

For the 2nd point it would be more complicated To do it we would have to clone the repo then compute its size; so the storage will be taken for that amount of time. If I am not wrong, the CLI is cloning the repo in /tmp then it deletes it. So what is the requirements behind max-upload-size?

seshapad commented 10 months ago

@gabriel-farache The DCO for the PR has failed. To pass this test, could you please sign your commits?

gabriel-farache commented 10 months ago

@seshapad Sorry, I forgot the -s in my commit command, it's done

seshapad commented 10 months ago

@seshapad Sorry, I forgot the -s in my commit command, it's done

No worries. Thank you for addressing it.

HarikrishnanBalagopal commented 10 months ago

@gabriel-farache Have implemented the size limit in CLI https://github.com/konveyor/move2kube/pull/1111 Added a --max-clone-size flag to both the plan and transform commands. It is the maximum size in bytes. Default is -1 where negative values mean infinite bytes.