-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
support multiple namespaces in one layer #157
Conversation
Signed-off-by: liang chenye <liangchenye@huawei.com>
Hi @jzelinskie @Quentin-M , the PR follows the suggestion from you in #150, PTAL. It makes the following changes:
|
if layer.Namespace != nil { | ||
n, err := pgSQL.insertNamespace(*layer.Namespace) | ||
// Find its parent's namespaces | ||
rows, err := pgSQL.Query(searchLayerNamespace, parentID) |
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 aren't layer.Parent.Namespaces already loaded? We already make the assumption that the provided Parent layer has been retrieved from the database (see L255).
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.
The layer.Parent.Namespaces are loaded in work.go.
But in layer_test, it is not. In FindLayer (around L55), the parent's ID and name are loaded, but parent's namespace is not.
As we already make the assumption that the provided Parent layer has been retrieved.
So either we modify the related test cases or load parent's namespace in FindLayer.
My second commits did the later choice, it is easier for developers who use database interface directly but it will be time consuming.
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.
in new PR, I'll update test cases. So will not reload parent's namespaces.
Signed-off-by: liang chenye <liangchenye@huawei.com>
@@ -35,7 +35,7 @@ type Error struct { | |||
|
|||
type Layer struct { | |||
Name string `json:"Name,omitempty"` | |||
NamespaceName string `json:"NamespaceName,omitempty"` | |||
NamespacesName []string `json:"NamespacesName,omitempty"` |
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.
NamespaceNames
When complete, this change will also need a database migration to move all current installations to the new schema. |
Signed-off-by: liang chenye <liangchenye@huawei.com>
Signed-off-by: liang chenye <liangchenye@huawei.com>
Signed-off-by: liang chenye <liangchenye@huawei.com>
Add 'version' field to I have two questions:
|
Signed-off-by: liang chenye <liangchenye@huawei.com>
This should be rebased now that it cannot be merged anymore and then reviewed again. Master is going to be the branch for "v2" work, we're managing the branches similar to etcd where we have branches for each minor release. The idea behind migrations is to always move forward by adding new files. This includes writing code (not just SQL) to upgrade from the old data schemas. |
Rebased in my branch https://github.com/liangchenye/clair/tree/multiple-detector. I don't know why it becomes an 'unknown' repository. Once the upgrading code was done, I'll add a new PR and close this one. |
Thanks @jzelinskie , some create/alter table work could be done by SQL, but the sequence between SQL and code matters. So now I'm working on adding a pure migration code. |
Hi @jzelinskie , I don't know if you have ever meet the same problem in goose. And another thing is, a user has to have goose lib under his/her GOPATH directory. |
As comment above, .go migration is not well supported by goose. (to my knowledge). |
close and work on #193 |
Hi, Thank you again for your work on this. liamstask/goose is clearly problematic. Issue #93 tracks it. There is a terrible lack of solid solution for database migration in Go. As far as I know, none of them except liamstask/goose support doing migrations using go code and none can do it without having a go env. That is a huge drawback for any Go app that use databases and that can pretend to be ran in production. |
Signed-off-by: liang chenye liangchenye@huawei.com