Skip to content

Commit

Permalink
create an AppControlledResource for any cloned databases if needed wh…
Browse files Browse the repository at this point in the history
…en app is updated
  • Loading branch information
cindy-broadinstitute committed Feb 9, 2024
1 parent 3e5c852 commit 6c719bd
Showing 1 changed file with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,33 @@ class AKSInterpreter[F[_]](config: AKSInterpreterConfig,
F.blocking(wsmApi.getAzureManagedIdentity(workspaceId.value, wsmIdentity.resourceId.value))
}

// Create or fetch WSM managed identity if shared app
wsmResourceApi <- buildWsmResourceApiClient
// Call WSM to get the list of databases for the app.
wsmDatabases <- appControlledResourceQuery
.getAllForAppByType(app.id.id, WsmResourceType.AzureDatabase)
.transaction
wsmDatabases <- wsmDatabases.traverse { wsmDatabase =>
F.blocking(wsmApi.getAzureDatabase(workspaceId.value, wsmDatabase.resourceId.value))
.map(db =>
WsmControlledDatabaseResource(db.getMetadata.getName,
db.getAttributes.getDatabaseName,
db.getMetadata.getResourceId
)
)
namespacePrefix = app.appResources.namespace.value
wsmManagedIdentityOpt <- app.samResourceId.resourceType match {
case SamResourceType.SharedApp =>
// if a managed identity has already been created in the workspace use that otherwise create a new managed identity
retrieveWsmManagedIdentity(wsmResourceApi, app.appType, workspaceId.value).flatMap {
case Some(v) => F.pure(Option(v))
case None => createAzureManagedIdentity(app, namespacePrefix, workspaceId)

Check warning on line 366 in http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/util/AKSInterpreter.scala

View check run for this annotation

Codecov / codecov/patch

http/src/main/scala/org/broadinstitute/dsde/workbench/leonardo/util/AKSInterpreter.scala#L364-L366

Added lines #L364 - L366 were not covered by tests
}
case _ => F.pure(None)
}

// Create or fetch WSM databases
wsmDatabases <-
createOrFetchWsmDatabaseResources(
app,
app.appType,
workspaceId,
namespacePrefix,
wsmManagedIdentityOpt.map(_.wsmResourceName),
landingZoneResources,
wsmResourceApi
)

// call WSM resource API to get list of ReferenceDatabases
wsmResourceApi <- buildWsmResourceApiClient
referenceDatabaseNames = app.appType.databases.collect { case ReferenceDatabase(name) => name }.toSet
referenceDatabases <-
if (referenceDatabaseNames.nonEmpty) {
Expand Down

0 comments on commit 6c719bd

Please sign in to comment.