-
Notifications
You must be signed in to change notification settings - Fork 174
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
Fixed incorrect depsdev getporject #1438
Fixed incorrect depsdev getporject #1438
Conversation
- Fixed the issue of incorrect GetProject issue - Fixes guacsec#1413 Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
916ad99
to
1843c45
Compare
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 @naveensrinivasan! A few comments
@@ -568,7 +567,7 @@ func (d *depsCollector) collectAdditionalMetadata(ctx context.Context, pkgType s | |||
logger.Debugf("The project key was not found in the map: %v", projectReq.ProjectKey) | |||
project, err = d.client.GetProject(ctx, projectReq) | |||
if err != nil { | |||
logger.Debugf("unable to get project for: %v, error: %v", projectReq.ProjectKey.Id, err) | |||
logger.Infof("unable to get project for: %v, error: %v", projectReq.ProjectKey.Id, err) |
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.
nit: This query will still fail for various reasons, so I think it will be too verbose for Info level. Keeping it as Debug should be fine because #1422 will be merged soon.
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.
Kept it as a debug in PR #2009
t.Errorf("NewDepsCollector() error = %v", err) | ||
return | ||
} | ||
if err := c.collectAdditionalMetadata(context.Background(), tt.pkgType, tt.namespace, tt.name, tt.version, tt.pkgComponent); (err != nil) != tt.wantErr { |
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.
nit: use ctx
defined above instead of context.Background()
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.
Using ctx
instead of context.Background
in PR #2009.
t.Errorf("NewDepsCollector() error = %v", err) | ||
return | ||
} | ||
if err := c.collectAdditionalMetadata(context.Background(), tt.pkgType, tt.namespace, tt.name, tt.version, tt.pkgComponent); (err != nil) != tt.wantErr { |
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.
If retrieving the project fails, then collectAdditionalMetadata
logs the error instead of returning it. As a result, this test doesn't really capture what is intended to be tested (i.e. that the d.client.GetProject
call does not fail).
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 are right, collectAdditionalMetadata
has logs instead of errors, so the tests are now checking the logs to see whether they contain the expected error. Again, this is in PR #2009.
// Based on the issue https://github.com/guacsec/guac/issues/1413, we need to ensure | ||
// that the .git suffix is removed from the repository name. This is because some | ||
// repository URLs might include the .git suffix which is not expected by certain endpoints. | ||
m.Name = strings.TrimSuffix(m.Name, ".git") |
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.
Should we also trim .git
after possibly removing the version? If there is a version specified after the .git
then it won't be removed.
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.
Yeah, the code now trims the .git
after removing the version. Thanks!
This pull request has been automatically marked as stale because it has not had recent activity (60 days of inactivity). |
Hi @naveensrinivasan just pinging on this from stale-bot notification - are you still looking to finish up this PR? |
This pull request has been automatically marked as stale because it has not had recent activity (60 days of inactivity). |
@naveensrinivasan should we close this or will you be finishing it up? Thanks |
Sorry I don't have cycles now. |
This pull request has been automatically marked as stale because it has not had recent activity (60 days of inactivity). |
This pull request has been automatically closed because there has been no activity for 90 days. |
Reopening as the fix may be needed. |
This PR is being continued in #2009. |
Closing this as continued work in #2009. |
Description of the PR
PR Checklist
-s
flag togit commit
.make generate
has been runcollectsub
protobuf has been changed,make proto
has been run