Skip to content

Conversation

@Incarnation-p-lee
Copy link
Contributor

  • Add create, show, set, delete and list for buildpack-binding.
  • Add enable app insights when create Enterprise tier.

Signed-off-by: Pan Li panli@microsoft.com


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

* Add create, show, set, delete and list for buildpack-binding.
* Add enable app insights when create Enterprise tier.

Signed-off-by: Pan Li <panli@microsoft.com>
@Incarnation-p-lee
Copy link
Contributor Author

The test part is under preparing, will be soon.

@yonzhan
Copy link
Collaborator

yonzhan commented Jan 7, 2022

Spring-Cloud

Incarnation-p-lee and others added 7 commits January 7, 2022 10:41
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
namespace.builder_name,
namespace.name)
if binding_resource is not None:
raise CLIError('buildpack Binding {} in builder {} already exists '
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use a specific error type instead of CLIError ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

'You can visit %s/#resource%s/overview to view your '
'Application Insights component', appinsights.name, portal_url, appinsights.id)

return appinsights No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

Please add newline at end of file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

'Format "key[=value]".',
nargs='*',
validator=validate_buildpack_binding_secrets)
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_not_exist)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_not_exist)
c.argument('name', name_type, help='Name for buildpack binding.', validator=validate_buildpack_binding_not_exist)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

'Format "key[=value]".',
nargs='*',
validator=validate_buildpack_binding_secrets)
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)
c.argument('name', name_type, help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

for scope in ['spring-cloud build-service builder buildpack-binding show',
'spring-cloud build-service builder buildpack-binding delete']:
with self.argument_context(scope) as c:
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
c.argument('name', help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)
c.argument('name', name_type, help='Name for buildpack binding.', validator=validate_buildpack_binding_exist)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@wangzelin007 wangzelin007 changed the title [Spring-Cloud] Add buildpack-binding command for Enterprise tier. [Spring Cloud] Add buildpack-binding command for Enterprise tier. Jan 7, 2022
c.argument('app', app_name_type, help='Name of app.', validator=validate_app_name)

with self.argument_context('spring-cloud service-registry unbind') as c:
c.argument('app', app_name_type, help='Name of app.', validator=validate_app_name)
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate with line 437, please delete line 429-433


for scope in ['spring-cloud build-service builder buildpack-binding show',
'spring-cloud build-service builder buildpack-binding delete']:
with self.argument_context(scope) as c:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
with self.argument_context(scope) as c:
for scope in ['show', 'delete']:
with self.argument_context('spring-cloud build-service builder buildpack-binding {}'.format(scope)) as c:

c.argument('service', service_name_type, validator=only_support_enterprise)


for scope in ['spring-cloud build-service builder buildpack-binding set']:
Copy link
Member

@wangzelin007 wangzelin007 Jan 7, 2022

Choose a reason for hiding this comment

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

It's better to merge spring-cloud build-service builder buildpack-binding create with set except the argument name.
Otherwise we don't need to use scope here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One question, is this the convention to merge such kinds of statements? If so, I can align this.
As a beginner to CLI, I intended to write parms like this, because it is clean when I look into one command for parameters. I can have a full picture of all parameters of one command.
Compare to merging, I may need to combine these in my mind for full picture.

Could you please help to enlighten me what is the best practice here?

Copy link
Member

Choose a reason for hiding this comment

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

Hi Li,
We highly recommend merging, because after merging, the similarities and differences can be more clearly distinguished.
If you modify it later,it is not easy to miss anything after merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, updated.

@Incarnation-p-lee
Copy link
Contributor Author

#4294

Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
@Incarnation-p-lee
Copy link
Contributor Author

@wangzelin007 test added.

Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Comment on lines 895 to 901
helps['spring-cloud build-service builder buildpack-binding list'] = """
type: command
short-summary: (Support Enterprise Tier Only) List all buildpack binding in a builder. The secrets will be masked.
examples:
- name: Show a buildpack binding.
text: az spring-cloud build-service builder buildpack-binding list --builder-name first-builder --service MyCluster --resource-group MyResourceGroup
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

name: Show a buildpack binding.

Why is the description here Show rather than list?

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, thank you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.


from azure.cli.core.commands.validators import validate_tag
from azure.core.exceptions import ResourceNotFoundError
from azure.cli.core.util import CLIError
Copy link
Contributor

@zhoxing-ms zhoxing-ms Jan 10, 2022

Choose a reason for hiding this comment

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

from azure.cli.core.util import CLIError

Please remove the useless import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@zhoxing-ms
Copy link
Contributor

@Incarnation-p-lee Could you please fix the CI issues?

Signed-off-by: Pan Li <panli@microsoft.com>
@Incarnation-p-lee
Copy link
Contributor Author

@zhoxing-ms Sure, will be soon.

g.custom_command('set', 'create_or_update_buildpack_binding')
g.custom_show_command('show', 'buildpack_binding_show')
g.custom_command('list', 'buildpack_binding_list')
g.custom_command('delete', 'buildpack_binding_delete')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need consider adding confirmation=True for the delete command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense, let me update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
Signed-off-by: Pan Li <panli@microsoft.com>
])

results = self.cmd('spring-cloud build-service builder buildpack-binding list -g {rg} -s {serviceName}').get_output_in_json()
self.assertEqual(2, len(results)) No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

Please add newline at end of file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

Signed-off-by: Pan Li <panli@microsoft.com>
@zhoxing-ms zhoxing-ms merged commit f549964 into Azure:main Jan 11, 2022
@Incarnation-p-lee Incarnation-p-lee deleted the panli/add-buildpack-binding-command-for-enterprise branch January 12, 2022 05:28
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