-
Notifications
You must be signed in to change notification settings - Fork 104
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
Upgrades gorm to 2.0 #131
Upgrades gorm to 2.0 #131
Conversation
9b141b1
to
357872b
Compare
/lgtm |
@@ -149,10 +148,10 @@ func addUsers(db *gorm.DB, log *log.Logger, data *app.Data) error { | |||
} | |||
|
|||
// Add scopes for user if not added already | |||
us := model.UserScope{UserID: user.ID, ScopeID: scope.ID} | |||
q = db.Model(&model.UserScope{}).Where(&us) | |||
us := &model.UserScope{UserID: user.ID, ScopeID: scope.ID} |
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.
could you please revert this to the old usage?
q = db.Model(...).Where(&us)
makes it quite clear the us
is passed as a reference
and may be modified.
api/pkg/service/catalog/syncer.go
Outdated
catalog := model.Catalog{} | ||
db.Model(job).Related(&catalog) | ||
catalog := &model.Catalog{} | ||
db.Model(job).Association("Catalog").Find(catalog) |
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.
could you please revert to the old style to pass &catalog
to indicate that the object is modified?
api/pkg/service/catalog/syncer.go
Outdated
@@ -146,15 +146,15 @@ func (s *syncer) Process() error { | |||
log := s.logger.With("action", "process") | |||
db := s.db | |||
|
|||
job := model.SyncJob{} | |||
job := &model.SyncJob{} | |||
|
|||
// helper to update job state | |||
setJobState := func(s model.JobState) { | |||
job.SetState(s) | |||
db.Model(&job).Updates(job) |
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 think we should use Model(&model.SyncJob{})
instead of &job
since it is confusing to read.
api/pkg/service/catalog/syncer.go
Outdated
log := s.logger.With("action", "update-job", "job-id", job.ID) | ||
|
||
txn := s.db.Begin() | ||
|
||
catalog := model.Catalog{} | ||
txn.Model(&job).Related(&catalog) | ||
catalog := &model.Catalog{} |
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.
same as above
api/pkg/service/resource/resource.go
Outdated
@@ -471,3 +466,10 @@ func invalidKindError(kind string) error { | |||
return resource.MakeInvalidKind(fmt.Errorf("resource kind '%s' not supported. Supported kinds are %v", | |||
kind, parser.SupportedKinds())) | |||
} | |||
|
|||
func isNotFoundError(err error) 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.
imho, this doesn't improve the readabilty.
One would isNotFoundError(err)
to return true if the err
is NotFound
and not a notFoundError
or fetchError
.
Moreover, it fails to log.Error for all errors other than NotFound
081991e
to
273e93b
Compare
Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
@@ -13,7 +13,7 @@ | |||
# limitations under the License. | |||
|
|||
- id: 1 | |||
version: 0.1 | |||
version: "0.1" |
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.
Is it the change in the gorm to change it to string ???
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.
@PuneetPunamiya , yes it has to be a string to represent "0.1.1" or even "alpha" etc
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.
/lgtm
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sthaha 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 |
Signed-off-by: Shivam Mukhade smukhade@redhat.com
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.