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

Support tls feature in api version 2021-09-01-preview #3976

Merged
merged 27 commits into from
Oct 26, 2021

Conversation

Descatles
Copy link
Contributor


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.

@@ -102,12 +104,13 @@ def load_command_table(self, _):
g.custom_command('redis update', 'binding_redis_update')
g.custom_show_command('remove', 'binding_remove')

with self.command_group('spring-cloud certificate', client_factory=cf_spring_cloud,
with self.command_group('spring-cloud certificate', client_factory=cf_spring_cloud_20210901preview,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just set the default API version to 2021-09-01-preview?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If not, we would update all clients related with certificate to 2021-09-01-preview one by one.

assign_identity=None,
loaded_public_cert_file=None):

client = get_mgmt_service_client(cmd.cli_ctx, AppPlatformManagementClient_20210901preview)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, change the default client to new API version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For app, maybe change only certificate related to new api version is better

src/spring-cloud/azext_spring_cloud/custom.py Outdated Show resolved Hide resolved
src/spring-cloud/azext_spring_cloud/custom.py Show resolved Hide resolved
src/spring-cloud/azext_spring_cloud/custom.py Outdated Show resolved Hide resolved
src/spring-cloud/azext_spring_cloud/custom.py Outdated Show resolved Hide resolved
certificate_resource = models.CertificateResource(properties=properties)
def certificate_add(cmd, client, resource_group, service, name, only_public_cert=None,
vault_uri=None, vault_certificate_name=None, public_cert_file=None):
if vault_uri is None and public_cert_file is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Move such logic to validators?

Copy link
Contributor Author

@Descatles Descatles Oct 19, 2021

Choose a reason for hiding this comment

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

Seems validator could only validate one parameter? And here we need to validate between parameters

src/spring-cloud/azext_spring_cloud/custom.py Show resolved Hide resolved
if load_certificate.resource_id == certificate_resource_id:
reference_apps.append(app)
break
for app in reference_apps:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add deployment info or not is both ok, I add here because currently app get/list all have deployment information

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 18, 2021

spring cloud

@Descatles Descatles marked this pull request as ready for review October 19, 2021 10:46
@Descatles Descatles changed the title [WIP] Support tls feature in api version 2021-09-01-preview Support tls feature in api version 2021-09-01-preview Oct 19, 2021
Comment on lines 7 to 8
* Application could load public certificate by using argument`--loaded_public_certificate_file` in batch or
directly using `spring-cloud app append-loaded-public-certificate` one by one
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Application could load public certificate by using argument`--loaded_public_certificate_file` in batch or
directly using `spring-cloud app append-loaded-public-certificate` one by one
* Application could load public certificate by using argument `--loaded_public_certificate_file` in batch or
directly using `spring-cloud app append-loaded-public-certificate` one by one

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

Comment on lines 291 to 296
raise CLIError("loadedCertificates must be provided in the json file")
loaded_certificates = []
for item in data['loadedCertificates']:
invalidProperties = not item.get('certificateName') or not item.get('loadTrustStore')
if invalidProperties:
raise CLIError("certificateName, loadTrustStore must be provided in the json file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please use the specific error type from azure.cli.core.azclierror 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

Comment on lines +402 to +408
if not data.get('loadedCertificates'):
raise CLIError("loadedCertificates must be provided in the json file")
loaded_certificates = []
for item in data['loadedCertificates']:
invalidProperties = not item.get('certificateName') or not item.get('loadTrustStore')
if invalidProperties:
raise CLIError("certificateName, loadTrustStore must be provided in the json file")
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please use the specific error type from azure.cli.core.azclierror 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

Comment on lines 658 to 660
raise CLIError(
"To use the log streaming feature, please enable the test endpoint by running 'az spring-cloud test-endpoint enable -n {0} -g {1}'".format(
service, resource_group))
Copy link
Contributor

@zhoxing-ms zhoxing-ms Oct 21, 2021

Choose a reason for hiding this comment

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

Same as above, I won't comment repeatedly for the similar palaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -64,3 +64,36 @@ def test_bind_cert_to_domain(self):

self.cmd('spring-cloud certificate remove --name {cert} -g {rg} -s {serviceName}')
self.cmd('spring-cloud certificate show --name {cert} -g {rg} -s {serviceName}', expect_failure=True)


@record_only()
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask why this test is @record_only()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I don't know its meaning, I add that just because the former test class in this file add that. Is that necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

@zhoxing-ms zhoxing-ms merged commit 101e1f7 into Azure:main Oct 26, 2021
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