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

botservice cli extension #155

Merged
merged 17 commits into from
May 3, 2018
Merged

botservice cli extension #155

merged 17 commits into from
May 3, 2018

Conversation

swagatmishra2007
Copy link
Contributor

this changelist contains the following changes -

  1. Bot service python sdk generated from swagger
  2. Botservice cli function code.

@azuresdkci
Copy link

If this PR is for a new extension or change to an existing extension, use the following to try out the changes in this PR:

docker run -it microsoft/azure-cli:latest
export EXT=<NAME>
pip install --upgrade --target ~/.azure/cliextensions/$EXT "git+https://github.com/swagatmishra2007/azure-cli-extensions.git@master#subdirectory=src/$EXT&egg=$EXT"

@@ -0,0 +1,478 @@
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this file need to be checked-in to the repo?
What's it for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it doesn't . i will add my .vscode folder to gitignore so that this doesnt get in by mistake


from azure.cli.core import AzCommandsLoader
from azext_bot._help import helps #pylint: disable=unused-import
import pdb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a debug import that should be removed.

examples:
- name: Update description on a bot
text: |-
az bot update -n botname -g resource_group_name --set properties.description="some description"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer MyResourceGroup over resource_group_name

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same elsewhere.


if not msa_app_id:
msa_app_id, password = provisionConvergedApp(resource_name)
print('obtained msa app id and password. Provisioning bot now.')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use logger.warning instead of print.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

from azext_bot.botservice import AzureBotService
from azext_bot.botservice.models import Bot, BotProperties,sku, BotChannel
from azure.cli.command_modules.appservice.custom import enable_zip_deploy, config_source_control, get_app_settings, _get_site_credential, _get_scm_url
from azure.cli.command_modules.resource.custom import deploy_arm_template
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on other command modules like this is potentially brittle.
The command modules you import have no idea you're using them in this way so this could break the extension in the future.

It's okay to leave it as is since you mentioned you plan to move in to the CLI so it will be less of an issue then but still not recommended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is true. longterm, should i talk to the other cli module teams to make sure that they continue to support these functions?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, your extension/module should not rely on other modules so you shouldn't have these imports at all. You can either copy the functionality into your module or we could move them into the core so that a common implementation is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either of the 2 funcitonalities are acceptable to me. i am thinking of making the changes in another PR though since i dont want to break anything this close to build conference. Is it ok to get this checked in and onto the index.json and then taking the dependency off (by copying the code over)?

deploy_result = deploy_arm_template(
cmd = cmd,
resource_group_name = resource_group_name,
template_file = '{0}\\{1}'.format(dir_path, template_name),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work on Linux/macOS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to use os.path.join instead of string concatenation. That will make it os independent.


#since there is no git url it's definitely publish from local
if not code_dir:
import os
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can really just import os at the very top of the file instead of importing it so many times.
Same with other standard python imports such as shutil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch! thanks. .updated the code to move os, shutil and json imports to the top of the file

HISTORY = f.read()

setup(
name='azurebotextension',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change name of extension.
e.g. to just botservice since that's the name of the directory in this PR.
Then user would install with az extension add -n botservice

@derekbekoe
Copy link
Member

@swagatmishra2007 Thanks for the changes. Please take a look at the CI failure for style.

@derekbekoe
Copy link
Member

@tjprescott Does it look good to you?

Copy link
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@tjprescott tjprescott merged commit 3b810b4 into Azure:master May 3, 2018
runefa pushed a commit to runefa/azure-cli-extensions that referenced this pull request Sep 23, 2022
Migrating containerapp-compose into containerapp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants