store: custom image size

When pushing a compose to the store an image size can be included in the
parameters.
This commit is contained in:
Jacob Kozol 2019-12-08 14:11:53 +01:00 committed by Tom Gundersen
parent a86e697171
commit e3d64ea1eb
4 changed files with 6 additions and 6 deletions

View file

@ -45,7 +45,7 @@ func TestCreate(t *testing.T) {
store := store.New(nil, distro)
api := jobqueue.New(nil, store)
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test-repo": "test:foo"}, "test_arch", "test_output", nil)
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test-repo": "test:foo"}, "test_arch", "test_output", 0, nil)
if err != nil {
t.Fatalf("error pushing compose: %v", err)
}
@ -61,7 +61,7 @@ func testUpdateTransition(t *testing.T, from, to string, expectedStatus int) {
api := jobqueue.New(nil, store)
if from != "VOID" {
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test": "test:foo"}, "test_arch", "test_output", nil)
err := store.PushCompose(id, &blueprint.Blueprint{}, map[string]string{"test": "test:foo"}, "test_arch", "test_output", 0, nil)
if err != nil {
t.Fatalf("error pushing compose: %v", err)
}

View file

@ -129,7 +129,7 @@ func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ http
// Push the requested compose to the store
composeUUID := uuid.New()
// nil is used as an upload target, because LocalTarget is already used in the PushCompose function
err = api.store.PushCompose(composeUUID, &blueprint.Blueprint{}, make(map[string]string), composeRequest.Architectures[0], composeRequest.ImageTypes[0], nil)
err = api.store.PushCompose(composeUUID, &blueprint.Blueprint{}, make(map[string]string), composeRequest.Architectures[0], composeRequest.ImageTypes[0], 0, nil)
if err != nil {
if api.logger != nil {
api.logger.Println("RCM API failed to push compose:", err)

View file

@ -443,7 +443,7 @@ func (s *Store) GetComposeResult(id uuid.UUID) (io.ReadCloser, error) {
return os.Open(*s.stateDir + "/outputs/" + id.String() + "/result.json")
}
func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checksums map[string]string, arch, composeType string, uploadTarget *target.Target) error {
func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checksums map[string]string, arch, composeType string, size uint64, uploadTarget *target.Target) error {
targets := []*target.Target{}
if s.stateDir != nil {
@ -463,7 +463,7 @@ func (s *Store) PushCompose(composeID uuid.UUID, bp *blueprint.Blueprint, checks
repos = append(repos, source.RepoConfig())
}
pipeline, err := s.distro.Pipeline(bp, repos, checksums, arch, composeType, 0)
pipeline, err := s.distro.Pipeline(bp, repos, checksums, arch, composeType, size)
if err != nil {
return err
}

View file

@ -1257,7 +1257,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
return
}
err = api.store.PushCompose(reply.BuildID, bp, checksums, api.arch, cr.ComposeType, uploadTarget)
err = api.store.PushCompose(reply.BuildID, bp, checksums, api.arch, cr.ComposeType, 0, uploadTarget)
// TODO: we should probably do some kind of blueprint validation in future
// for now, let's just 500 and bail out