Skip to content

Commit

Permalink
✨ : update registry details when module is saved
Browse files Browse the repository at this point in the history
  • Loading branch information
juwit committed May 8, 2022
1 parent 8436476 commit e15dbcd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public TerraformModule saveModule(@PathVariable String id, @RequestBody @Valid T
throw new ModuleForbiddenException();
}

// try to update registry details
moduleService.updateRegistryDetails(module);

module.getModuleMetadata().setUpdatedBy(user);
module.getModuleMetadata().setUpdatedAt(LocalDateTime.now());

Expand All @@ -103,12 +106,6 @@ public TerraformModule refreshModule(@PathVariable String id, User user) {
throw new ModuleForbiddenException();
}

// no registry details found, try to update
if(existingModule.getRegistryDetails() == null){
moduleService.updateRegistryDetails(existingModule);
moduleRepository.save(existingModule);
}

var projectId = existingModule.getRegistryDetails().getProjectId();
var registryType = existingModule.getRegistryDetails().getRegistryType();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.gaia_app.modules.controller;

import io.gaia_app.modules.ModuleService;
import io.gaia_app.modules.repository.TerraformModuleGitRepository;
import io.gaia_app.modules.repository.TerraformModuleRepository;
import io.gaia_app.registries.RegistryDetails;
Expand Down Expand Up @@ -40,6 +41,9 @@ class ModuleRestControllerTest {
@Mock
private RegistryService registryService;

@Mock
private ModuleService moduleService;

private User admin;

private User bob;
Expand Down

0 comments on commit e15dbcd

Please sign in to comment.