-
Notifications
You must be signed in to change notification settings - Fork 327
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
feat(kuma-cp) Added creation and modification time to core entities #521
Conversation
8020aa0
to
39c7557
Compare
statement := `INSERT INTO resources VALUES ($1, $2, $3, $4, $5, $6);` | ||
_, err = r.db.Exec(statement, opts.Name, "", opts.Mesh, resource.GetType(), version, string(bytes)) // todo(jakubdyszkiewicz) solve db migration | ||
statement := `INSERT INTO resources VALUES ($1, $2, $3, $4, $5, $6, $7, $8);` | ||
now := time.Now() |
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.
Why creationTime/modificationTime
is set at DAO layer instead of Service layer ?
@@ -107,11 +111,13 @@ func (r *postgresResourceStore) Update(_ context.Context, resource model.Resourc | |||
if err != nil { | |||
return errors.Wrap(err, "failed to convert meta version to int") | |||
} | |||
statement := `UPDATE resources SET spec=$1, version=$2 WHERE name=$3 AND mesh=$4 AND type=$5 AND version=$6;` | |||
statement := `UPDATE resources SET spec=$1, version=$2, modification_time=$3 WHERE name=$4 AND mesh=$5 AND type=$6 AND version=$7;` | |||
now := time.Now() |
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.
Why modificationTime
is set at DAO layer instead of Service layer ?
@@ -74,10 +85,13 @@ func (c *memoryStore) Create(_ context.Context, r model.Resource, fs ...store.Cr | |||
return store.ErrorResourceAlreadyExists(r.GetType(), opts.Name, opts.Mesh) | |||
} | |||
|
|||
now := time.Now() |
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.
Why creationTime/modificationTime
is set at DAO layer instead of Service layer ?
@@ -114,6 +128,7 @@ func (c *memoryStore) Update(_ context.Context, r model.Resource, fs ...store.Up | |||
return store.ErrorResourceConflict(r.GetType(), r.GetMeta().GetName(), r.GetMeta().GetMesh()) | |||
} | |||
meta.Version = meta.Version.Next() | |||
meta.ModificationTime = time.Now() |
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.
Why modificationTime
is set at DAO layer instead of Service layer ?
c3e3c85
to
67e23e6
Compare
67e23e6
to
e277f8b
Compare
Summary
Added creation and modification time to core entities including postgres migration.
It's not yet exposed on kumactl/API server. If we want to expose it on API side, lets discuss it and do it as a separate PR.
On K8S there is no distinction between creation and modification date therefore we always use creation time.