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

Conditional Templates #2795

Closed
wants to merge 14 commits into from
Closed

Conditional Templates #2795

wants to merge 14 commits into from

Conversation

damoodamoo
Copy link
Member

@damoodamoo damoodamoo commented Oct 27, 2022

Resolves #2741

  • Implements the allOf feature of JSON schema to allow conditional fields + conditional schema validation
  • "auto_create" string has gone in favour of an enum (dropdown), which shows appropriate follow-up fields
  • all workspace templates updated to use conditional schema to streamline the form
  • Airlock review VM configuration - nested properties, conditionally required
  • UI code to massage the data payload sent in for create or update of a resource.

image

@github-actions
Copy link

github-actions bot commented Oct 27, 2022

Unit Test Results

517 tests   517 ✔️  13s ⏱️
    1 suites      0 💤
    1 files        0

Results for commit e96af7c.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@tanya-borisova tanya-borisova left a comment

Choose a reason for hiding this comment

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

I think this PR lends itself naturally to being split into several smaller PRs:

  • Increasing the number of processes in resource processor (AFAIU it is not related to this pull request?)
  • Endpoints for getting a template with a specific version
  • Adding support for AllOf in the templates including the changes on UI necessary
  • Replacing auto_create with Automatic and manual auth_type (am I right that it is just refactoring and does not depend on the rest of the PR?)
  • Finally, changing the workspace templates to take advantage of the introduced AllOf feature for Airlock configuration

As it stands, I would be reluctant to approve this PR as there are too many changes. It is likely that I and other reviewers will miss something while reviewing.
It would also be good to call out these changes as separate items in CHANGELOG.

@@ -130,13 +130,15 @@ async def create_review_user_resource(
# Getting the review configuration from the airlock request's workspace properties
if airlock_request.type == AirlockRequestType.Import:
config = workspace.properties["airlock_review_config"]["import"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this line still?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep - as mentioned below, the structure is still:

properties: {
   ... 
   {
      "airlock_review_config": { 
          "import": {
              ...
          }, "export": { } 
   }
}

workspace_id = config["workspace_id"]
workspace_id = config["import_vm_workspace_id"]
workspace_service_id = config["import_vm_workspace_service_id"]
user_resource_template_name = config["import_vm_user_resource_template_name"]
else:
assert airlock_request.type == AirlockRequestType.Export
config = workspace.properties["airlock_review_config"]["export"]
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, do you need this line? AFAIU there won't be a field name "export" anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

the nested structure is still there, so there are parent objects for import and export still.

@@ -36,8 +36,11 @@
core_router.include_router(health.router, tags=["health"])
core_router.include_router(ping.router, tags=["health"])
core_router.include_router(workspace_templates.workspace_templates_admin_router, tags=["workspace templates"])
core_router.include_router(workspace_service_templates.workspace_service_templates_core_router, tags=["workspace service templates"])

# NOTE: User Resource Templates need to be registered before workspace service templates to cater for the `/{service_template_name}/user-resources`
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment makes sense in the context of this PR I'm looking at, but I think it will make less sense when people just see it in the code. Maybe reword to something like this:

NOTE: User Resource Templates need to be registered before Workspace Service templates, as some user resource endpoints depend on workspace service endpoints.

api_app/api/routes/shared_service_templates.py Outdated Show resolved Hide resolved
templates/core/terraform/variables.tf Outdated Show resolved Hide resolved
@damoodamoo
Copy link
Member Author

/test-extended

@github-actions
Copy link

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/3364875169 (with refid 3b8e3eae)

(in response to this comment from @damoodamoo)

@damoodamoo
Copy link
Member Author

/test-destroy-env

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Destroying PR test environment (RG: rg-tre3b8e3eae)... (run: https://github.com/microsoft/AzureTRE/actions/runs/3369145827)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Destroying branch test environment (RG: rg-treda8868a4)... (run: https://github.com/microsoft/AzureTRE/actions/runs/3369145827)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Branch test environment destroy complete (RG: rg-treda8868a4)

@damoodamoo
Copy link
Member Author

/test-extended

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/3369186464 (with refid 3b8e3eae)

(in response to this comment from @damoodamoo)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

PR test environment destroy complete (RG: rg-tre3b8e3eae)

@damoodamoo
Copy link
Member Author

/test-destroy-env

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Destroying PR test environment (RG: rg-tre3b8e3eae)... (run: https://github.com/microsoft/AzureTRE/actions/runs/3369263912)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

PR test environment destroy complete (RG: rg-tre3b8e3eae)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Destroying branch test environment (RG: rg-treda8868a4)... (run: https://github.com/microsoft/AzureTRE/actions/runs/3369263912)

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

Branch test environment destroy complete (RG: rg-treda8868a4)

@damoodamoo
Copy link
Member Author

/test-extended

@github-actions
Copy link

github-actions bot commented Nov 1, 2022

🤖 pr-bot 🤖

🏃 Running extended tests: https://github.com/microsoft/AzureTRE/actions/runs/3369300342 (with refid 3b8e3eae)

(in response to this comment from @damoodamoo)

@damoodamoo
Copy link
Member Author

Closing as env is messed up. Creating new.

@damoodamoo damoodamoo closed this Nov 1, 2022
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.

Enable optional fields to show/hide in UI
2 participants