Add support for starting a compose upload with the profile
This extends the /compose/ route to support uploading with either an existing profile, or with one-time use settings passed in the POST. To select a profile include the provider and profile, as returned by `/uploads/providers`: "upload": { "image_name": "My Image", "provider": "azure", "profile": "production-azure-settings" }
This commit is contained in:
parent
bc06abceab
commit
5d7aa95f2f
@ -25,6 +25,7 @@ from flask import current_app as api
|
|||||||
|
|
||||||
from lifted.queue import get_upload, reset_upload, cancel_upload, delete_upload
|
from lifted.queue import get_upload, reset_upload, cancel_upload, delete_upload
|
||||||
from lifted.providers import list_providers, resolve_provider, load_profiles, validate_settings, save_settings
|
from lifted.providers import list_providers, resolve_provider, load_profiles, validate_settings, save_settings
|
||||||
|
from lifted.providers import load_settings
|
||||||
from pylorax.api.checkparams import checkparams
|
from pylorax.api.checkparams import checkparams
|
||||||
from pylorax.api.compose import start_build
|
from pylorax.api.compose import start_build
|
||||||
from pylorax.api.errors import BAD_COMPOSE_TYPE, BUILD_FAILED, INVALID_CHARS, MISSING_POST, PROJECTS_ERROR
|
from pylorax.api.errors import BAD_COMPOSE_TYPE, BUILD_FAILED, INVALID_CHARS, MISSING_POST, PROJECTS_ERROR
|
||||||
@ -191,7 +192,23 @@ def v1_compose_start():
|
|||||||
Start a compose. The content type should be 'application/json' and the body of the POST
|
Start a compose. The content type should be 'application/json' and the body of the POST
|
||||||
should look like this. The "upload" object is optional.
|
should look like this. The "upload" object is optional.
|
||||||
|
|
||||||
Example::
|
The upload object can specify either a pre-existing profile to use (as returned by
|
||||||
|
`/uploads/providers` or one-time use settings for the provider.
|
||||||
|
|
||||||
|
Example with upload profile::
|
||||||
|
|
||||||
|
{
|
||||||
|
"blueprint_name": "http-server",
|
||||||
|
"compose_type": "tar",
|
||||||
|
"branch": "master",
|
||||||
|
"upload": {
|
||||||
|
"image_name": "My Image",
|
||||||
|
"provider": "azure",
|
||||||
|
"profile": "production-azure-settings"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Example with upload settings::
|
||||||
|
|
||||||
{
|
{
|
||||||
"blueprint_name": "http-server",
|
"blueprint_name": "http-server",
|
||||||
@ -220,7 +237,7 @@ def v1_compose_start():
|
|||||||
If an "upload" is given, it will schedule an upload to run when the build
|
If an "upload" is given, it will schedule an upload to run when the build
|
||||||
finishes.
|
finishes.
|
||||||
|
|
||||||
Example::
|
Example response::
|
||||||
|
|
||||||
{
|
{
|
||||||
"build_id": "e6fa6db4-9c81-4b70-870f-a697ca405cdf",
|
"build_id": "e6fa6db4-9c81-4b70-870f-a697ca405cdf",
|
||||||
@ -265,8 +282,15 @@ def v1_compose_start():
|
|||||||
if "upload" in compose:
|
if "upload" in compose:
|
||||||
try:
|
try:
|
||||||
image_name = compose["upload"]["image_name"]
|
image_name = compose["upload"]["image_name"]
|
||||||
provider_name = compose["upload"]["provider"]
|
|
||||||
settings = compose["upload"]["settings"]
|
if "profile" in compose["upload"]:
|
||||||
|
# Load a specific profile for this provider
|
||||||
|
profile = compose["upload"]["profile"]
|
||||||
|
provider_name = compose["upload"]["provider"]
|
||||||
|
settings = load_settings(api.config["COMPOSER_CFG"]["upload"], provider_name, profile)
|
||||||
|
else:
|
||||||
|
provider_name = compose["upload"]["provider"]
|
||||||
|
settings = compose["upload"]["settings"]
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
errors.append({"id": UPLOAD_ERROR, "msg": f'Missing parameter {str(e)}!'})
|
errors.append({"id": UPLOAD_ERROR, "msg": f'Missing parameter {str(e)}!'})
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user