public async Task HandleAsync(CapabilityRegisteredEvent capabilityRegisteredEvent) { var capabilityName = capabilityRegisteredEvent.CapabilityName.ToLower(); var configmapRoleName = capabilityName; await _configMapService.AddRole( roleName : configmapRoleName, roleArn : capabilityRegisteredEvent.RoleArn ); var namespaceName = capabilityName; await _namespaceRepository.CreateNamespace( namespaceName : namespaceName, roleName : configmapRoleName ); var namespaceRoleName = await _roleRepository .CreateNamespaceFullAccessRole(namespaceName); await _roleBindingRepository.BindNamespaceRoleToGroup( namespaceName : namespaceName, role : namespaceRoleName, group : capabilityName ); }
public async Task <ActionResult <string> > AddRole([FromBody] AddRoleRequest addRoleRequest) { if (!_addRoleRequestValidator.TryValidateAddRoleRequest(addRoleRequest, out string validationError)) { Log.Warning($"Create role called with invalid input. Validation error: {validationError}"); return(BadRequest(validationError)); } var updatedMapRolesYaml = string.Empty; try { await _configMapService.AddRole( addRoleRequest.RoleName, addRoleRequest.RoleArn ); } catch (Exception ex) { Log.Error($"An error occured trying to create the role mapping: {ex.Message}"); return(StatusCode(StatusCodes.Status500InternalServerError, $"An error occured trying to create the role mapping: {ex.Message}")); } return(Ok(updatedMapRolesYaml)); }
public async Task HandleAsync(CapabilityRegisteredDomainEvent capabilityRegisteredDomainEvent) { _logger.LogWarning($"Handling deprecated CapabilityRegisteredDomainEvent for capability {capabilityRegisteredDomainEvent.Payload.CapabilityName}"); var capabilityName = capabilityRegisteredDomainEvent.Payload.CapabilityName.ToLower(); var configmapRoleName = capabilityName; await _configMapService.AddRole( roleName : configmapRoleName, roleArn : capabilityRegisteredDomainEvent.Payload.RoleArn ); var namespaceName = capabilityName; _logger.LogWarning($"Creating namespace with default role permisison (AccountId: 000000000000)"); await _namespaceRepository.CreateNamespaceAsync( namespaceName : namespaceName, accountId : "000000000000" ); var namespaceRoleName = await _roleRepository .CreateNamespaceFullAccessRole(namespaceName); await _roleBindingRepository.BindNamespaceRoleToGroup( namespaceName : namespaceName, role : namespaceRoleName, group : capabilityName ); }
public async Task ConnectAwsArnToNameSpace(NamespaceName namespaceName, string roleArn) { var roleName = namespaceName; await _configMapService.AddRole( roleName : roleName, roleArn : roleArn ); var annotations = new Dictionary <string, string>(); await _namespaceRepository.AddAnnotations(namespaceName, annotations); }