Skip to content
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(kpack): add a parameter '--builder' when deploy app #31

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/spring-cloud/azext_spring_cloud/_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def app_update_enterprise(cmd, client, resource_group, service, name,


def app_deploy_enterprise(cmd, client, resource_group, service, name,
version, deployment, artifact_path, target_module, jvm_options,
version, deployment, artifact_path, builder, target_module, jvm_options,
env, config_file_patterns, no_wait):
'''app_deploy_enterprise
Deploy artifact to deployment under the existing app.
Expand All @@ -122,7 +122,7 @@ def app_deploy_enterprise(cmd, client, resource_group, service, name,
deployment = _deployment_or_active_deployment_name(client, resource_group, service, name, deployment)

deployment_settings = _format_deployment_settings(jvm_options=jvm_options, env=env, config_file_patterns=config_file_patterns)
user_source_info = _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, target_module, additional_steps=1)
user_source_info = _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, builder, target_module, additional_steps=1)
logger.warning("[5/5] Deploying the built docker image to deployment {} under app {}".format(deployment, name))
resource = models.DeploymentResource(
properties=models.DeploymentResourceProperties(
Expand Down Expand Up @@ -196,6 +196,7 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name
skip_clone_settings=False,
version=None,
artifact_path=None,
builder=None,
target_module=None,
jvm_options=None,
cpu=None,
Expand All @@ -213,7 +214,7 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name
jvm_options=jvm_options,
env=env or origin_settings.environment_variables,
config_file_patterns=config_file_patterns or _get_config_file_patterns(origin_settings.addon_configs))
user_source_info = _build_and_get_result(cmd, client, resource_group, service, app, version, artifact_path, target_module, additional_steps=1)
user_source_info = _build_and_get_result(cmd, client, resource_group, service, app, version, builder, artifact_path, target_module, additional_steps=1)
resource = models.DeploymentResource(
properties=models.DeploymentResourceProperties(
source=user_source_info,
Expand All @@ -226,14 +227,14 @@ def deployment_create_enterprise(cmd, client, resource_group, service, app, name
resource_group, service, app, name, resource)


def _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, target_module, additional_steps=0):
def _build_and_get_result(cmd, client, resource_group, service, name, version, artifact_path, builder, target_module, additional_steps=0):
total_steps = 4 + additional_steps
logger.warning("[1/{}] Requesting for upload URL.".format(total_steps))
upload_url, relative_path = _request_upload_url(client, resource_group, service, name)
logger.warning("[2/{}] Uploading package to blob.".format(total_steps))
_compress_and_upload(cmd, client, upload_url, artifact_path)
logger.warning("[3/{}] Creating or Updating build '{}'.".format(total_steps, name))
build_result_id = _queue_build(client, resource_group, service, name, relative_path, target_module)
build_result_id = _queue_build(client, resource_group, service, name, relative_path, builder, target_module)
logger.warning("[4/{}] Waiting for building docker image to finish. This may take a few minutes.".format(total_steps))
_wait_build_finished(cmd, client, service, build_result_id)
return models.BuildResultUserSourceInfo(version=version, build_result_id=build_result_id)
Expand Down Expand Up @@ -304,9 +305,9 @@ def _is_build_result_still_building(build_result):
return build_result.properties.status == "Building" or build_result.properties.status == "Queuing"


def _queue_build(client, resource_group, service, name, relative_path, target_module=None):
def _queue_build(client, resource_group, service, name, relative_path, builder=None, target_module=None):
properties = models.BuildProperties(
builder="default-enterprise-builder",
builder= builder,
relative_path=relative_path,
env={"BP_MAVEN_BUILT_MODULE": target_module} if target_module else None)
build = models.Build(properties=properties)
Expand Down
2 changes: 2 additions & 0 deletions src/spring-cloud/azext_spring_cloud/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def prepare_logs_argument(c):
c.argument(
'main_entry', options_list=[
'--main-entry', '-m'], help="A string containing the path to the .NET executable relative to zip root.")
c.argument(
'builder', help="The name of builder.", default="default")
c.argument(
'target_module', help='Child module to be deployed, required for multiple jar packages built from source code.')
c.argument(
Expand Down
3 changes: 2 additions & 1 deletion src/spring-cloud/azext_spring_cloud/tier_routing_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def app_deploy(cmd, client, resource_group, service, name,
version=None,
deployment=None,
artifact_path=None,
builder=None,
target_module=None,
runtime_version=None,
jvm_options=None,
Expand All @@ -154,7 +155,7 @@ def app_deploy(cmd, client, resource_group, service, name,
if is_enterprise_tier(cmd, resource_group, service):
# runtime_version, assign_ideneity, main_entry not support
return app_deploy_enterprise(cmd, get_client(cmd), resource_group, service, name,
version, deployment, artifact_path, target_module,
version, deployment, artifact_path, builder, target_module,
jvm_options, env, config_file_patterns, no_wait)
else:
# config_file_patterns not support
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def deployment_create(cmd, client, resource_group, service, app, name,
skip_clone_settings=False,
version=None,
artifact_path=None,
builder=None,
target_module=None,
runtime_version=None,
jvm_options=None,
Expand All @@ -50,7 +51,7 @@ def deployment_create(cmd, client, resource_group, service, app, name,
no_wait=False):
if is_enterprise_tier(cmd, resource_group, service):
return deployment_create_enterprise(cmd, get_client(cmd), resource_group, service, app, name,
skip_clone_settings, version, artifact_path, target_module,
skip_clone_settings, version, artifact_path, builder, target_module,
jvm_options, cpu, memory, instance_count, env, config_file_patterns, no_wait)
else:
return deployment_create_standard(cmd, client, resource_group, service, app, name,
Expand Down