Skip to content

Commit

Permalink
[STREAM-227] Modify deploy command
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebowczyk92 committed Oct 26, 2021
1 parent aa9b992 commit aefa7a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ project/run:
cd tmp_project; docker run tmp_project

project/deploy:
cd tmp_project; pipenv run scli project deploy --profile local --docker-image-tag tmp_project:v1.1.22
pipenv run scli project deploy --profile local --docker-image-tag local --docker-image-repository tmp_project

project/deploy/overrides:
cd tmp_project; pipenv run scli project deploy --profile local --docker-image-tag tmp_project:v1.1.22 --overrides_from_yaml=./deployment_prod.yml
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ scli project deploy \
--vvp-namespace "default" \
--vvp-api-token "x§11d091jd1jd9jasd0j" \
--vvp-deployment-target "vvp-team1" \
--docker-registry-url "${CI_REGISTRY_IMAGE}" \
--docker_image_registry "${CI_REGISTRY_IMAGE}" \
--docker-image-tag "${CI_COMMIT_TAG}" \
--docker-image-repository tmp_project \
--profile "sandbox"
```
> Parameters `--vvp-url`, `--vvp-namespace`, `--vvp-api-token`, `--vvp-deployment-target` are optional if they can be read from profile.
Expand Down
17 changes: 11 additions & 6 deletions streamingcli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ def project_init(project_name: str):


@project.command()
@click.argument('docker-image-tag')
@click.option('--docker-image-tag',
help='Docker image tag', default = 'latest')
@click.option('--docker-image-registry', 'docker_image_registry',
help='URL for Docker registry, i.e: "https://hub.docker.com/"')
@click.option('--docker-image-repository', 'docker_image_repository',
help='Docker image repository')
@click.option('--profile',
help='Profile name to use')
@click.option('--vvp-url', 'ververica_url',
Expand All @@ -54,31 +59,31 @@ def project_init(project_name: str):
help='Ververica deployment target name')
@click.option('--token', 'ververica_webtoken_secret',
help='Ververica WebToken secret to make API calls')
@click.option('--docker-registry-url', 'docker_registry_url',
help='URL for Docker registry, i.e: "https://hub.docker.com/"')
@click.option('--overrides-from-yaml',
help='Path to additional deployment YAML file to merge with Ververica one')
def project_deploy(docker_image_tag: str,
docker_image_registry: str = None,
docker_image_repository: str = None,
profile: str = None,
ververica_url: str = None,
ververica_namespace: str = None,
ververica_deployment_target_name: str = None,
ververica_webtoken_secret: str = None,
docker_registry_url: str = None,
overrides_from_yaml: str = None):
ProjectDeployer.deploy_project(docker_image_tag=docker_image_tag,
docker_registry_url=docker_image_registry,
docker_image_repository=docker_image_repository,
profile=profile,
ververica_url=ververica_url,
ververica_namespace=ververica_namespace,
ververica_deployment_target_name=ververica_deployment_target_name,
ververica_webtoken_secret=ververica_webtoken_secret,
docker_registry_url=docker_registry_url,
overrides_from_yaml=overrides_from_yaml)


@project.command()
@click.option('--docker-image-tag',
help='Project image tag')
help='Project image tag', default= 'latest')
def project_build(docker_image_tag: str = None):
ProjectBuilder.build_project(docker_image_tag)

Expand Down
4 changes: 2 additions & 2 deletions streamingcli/project/build_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

class ProjectBuilder:
@staticmethod
def build_project(tag_name:str = None):
def build_project(tag_name: str):
# Load local project config
local_project_config = LocalProjectConfigIO.load_project_config()

image_tag = f"{local_project_config.project_name}:{tag_name if tag_name is not None else 'latest'}"
image_tag = f"{local_project_config.project_name}:{tag_name}"
click.echo(f"Building Docker image {image_tag} ...")

client = docker.from_env()
Expand Down
16 changes: 7 additions & 9 deletions streamingcli/project/deploy_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@ def get_profile_name(profile_name: Optional[str]) -> Optional[str]:

@staticmethod
def deploy_project(docker_image_tag: str,
docker_registry_url: Optional[str] = None,
docker_image_repository: Optional[str] = None,
profile: Optional[str] = None,
ververica_url: Optional[str] = None,
ververica_namespace: Optional[str] = None,
ververica_deployment_target_name: Optional[str] = None,
ververica_webtoken_secret: Optional[str] = None,
docker_registry_url: Optional[str] = None,
overrides_from_yaml: Optional[str] = None):

local_project_config = LocalProjectConfigIO.load_project_config()

profile_name = ProjectDeployer.get_profile_name(profile_name=profile)

if profile_name is not None:
profile_data = ProfileAdapter.get_profile(profile_name=profile_name)
else:
profile_data = ScliProfile(profile_name="temporary")
profile_data = (ProfileAdapter.get_profile(profile_name=profile_name)
or ScliProfile(profile_name="temporary"))

project_name = docker_image_repository or LocalProjectConfigIO.load_project_config().project_name
profile_data = ProfileAdapter.update_profile_data(
profile_data=profile_data,
ververica_url=ververica_url,
Expand All @@ -51,14 +49,14 @@ def deploy_project(docker_image_tag: str,

# Generate deployment YAML
deployment_yml = ProjectDeployer.generate_project_template(
project_name=local_project_config.project_name,
project_name=project_name,
docker_registry_url=profile_data.docker_registry_url,
docker_image_tag=docker_image_tag,
deployment_target_name=profile_data.ververica_deployment_target
)
if overrides_from_yaml:
deployment_yml = YamlMerger.merge_two_yaml(deployment_yml, overrides_from_yaml)
click.echo(f"Deploying streaming project: {local_project_config.project_name} ...")
click.echo(f"Deploying streaming project: {project_name} ...")

deployment_name = DeploymentAdapter.deploy(
deployment_yml=deployment_yml,
Expand Down

0 comments on commit aefa7a4

Please sign in to comment.