Skip to content

Commit

Permalink
Merge gov cloud with main and resolve conflicts (#3378)
Browse files Browse the repository at this point in the history
* Fix firewall log categories (#3313)

fix firewall log categories

* Add question template (#3327)

* Add question template

* update databricks diagram (#3337)

* RP_BUNDLE multiple values fix (#3343)

* added spacing to join and some test rp_bundle vals to the build to ensure breaks if it needs to

* bumped core v

* rp_bundles to secret

* Fix ENABLE_SWAGGER in CI (#3355)

* change ENABLE_SWAGGER to TF_VAR_enable_swagger, and make it false by default

* update changelog

* Add RP_BUNDLE_VALUES to PR Bot (#3368)

Add RP_BUNDLE_VALUES to pr-bot

* Migration for stepId in OperationSteps (#3358)

* add migration for operationStep

* update PR name

* Add 'availableUpgrades' field to Resources (#3234)

* add availableUpgrades field to resources

* enrich resources with availableUpgrades in endpoints

* rename AvailableUpgrades fields

* fix tests

* fix types

* rename variable

* add tests for enrich_resource_with_available_upgrades

* update api version and changelog

* change structure of resource available upgrades

* Dependabot UI updates (#3370)

* Bump @azure/msal-browser from 2.32.1 to 2.33.0 in /ui/app

Bumps [@azure/msal-browser](https://github.com/AzureAD/microsoft-authentication-library-for-js) from 2.32.1 to 2.33.0.
- [Release notes](https://github.com/AzureAD/microsoft-authentication-library-for-js/releases)
- [Commits](AzureAD/microsoft-authentication-library-for-js@msal-browser-v2.32.1...msal-browser-v2.33.0)

---
updated-dependencies:
- dependency-name: "@azure/msal-browser"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @testing-library/react from 13.4.0 to 14.0.0 in /ui/app

Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 13.4.0 to 14.0.0.
- [Release notes](https://github.com/testing-library/react-testing-library/releases)
- [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
- [Commits](testing-library/react-testing-library@v13.4.0...v14.0.0)

---
updated-dependencies:
- dependency-name: "@testing-library/react"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @fluentui/react from 8.105.1 to 8.106.1 in /ui/app

Bumps [@fluentui/react](https://github.com/microsoft/fluentui) from 8.105.1 to 8.106.1.
- [Release notes](https://github.com/microsoft/fluentui/releases)
- [Changelog](https://github.com/microsoft/fluentui/blob/master/azure-pipelines.release-fluentui.yml)
- [Commits](https://github.com/microsoft/fluentui/compare/@fluentui/react_v8.105.1...@fluentui/react_v8.106.1)

---
updated-dependencies:
- dependency-name: "@fluentui/react"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump @types/node from 18.11.9 to 18.14.2 in /ui/app

Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 18.11.9 to 18.14.2.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Bump webpack from 5.75.0 to 5.76.1 in /ui/app

Bumps [webpack](https://github.com/webpack/webpack) from 5.75.0 to 5.76.1.
- [Release notes](https://github.com/webpack/webpack/releases)
- [Commits](webpack/webpack@v5.75.0...v5.76.1)

---
updated-dependencies:
- dependency-name: webpack
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Adjust versions

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Tamir Kamara <[email protected]>
Co-authored-by: Marcus Robinson <[email protected]>
Co-authored-by: Guy Bertental <[email protected]>
Co-authored-by: David Moore <[email protected]>
Co-authored-by: Yuval Yaron <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
7 people authored Mar 28, 2023
1 parent 3c9bfbc commit 278ff62
Show file tree
Hide file tree
Showing 52 changed files with 340 additions and 193 deletions.
6 changes: 4 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
---
name: 🪲 Bug report
name: "\U0001FAB2 Bug report"
about: Create a report to help us improve
title: ''
labels: 'bug'
labels: bug
assignees: ''

---

Remember to label the issue with the appropriate area, and also assign it to yourself if you plan to work on the issue in the near future.

**Describe the bug**
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'feature'
labels: feature
assignees: ''

---
Expand Down
29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Question
about: Question about your implementation that is not a bug in the project.
title: ''
labels: question
assignees: ''

---

<!--
Note: We cannot provide in depth support for custom code that is not part of the Azure TRE repository.
-->

## Description

In my Azure TRE deployment I am trying to...

## Steps
The steps I have tried are:
1.
2.
3.

## Code
The code I am using is:

```yaml
code here
```
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/user_story.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: User story
about: User story with acceptance criteria
title: ''
labels: 'story'
labels: story
assignees: ''

---
Expand Down
8 changes: 7 additions & 1 deletion .github/actions/devcontainer_run_command/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ inputs:
description: "The number of e2e tests running in parallel"
required: false
default: ""
RP_BUNDLE_VALUES:
description: "JSON string containing key/value pairs to injet into the Resource Processor as ENV vars"
required: false
default: ""

runs:
using: composite
Expand Down Expand Up @@ -194,7 +198,8 @@ runs:
-e TF_VAR_application_admin_client_id="${{ inputs.APPLICATION_ADMIN_CLIENT_ID }}" \
-e TF_VAR_application_admin_client_secret="${{ inputs.APPLICATION_ADMIN_CLIENT_SECRET }}" \
-e TF_VAR_arm_subscription_id="${{ fromJSON(inputs.AZURE_CREDENTIALS).subscriptionId }}" \
-e ENABLE_SWAGGER="${{ inputs.ENABLE_SWAGGER }}" \
-e TF_VAR_enable_swagger="${{ (inputs.ENABLE_SWAGGER != ''
&& inputs.ENABLE_SWAGGER) || 'false' }}" \
-e SWAGGER_UI_CLIENT_ID="${{ inputs.SWAGGER_UI_CLIENT_ID }}" \
-e TF_VAR_swagger_ui_client_id="${{ inputs.SWAGGER_UI_CLIENT_ID }}" \
-e TF_VAR_core_address_space="${{ inputs.core_address_space }}" \
Expand All @@ -218,6 +223,7 @@ runs:
&& inputs.CORE_APP_SERVICE_PLAN_SKU) || 'P1v2' }}" \
-e WORKSPACE_APP_SERVICE_PLAN_SKU="${{ (inputs.WORKSPACE_APP_SERVICE_PLAN_SKU != ''
&& inputs.WORKSPACE_APP_SERVICE_PLAN_SKU) || 'P1v2' }}" \
-e TF_VAR_rp_bundle_values='${{ inputs.RP_BUNDLE_VALUES }}' \
-e TF_VAR_resource_processor_number_processes_per_instance="${{ (inputs.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE != ''
&& inputs.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE) || 5 }}" \
-e E2E_TESTS_NUMBER_PROCESSES="${{ inputs.E2E_TESTS_NUMBER_PROCESSES }}" \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy_tre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ jobs:
CORE_APP_SERVICE_PLAN_SKU: ${{ secrets.CORE_APP_SERVICE_PLAN_SKU }}
WORKSPACE_APP_SERVICE_PLAN_SKU: ${{ secrets.WORKSPACE_APP_SERVICE_PLAN_SKU }}
RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE: ${{ secrets.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE }}
RP_BUNDLE_VALUES: ${{ secrets.RP_BUNDLE_VALUES }}
1 change: 1 addition & 0 deletions .github/workflows/deploy_tre_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@ jobs:
CORE_APP_SERVICE_PLAN_SKU: ${{ secrets.CORE_APP_SERVICE_PLAN_SKU }}
WORKSPACE_APP_SERVICE_PLAN_SKU: ${{ secrets.WORKSPACE_APP_SERVICE_PLAN_SKU }}
RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE: ${{ secrets.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE }}
RP_BUNDLE_VALUES: ${{ secrets.RP_BUNDLE_VALUES }}
4 changes: 4 additions & 0 deletions .github/workflows/deploy_tre_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ on: # yamllint disable-line rule:truthy
RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE:
description: ""
required: false
RP_BUNDLE_VALUES:
description: ""
required: false

# This will prevent multiple runs of this entire workflow.
# We should NOT cancel in progress runs as that can destabilize the environment.
Expand Down Expand Up @@ -384,6 +387,7 @@ jobs:
STATEFUL_RESOURCES_LOCKED: "${{ github.ref == 'refs/heads/main' && inputs.prRef == '' && true || false }}"
CORE_APP_SERVICE_PLAN_SKU: ${{ secrets.CORE_APP_SERVICE_PLAN_SKU }}
RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE: ${{ secrets.RESOURCE_PROCESSOR_NUMBER_PROCESSES_PER_INSTANCE }}
RP_BUNDLE_VALUES: ${{ secrets.RP_BUNDLE_VALUES }}

- name: API Healthcheck
uses: ./.github/actions/devcontainer_run_command
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr_comment_bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ jobs:
TRE_ID: ${{ format('tre{0}', needs.pr_comment.outputs.prRefId) }}
CI_CACHE_ACR_NAME: ${{ secrets.ACR_NAME }}
TF_LOG: ${{ secrets.TF_LOG }}
RP_BUNDLE_VALUES: ${{ secrets.RP_BUNDLE_VALUES }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!-- markdownlint-disable MD041 -->
## 0.10.0 (Unreleased)
**BREAKING CHANGES & MIGRATIONS**:
A migration for OperationSteps in Operation objects was added ([#3358](https://github.com/microsoft/AzureTRE/pull/3358)).

FEATURES:

ENHANCEMENTS:
* Added 'availableUpgrades' field to Resources in GET/GET all Resources endpoints. The field indicates whether there are template versions that a resource can be upgraded to [#3234](https://github.com/microsoft/AzureTRE/pull/3234)

BUG FIXES:
* Fix ENABLE_SWAGGER configuration being ignored in CI ([#3355](https://github.com/microsoft/AzureTRE/pull/3355))

COMPONENTS:

Expand Down
2 changes: 1 addition & 1 deletion api_app/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.13.8"
__version__ = "0.14.1"
4 changes: 4 additions & 0 deletions api_app/api/routes/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ async def migrate_database(resources_repo=Depends(get_repository(ResourceReposit
num_updated = await airlock_migration.update_review_decision_values()
migrations.append(Migration(issueNumber="3152", status=f'Updated {num_updated} airlock requests with new reviewDecision value'))

logging.info("PR 3358 - Migrate OperationSteps of Operations")
num_updated = await resource_migration.migrate_step_id_of_operation_steps(operations_repo)
migrations.append(Migration(issueNumber="3358", status=f'Updated {num_updated} operations'))

return MigrationOutList(migrations=migrations)
except Exception as e:
logging.exception("Failed to migrate database")
Expand Down
21 changes: 20 additions & 1 deletion api_app/api/routes/resource_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import logging
import semantic_version
from copy import deepcopy
from typing import Dict, Any, Optional

Expand All @@ -17,7 +18,7 @@
from db.errors import DuplicateEntity, EntityDoesNotExist
from db.repositories.operations import OperationRepository
from db.repositories.resource_templates import ResourceTemplateRepository
from models.domain.resource import ResourceType, Resource
from models.domain.resource import AvailableUpgrade, ResourceType, Resource
from models.domain.operation import Operation
from resources import strings
from service_bus.resource_request_sender import (
Expand Down Expand Up @@ -311,3 +312,21 @@ async def update_user_resource(
action=RequestAction.Upgrade)

return operation


async def enrich_resource_with_available_upgrades(resource: Resource, resource_template_repo: ResourceTemplateRepository):
available_upgrades = []
resource_version = semantic_version.Version(resource.templateVersion)
all_versions = await resource_template_repo.get_all_template_versions(resource.templateName)

versions_higher_than_current = [version for version in all_versions if semantic_version.Version(version) > resource_version]
major_update_versions = [version for version in versions_higher_than_current if semantic_version.Version(version).major > resource_version.major]
non_major_update_versions = [version for version in versions_higher_than_current if version not in major_update_versions]

for version in sorted(non_major_update_versions, key=semantic_version.Version):
available_upgrades.append(AvailableUpgrade(version=version, forceUpdateRequired=False))

for version in sorted(major_update_versions, key=semantic_version.Version):
available_upgrades.append(AvailableUpgrade(version=version, forceUpdateRequired=True))

resource.availableUpgrades = available_upgrades
9 changes: 6 additions & 3 deletions api_app/api/routes/shared_services.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import logging

from fastapi import APIRouter, Depends, HTTPException, Header, status, Response
Expand All @@ -17,7 +18,7 @@
from resources import strings
from .workspaces import save_and_deploy_resource, construct_location_header
from azure.cosmos.exceptions import CosmosAccessConditionFailedError
from .resource_helpers import send_custom_action_message, send_uninstall_message, send_resource_request_message
from .resource_helpers import enrich_resource_with_available_upgrades, send_custom_action_message, send_uninstall_message, send_resource_request_message
from services.authentication import get_current_admin_user, get_current_tre_user_or_tre_admin
from models.domain.request_action import RequestAction

Expand All @@ -32,13 +33,15 @@ def user_is_tre_admin(user):


@shared_services_router.get("/shared-services", response_model=SharedServicesInList, name=strings.API_GET_ALL_SHARED_SERVICES, dependencies=[Depends(get_current_tre_user_or_tre_admin)])
async def retrieve_shared_services(shared_services_repo=Depends(get_repository(SharedServiceRepository))) -> SharedServicesInList:
async def retrieve_shared_services(shared_services_repo=Depends(get_repository(SharedServiceRepository)), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))) -> SharedServicesInList:
shared_services = await shared_services_repo.get_active_shared_services()
await asyncio.gather(*[enrich_resource_with_available_upgrades(shared_service, resource_template_repo) for shared_service in shared_services])
return SharedServicesInList(sharedServices=shared_services)


@shared_services_router.get("/shared-services/{shared_service_id}", response_model=SharedServiceInResponse, name=strings.API_GET_SHARED_SERVICE_BY_ID, dependencies=[Depends(get_current_tre_user_or_tre_admin), Depends(get_shared_service_by_id_from_path)])
async def retrieve_shared_service_by_id(shared_service=Depends(get_shared_service_by_id_from_path), user=Depends(get_current_tre_user_or_tre_admin)):
async def retrieve_shared_service_by_id(shared_service=Depends(get_shared_service_by_id_from_path), user=Depends(get_current_tre_user_or_tre_admin), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))):
await enrich_resource_with_available_upgrades(shared_service, resource_template_repo)
if user_is_tre_admin(user):
return SharedServiceInResponse(sharedService=shared_service)
else:
Expand Down
23 changes: 17 additions & 6 deletions api_app/api/routes/workspaces.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import logging

from fastapi import APIRouter, Depends, HTTPException, Header, status, Request, Response
Expand Down Expand Up @@ -32,7 +33,7 @@
from services.authentication import extract_auth_information
from services.azure_resource_status import get_azure_resource_status
from azure.cosmos.exceptions import CosmosAccessConditionFailedError
from .resource_helpers import cascaded_update_resource, delete_validation, get_identity_role_assignments, save_and_deploy_resource, construct_location_header, send_uninstall_message, \
from .resource_helpers import cascaded_update_resource, delete_validation, enrich_resource_with_available_upgrades, get_identity_role_assignments, save_and_deploy_resource, construct_location_header, send_uninstall_message, \
send_custom_action_message, send_resource_request_message, update_user_resource
from models.domain.request_action import RequestAction

Expand All @@ -54,11 +55,13 @@ def validate_user_has_valid_role_for_user_resource(user, user_resource):

# WORKSPACE ROUTES
@workspaces_core_router.get("/workspaces", response_model=WorkspacesInList, name=strings.API_GET_ALL_WORKSPACES)
async def retrieve_users_active_workspaces(request: Request, user=Depends(get_current_tre_user_or_tre_admin), workspace_repo=Depends(get_repository(WorkspaceRepository))) -> WorkspacesInList:
async def retrieve_users_active_workspaces(request: Request, user=Depends(get_current_tre_user_or_tre_admin), workspace_repo=Depends(get_repository(WorkspaceRepository)), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))) -> WorkspacesInList:

try:
user = await get_current_admin_user(request)
return WorkspacesInList(workspaces=await workspace_repo.get_active_workspaces())
workspaces = await workspace_repo.get_active_workspaces()
await asyncio.gather(*[enrich_resource_with_available_upgrades(workspace, resource_template_repo) for workspace in workspaces])
return WorkspacesInList(workspaces=workspaces)

except Exception:
workspaces = await workspace_repo.get_active_workspaces()
Expand All @@ -78,7 +81,8 @@ def _safe_get_workspace_role(user, workspace, user_role_assignments):


@workspaces_shared_router.get("/workspaces/{workspace_id}", response_model=WorkspaceInResponse, name=strings.API_GET_WORKSPACE_BY_ID)
async def retrieve_workspace_by_workspace_id(workspace=Depends(get_workspace_by_id_from_path)) -> WorkspaceInResponse:
async def retrieve_workspace_by_workspace_id(workspace=Depends(get_workspace_by_id_from_path), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))) -> WorkspaceInResponse:
await enrich_resource_with_available_upgrades(workspace, resource_template_repo)
return WorkspaceInResponse(workspace=workspace)


Expand Down Expand Up @@ -218,13 +222,15 @@ async def retrieve_workspace_history_by_workspace_id(workspace=Depends(get_works

# WORKSPACE SERVICES ROUTES
@workspace_services_workspace_router.get("/workspaces/{workspace_id}/workspace-services", response_model=WorkspaceServicesInList, name=strings.API_GET_ALL_WORKSPACE_SERVICES, dependencies=[Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager)])
async def retrieve_users_active_workspace_services(workspace=Depends(get_workspace_by_id_from_path), workspace_services_repo=Depends(get_repository(WorkspaceServiceRepository))) -> WorkspaceServicesInList:
async def retrieve_users_active_workspace_services(workspace=Depends(get_workspace_by_id_from_path), workspace_services_repo=Depends(get_repository(WorkspaceServiceRepository)), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))) -> WorkspaceServicesInList:
workspace_services = await workspace_services_repo.get_active_workspace_services_for_workspace(workspace.id)
await asyncio.gather(*[enrich_resource_with_available_upgrades(workspace_service, resource_template_repo) for workspace_service in workspace_services])
return WorkspaceServicesInList(workspaceServices=workspace_services)


@workspace_services_workspace_router.get("/workspaces/{workspace_id}/workspace-services/{service_id}", response_model=WorkspaceServiceInResponse, name=strings.API_GET_WORKSPACE_SERVICE_BY_ID, dependencies=[Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager), Depends(get_workspace_by_id_from_path)])
async def retrieve_workspace_service_by_id(workspace_service=Depends(get_workspace_service_by_id_from_path)) -> WorkspaceServiceInResponse:
async def retrieve_workspace_service_by_id(workspace_service=Depends(get_workspace_service_by_id_from_path), resource_template_repo=Depends(get_repository(ResourceTemplateRepository))) -> WorkspaceServiceInResponse:
await enrich_resource_with_available_upgrades(workspace_service, resource_template_repo)
return WorkspaceServiceInResponse(workspaceService=workspace_service)


Expand Down Expand Up @@ -352,6 +358,7 @@ async def retrieve_user_resources_for_workspace_service(
workspace_id: str,
service_id: str,
user=Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager),
resource_template_repo=Depends(get_repository(ResourceTemplateRepository)),
user_resource_repo=Depends(get_repository(UserResourceRepository))) -> UserResourcesInList:
user_resources = await user_resource_repo.get_user_resources_for_workspace_service(workspace_id, service_id)

Expand All @@ -363,18 +370,22 @@ async def retrieve_user_resources_for_workspace_service(
if 'azure_resource_id' in user_resource.properties:
user_resource.azureStatus = get_azure_resource_status(user_resource.properties['azure_resource_id'])

await asyncio.gather(*[enrich_resource_with_available_upgrades(user_resource, resource_template_repo) for user_resource in user_resources])

return UserResourcesInList(userResources=user_resources)


@user_resources_workspace_router.get("/workspaces/{workspace_id}/workspace-services/{service_id}/user-resources/{resource_id}", response_model=UserResourceInResponse, name=strings.API_GET_USER_RESOURCE, dependencies=[Depends(get_workspace_by_id_from_path)])
async def retrieve_user_resource_by_id(
user_resource=Depends(get_user_resource_by_id_from_path),
resource_template_repo=Depends(get_repository(ResourceTemplateRepository)),
user=Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager)) -> UserResourceInResponse:
validate_user_has_valid_role_for_user_resource(user, user_resource)

if 'azure_resource_id' in user_resource.properties:
user_resource.azureStatus = get_azure_resource_status(user_resource.properties['azure_resource_id'])

await enrich_resource_with_available_upgrades(user_resource, resource_template_repo)
return UserResourceInResponse(userResource=user_resource)


Expand Down
13 changes: 13 additions & 0 deletions api_app/db/migrations/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ async def archive_history(self, resource_history_repository: ResourceHistoryRepo
num_updated = num_updated + 1

return num_updated

async def migrate_step_id_of_operation_steps(self, operations_repository: OperationRepository) -> int:
num_updated = 0
for operation in await operations_repository.query("SELECT * from c WHERE ARRAY_LENGTH(c.steps) > 0 AND IS_DEFINED(c.steps[0].stepId)"):
for operation_step in operation['steps']:
operation_step['templateStepId'] = operation_step['stepId']
operation_step['id'] = str(uuid.uuid4())
del operation_step['stepId']

await operations_repository.update_item_dict(operation)
num_updated = num_updated + 1

return num_updated
6 changes: 6 additions & 0 deletions api_app/db/repositories/resource_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ async def get_template_by_name_and_version(self, name: str, version: str, resour
else:
return parse_obj_as(ResourceTemplate, templates[0])

async def get_all_template_versions(self, template_name: str) -> List[str]:
query = 'SELECT VALUE c.version FROM c where c.name = @template_name'
parameters = [{"name": "@template_name", "value": template_name}]
versions = await self.query(query=query, parameters=parameters)
return versions

async def create_template(self, template_input: ResourceTemplateInCreate, resource_type: ResourceType, parent_service_name: str = "") -> Union[ResourceTemplate, UserResourceTemplate]:
"""
creates a template based on the input (workspace and workspace-services template)
Expand Down
Loading

0 comments on commit 278ff62

Please sign in to comment.