Skip to content
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

Merged
merged 1 commit into from
Nov 23, 2020
Merged

Upgrades gorm to 2.0 #131

merged 1 commit into from
Nov 23, 2020

Conversation

sm43
Copy link
Member

@sm43 sm43 commented Nov 2, 2020

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.

@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 2, 2020
@sm43 sm43 force-pushed the gorm-upgrade branch 2 times, most recently from 9b141b1 to 357872b Compare November 4, 2020 16:04
@piyush-garg
Copy link
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 9, 2020
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 11, 2020
@@ -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}
Copy link
Member

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.

catalog := model.Catalog{}
db.Model(job).Related(&catalog)
catalog := &model.Catalog{}
db.Model(job).Association("Catalog").Find(catalog)
Copy link
Member

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?

@@ -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)
Copy link
Member

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.

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{}
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -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 {
Copy link
Member

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

@sm43 sm43 force-pushed the gorm-upgrade branch 2 times, most recently from 081991e to 273e93b Compare November 19, 2020 10:33
Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
@@ -13,7 +13,7 @@
# limitations under the License.

- id: 1
version: 0.1
version: "0.1"
Copy link
Member

@PuneetPunamiya PuneetPunamiya Nov 23, 2020

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 ???

Copy link
Member

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

Copy link
Member

@sthaha sthaha left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 23, 2020
@sthaha
Copy link
Member

sthaha commented Nov 23, 2020

/approve

@tekton-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 23, 2020
@tekton-robot tekton-robot merged commit be7952f into tektoncd:master Nov 23, 2020
@sm43 sm43 deleted the gorm-upgrade branch January 4, 2021 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants