-
Notifications
You must be signed in to change notification settings - Fork 514
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
Add a namespace field to tuf metadata storage #1110
Changes from all commits
24f043b
16db507
615a661
7aa289d
1acc425
3da63b1
e407047
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ALTER TABLE `tuf_files` | ||
DROP INDEX `gun`; | ||
|
||
CREATE TABLE `channels` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT, | ||
`name` VARCHAR(255) NOT NULL, | ||
`created_at` timestamp NULL DEFAULT NULL, | ||
`updated_at` timestamp NULL DEFAULT NULL, | ||
`deleted_at` timestamp NULL DEFAULT NULL, | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
INSERT INTO `channels` (id, name) VALUES (1, "published"), (2, "staged"); | ||
|
||
CREATE TABLE `channels_tuf_files` ( | ||
`channel_id` INT(11) NOT NULL, | ||
`tuf_file_id` INT(11) NOT NULL, | ||
FOREIGN KEY (channel_id) REFERENCES channels(`id`) ON DELETE CASCADE, | ||
FOREIGN KEY (tuf_file_id) REFERENCES tuf_files(`id`) ON DELETE CASCADE, | ||
PRIMARY KEY (tuf_file_id, channel_id) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||
|
||
INSERT INTO `channels_tuf_files` (channel_id, tuf_file_id) ( | ||
SELECT 1, `id` FROM `tuf_files` | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ALTER TABLE "tuf_files" DROP CONSTRAINT "tuf_files_gun_role_version_key"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dumb SQL question: Is this constraint automatically created in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, exactly. It's created by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool thanks for explaining! |
||
|
||
CREATE TABLE "channels" ( | ||
"id" serial PRIMARY KEY, | ||
"name" VARCHAR(255) NOT NULL, | ||
"created_at" timestamp NULL DEFAULT NULL, | ||
"updated_at" timestamp NULL DEFAULT NULL, | ||
"deleted_at" timestamp NULL DEFAULT NULL | ||
); | ||
|
||
INSERT INTO "channels" (id, name) VALUES (1, 'published'), (2, 'staged'); | ||
|
||
CREATE TABLE "channels_tuf_files" ( | ||
"channel_id" integer NOT NULL, | ||
"tuf_file_id" integer NOT NULL, | ||
FOREIGN KEY (channel_id) REFERENCES channels("id") ON DELETE CASCADE, | ||
FOREIGN KEY (tuf_file_id) REFERENCES tuf_files("id") ON DELETE CASCADE, | ||
PRIMARY KEY (tuf_file_id, channel_id) | ||
); | ||
|
||
INSERT INTO "channels_tuf_files" (channel_id, tuf_file_id) ( | ||
SELECT 1, "id" FROM "tuf_files" | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,17 +33,17 @@ type MetaStore interface { | |
// GetCurrent returns the modification date and data part of the metadata for | ||
// the latest version of the given GUN and role. If there is no data for | ||
// the given GUN and role, an error is returned. | ||
GetCurrent(gun data.GUN, tufRole data.RoleName) (created *time.Time, data []byte, err error) | ||
GetCurrent(gun data.GUN, tufRole data.RoleName, channels ...*Channel) (created *time.Time, data []byte, err error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current behavior is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh, yeah, this is fine. I had a moment of forgetfulness that a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like in all the implementations, if multiple channels are passed, only the data in the first channel the data is found in is passed (and the channels are checked in order of preference). Should this behavior be documented as a requirement in the interface, and a general test be added (maybe in Similarly for |
||
|
||
// GetChecksum returns the given TUF role file and creation date for the | ||
// GUN with the provided checksum. If the given (gun, role, checksum) are | ||
// not found, it returns storage.ErrNotFound | ||
GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string) (created *time.Time, data []byte, err error) | ||
GetChecksum(gun data.GUN, tufRole data.RoleName, checksum string, channels ...*Channel) (created *time.Time, data []byte, err error) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checksum is sufficiently specific I wonder if it's necessary to also pass a channel? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same checksum can live in multiple channels when staging metadata There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah of course! |
||
|
||
// GetVersion returns the given TUF role file and creation date for the | ||
// GUN with the provided version. If the given (gun, role, version) are | ||
// not found, it returns storage.ErrNotFound | ||
GetVersion(gun data.GUN, tufRole data.RoleName, version int) (created *time.Time, data []byte, err error) | ||
GetVersion(gun data.GUN, tufRole data.RoleName, version int, channels ...*Channel) (created *time.Time, data []byte, err error) | ||
|
||
// Delete removes all metadata for a given GUN. It does not return an | ||
// error if no metadata exists for the given GUN. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package storage | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Check that every provided implementation of a MetaStore actually conforms | ||
func TestImplementationsConform(t *testing.T) { | ||
impls := []MetaStore{&MemStorage{}, &SQLStorage{}, &RethinkDB{}, &TUFMetaStorage{}} | ||
require.NotEmpty(t, impls) | ||
} |
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.
Out of curiosity, does gorm automatically add this to both the mysql and postgres table generation? (didn't see something in the model that corresponded to this directive)
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 don't think so, I didn't use gorm to generate the table or migration