-
Notifications
You must be signed in to change notification settings - Fork 43
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: Also reconcile repo policy run on repo registration #1029
Conversation
internal/reconcilers/artifacts.go
Outdated
@@ -125,7 +147,9 @@ func (e *Reconciler) handleArtifactsReconcilerEvent(ctx context.Context, evt *Re | |||
artifacts, err := cli.ListPackagesByRepository(ctx, isOrg, repository.RepoOwner, | |||
CONTAINER_TYPE, int64(repository.RepoID), 1, 100) | |||
if err != nil { | |||
return fmt.Errorf("error retrieving artifacts: %w", err) | |||
// we do not return error since it's a valid use case for a repository to not have artifacts |
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.
We probably want to explicitly check that the error is a NotFound
error
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.
Added a separate 404 check 👍
@@ -132,7 +132,7 @@ func (c *RestClient) ListPackagesByRepository(ctx context.Context, isOrg bool, o | |||
artifacts, resp, err = c.client.Users.ListPackages(ctx, "", opt) | |||
} | |||
if err != nil { | |||
return allContainers, err | |||
return allContainers, resp, 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.
An alternative is to just return an empty list if there's a 404 here, and no error. This way we don't need to expose the response. What do you think?
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 wasn't sure, because we do this pagination where we return what we have so far even in the error case. WDYT, should we keep that?
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.
Alternatively, what about returning a special error code on 404?
Long term I think we want to move to returning a channel from the List functions and paginate inside the API instead of letting the caller do the work.
3bacc61
to
6b936f8
Compare
We used to only evaluate policy for artifacts when we created a repo. This is not correct. We should also evaluate the repository itself.
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
6b936f8
to
dc703d1
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.
🍻
We used to only evaluate policy for artifacts when we created a repo. This is not
correct. We should also evaluate the repository itself.