Search in sources :

Example 1 with GitRepoResource

use of bio.terra.workspace.model.GitRepoResource in project terra-workspace-manager by DataBiosphere.

the class ReferencedGitRepoLifecycle method testUpdateReference.

private void testUpdateReference(ReferencedGcpResourceApi referencedGcpResourceApi) throws Exception {
    String newGitRepoReferenceName = "newGitRepoReferenceName";
    String newGitRepoReferenceDescription = "a new description for git repo reference";
    GitRepoUtils.updateGitRepoReferenceResource(referencedGcpResourceApi, getWorkspaceId(), gitResourceId, newGitRepoReferenceName, newGitRepoReferenceDescription, /*gitCloneUrl=*/
    null);
    GitRepoResource updatedResource = referencedGcpResourceApi.getGitRepoReference(getWorkspaceId(), gitResourceId);
    assertEquals(newGitRepoReferenceName, updatedResource.getMetadata().getName());
    assertEquals(newGitRepoReferenceDescription, updatedResource.getMetadata().getDescription());
}
Also used : GitRepoResource(bio.terra.workspace.model.GitRepoResource)

Example 2 with GitRepoResource

use of bio.terra.workspace.model.GitRepoResource in project terra-workspace-manager by DataBiosphere.

the class ReferencedGitRepoLifecycle method testGetReference.

private void testGetReference(GitRepoResource gitResource, ReferencedGcpResourceApi referencedGcpResourceApi, ResourceApi resourceApi) throws Exception {
    GitRepoResource fetchedGitResource = referencedGcpResourceApi.getGitRepoReference(getWorkspaceId(), gitResourceId);
    assertEquals(gitResource, fetchedGitResource);
    // Enumerate the reference
    ResourceList referenceList = resourceApi.enumerateResources(getWorkspaceId(), 0, 5, /*referenceType=*/
    null, /*stewardShipType=*/
    null);
    assertEquals(1, referenceList.getResources().size());
    assertEquals(StewardshipType.REFERENCED, referenceList.getResources().get(0).getMetadata().getStewardshipType());
    assertEquals(ResourceType.GIT_REPO, referenceList.getResources().get(0).getMetadata().getResourceType());
}
Also used : ResourceList(bio.terra.workspace.model.ResourceList) GitRepoResource(bio.terra.workspace.model.GitRepoResource)

Example 3 with GitRepoResource

use of bio.terra.workspace.model.GitRepoResource in project terra-workspace-manager by DataBiosphere.

the class ReferencedGitRepoLifecycle method doUserJourney.

@Override
protected void doUserJourney(TestUserSpecification testUser, WorkspaceApi workspaceApi) throws Exception {
    ReferencedGcpResourceApi referencedGcpResourceApi = ClientTestUtils.getReferencedGcpResourceClient(testUser, server);
    // Create the reference
    GitRepoResource gitResource = GitRepoUtils.makeGitRepoReference(gitRepoAttributes, referencedGcpResourceApi, getWorkspaceId(), MultiResourcesUtils.makeName());
    gitResourceId = gitResource.getMetadata().getResourceId();
    // Read the reference
    ResourceApi resourceApi = ClientTestUtils.getResourceClient(testUser, server);
    testGetReference(gitResource, referencedGcpResourceApi, resourceApi);
    // Clone the reference
    testCloneReference(gitResource, referencedGcpResourceApi, workspaceApi);
    // No validation checks yet, we don't validate access to git repos.
    // Update the reference
    testUpdateReference(referencedGcpResourceApi);
    // Delete the reference
    referencedGcpResourceApi.deleteGitRepoReference(getWorkspaceId(), gitResourceId);
    // Enumerating all resources with no filters should be empty
    ResourceList enumerateResult = resourceApi.enumerateResources(getWorkspaceId(), 0, 100, null, null);
    assertTrue(enumerateResult.getResources().isEmpty());
}
Also used : ReferencedGcpResourceApi(bio.terra.workspace.api.ReferencedGcpResourceApi) ResourceApi(bio.terra.workspace.api.ResourceApi) ResourceList(bio.terra.workspace.model.ResourceList) GitRepoResource(bio.terra.workspace.model.GitRepoResource) ReferencedGcpResourceApi(bio.terra.workspace.api.ReferencedGcpResourceApi)

Example 4 with GitRepoResource

use of bio.terra.workspace.model.GitRepoResource in project terra-cli by DataBiosphere.

the class GitRepo method addReferenced.

/**
 * Add a git repo as a referenced resource in the workspace.
 *
 * @return the resource that was added
 */
public static GitRepo addReferenced(AddGitRepoParams addGitRepoParams) {
    validateEnvironmentVariableName(addGitRepoParams.resourceFields.name);
    // call WSM to add the reference.
    GitRepoResource addedResource = WorkspaceManagerService.fromContext().createReferencedGitRepo(Context.requireWorkspace().getId(), addGitRepoParams);
    logger.info("Created Git repo reference: {}", addedResource);
    // convert the WSM object to a CLI object
    Context.requireWorkspace().listResourcesAndSync();
    return new GitRepo(addedResource);
}
Also used : GitRepoResource(bio.terra.workspace.model.GitRepoResource) UFGitRepo(bio.terra.cli.serialization.userfacing.resource.UFGitRepo) PDGitRepo(bio.terra.cli.serialization.persisted.resource.PDGitRepo)

Aggregations

GitRepoResource (bio.terra.workspace.model.GitRepoResource)4 ResourceList (bio.terra.workspace.model.ResourceList)2 PDGitRepo (bio.terra.cli.serialization.persisted.resource.PDGitRepo)1 UFGitRepo (bio.terra.cli.serialization.userfacing.resource.UFGitRepo)1 ReferencedGcpResourceApi (bio.terra.workspace.api.ReferencedGcpResourceApi)1 ResourceApi (bio.terra.workspace.api.ResourceApi)1