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

add CLI command for git repo deployment #284

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 23 additions & 0 deletions rsconnect/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,29 @@ def task_get(self, task_id, first_status=None):
self._server.handle_bad_response(response)
return response


def deploy_git(self, app_name, repository, branch, subdirectory):
app = self.app_create(app_name)
self._server.handle_bad_response(app)

self.post(
"applications/%s/repo" % app["guid"],
body={
"repository": repository, "branch": branch , "subdirectory": subdirectory
}
)

task = self.post("applications/%s/deploy" % app["guid"], body=dict())
self._server.handle_bad_response(task)

return {
"task_id": task["id"],
"app_id": app["id"],
"app_guid": app["guid"],
"app_url": app["url"],
"title": app["title"],
}

def deploy(self, app_id, app_name, app_title, title_is_default, tarball, env_vars=None):
if app_id is None:
# create an app if id is not provided
Expand Down
51 changes: 50 additions & 1 deletion rsconnect/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,56 @@ def deploy_help():
click.echo()


@deploy.command(
name="git",
short_help="Deploy git repository with exisiting manifest file",
help="Deploy git repository with exisiting manifest file"
)
@click.option("--name", "-n", help="The nickname of the RStudio Connect server to deploy to.")
@click.option(
"--server", "-s", envvar="CONNECT_SERVER", help="The URL for the RStudio Connect server to deploy to.",
)
@click.option(
"--api-key", "-k", envvar="CONNECT_API_KEY", help="The API key to use to authenticate with RStudio Connect.",
)
@click.option(
"--insecure", "-i", envvar="CONNECT_INSECURE", is_flag=True, help="Disable TLS certification/host validation.",
)
@click.option(
"--cacert",
"-c",
envvar="CONNECT_CA_CERTIFICATE",
type=click.File(),
help="The path to trusted TLS CA certificates.",
)
@click.option("--verbose", "-v", is_flag=True, help="Print detailed messages.")
@click.option('--app_name', '-a')
@click.option('--repository', "-r")
@click.option('--branch', "-b")
@click.option('--subdirectory', "-d")
def deploy_git(name, server, api_key, insecure, cacert, verbose, app_name, repository, branch, subdirectory):
set_verbosity(verbose)

with cli_feedback("Checking arguments"):
connect_server = _validate_deploy_to_args(name, server, api_key, insecure, cacert)

connect_client = api.RSConnect(connect_server)

with cli_feedback("Deploying git repository"):
app = connect_client.deploy_git(app_name, repository, branch, subdirectory)

with cli_feedback(""):
click.secho("\nDeployment log:", fg="bright_white")
app_url, _ = spool_deployment_log(connect_server, app, click.echo)
click.secho("Deployment completed successfully.", fg="bright_white")
click.secho(" Dashboard content URL: %s" % app_url, fg="bright_white")
click.secho(" Direct content URL: %s" % app["app_url"], fg="bright_white")


click.secho("Git deployment completed successfully.", fg="bright_white")
click.secho("App available as %s" % app_name, fg="bright_white")


@cli.group(
name="write-manifest",
no_args_is_help=True,
Expand All @@ -1152,7 +1202,6 @@ def deploy_help():
def write_manifest():
pass


@write_manifest.command(
name="notebook",
short_help="Create a manifest.json file for a Jupyter notebook.",
Expand Down