Skip to content

Implement Interface definition for DownloadInMemory #189

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

Merged
merged 5 commits into from
Nov 27, 2023

Conversation

maysunfaisal
Copy link
Member

@maysunfaisal maysunfaisal commented Nov 17, 2023

What does this PR do?:

  • Implement Interface definition for DownloadInMemory and DownloadGitRepoResources
  • Provide mock implementation DownloadInMemory
  • Update all occurrences of DownloadInMemory invocation
  • Update tests to include handling of mock invocation
  • Update YAML Reader func ReadKubernetesYaml() to pass in Token and Devfile Utils Client to enable reading from private git repos
  • Update function/API description to highlight new updates/changes
  • Update README and documentation how to use Devfile Utils

Which issue(s) this PR fixes:

Fixes devfile/api#1221

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened and linked to this PR, if they are not in the PR scope due to various constraints.

  • Unit/Functional tests

  • QE Integration test

  • Documentation (READMEs, Product Docs, Blogs, Education Modules, etc.)

  • Client Impact

  • Gosec scans

How to test changes / Special notes to the reviewer:

Tests should pass

Copy link

codecov bot commented Nov 17, 2023

Codecov Report

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

Comparison is base (11c85d0) 61.05% compared to head (59df524) 60.53%.
Report is 1 commits behind head on main.

Files Patch % Lines
pkg/devfile/parser/util/utils.go 10.00% 36 Missing ⚠️
pkg/util/mock.go 0.00% 13 Missing ⚠️
pkg/devfile/parser/parse.go 45.45% 6 Missing ⚠️
pkg/devfile/parser/util/mock.go 80.00% 3 Missing ⚠️
pkg/devfile/parser/context/context.go 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #189      +/-   ##
==========================================
- Coverage   61.05%   60.53%   -0.53%     
==========================================
  Files          42       43       +1     
  Lines        5017     5047      +30     
==========================================
- Hits         3063     3055       -8     
- Misses       1761     1802      +41     
+ Partials      193      190       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maysunfaisal maysunfaisal marked this pull request as ready for review November 20, 2023 21:59
@openshift-ci openshift-ci bot requested review from elsony and feloy November 20, 2023 21:59
@@ -38,6 +39,8 @@ type YamlSrc struct {
Path string
// URL of the yaml file
URL string
// Token to access a private URL like a private repository
Token string
Copy link
Collaborator

Choose a reason for hiding this comment

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

before I start reviewing, I'm wondering if by-design we can ONLY accept a single token instead of a token list?
saw you have the readkubernetesyaml with the token passed in. led me to think of the case that the private repo A contains devfile.yaml, which has a kubernetes component reference to a private repo B. In this case, only one token can be passed in, it's gonna cause problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that is a valid question but which is currently out of scope for this issue. We have the same issue in HAS with SPI where we only support one token and if someone's devfile has multiple private repo then its something we dont support now.

Signed-off-by: Maysun J Faisal <[email protected]>
Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

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

generally looks good, just some minor comments.

README.md Outdated
```go
src: YamlSrc{
URL: "http://github.com/my-private-repo",
Token: "my-PAT",
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation?

README.md Outdated
values, err := ReadKubernetesYaml(src, fs, nil)
```

If you would like to use the mock implementation for the `DevfileUtils` interface method defined in `pkg/devfile/parser/util/interface.go`, then use
Copy link
Collaborator

Choose a reason for hiding this comment

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

link to the file would be better

return err
}

if !gitUrl.IsFile || gitUrl.Revision == "" || !strings.Contains(gitUrl.Path, OutputDevfileYamlPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I couldn't recall. but why the giturl path has to contain odo-devfile.yaml?

Copy link
Collaborator

Choose a reason for hiding this comment

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

should it be devfile.yaml or devfile.yml?

Copy link
Member Author

@maysunfaisal maysunfaisal Nov 27, 2023

Choose a reason for hiding this comment

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

I am not sure, this is a just a cut-paste from another file when I was re-arranging it https://github.com/devfile/library/blob/main/pkg/devfile/parser/utils.go#L52

Copy link
Member Author

Choose a reason for hiding this comment

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

I opened a bug to handle this devfile/api#1362

Signed-off-by: Maysun J Faisal <[email protected]>
Copy link
Collaborator

@yangcao77 yangcao77 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 change. looks good to me

Copy link

openshift-ci bot commented Nov 27, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: maysunfaisal, yangcao77
Once this PR has been reviewed and has the lgtm label, please assign michael-valdron for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@maysunfaisal maysunfaisal merged commit 38de98b into devfile:main Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide Mock Interface for Devfile Downloads on devfile/library
2 participants