-
Notifications
You must be signed in to change notification settings - Fork 41
Add cloud logging service feature #1847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Yavor16
wants to merge
5
commits into
master
Choose a base branch
from
export-logs-to-logging-service-squash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...ndry/multiapps/controller/core/auditlogging/CloudLoggingServiceConfigurationAuditLog.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.auditlogging; | ||
|
|
||
| import java.text.MessageFormat; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| import org.cloudfoundry.multiapps.controller.core.Messages; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration; | ||
| import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions; | ||
| import org.cloudfoundry.multiapps.controller.persistence.model.LoggingConfiguration; | ||
|
|
||
| public class CloudLoggingServiceConfigurationAuditLog { | ||
|
|
||
| private static final String ID_PROPERTY_NAME = "id"; | ||
| private static final String MTA_ID_PROPERTY_NAME = "mtaId"; | ||
| private static final String MTA_SPACE_PROPERTY_NAME = "mtaSpace"; | ||
| private static final String MTA_SPACE_ID_PROPERTY_NAME = "mtaSpaceId"; | ||
| private static final String MTA_ORG_PROPERTY_NAME = "mtaOrg"; | ||
| private static final String NAMESPACE_PROPERTY_NAME = "namespace"; | ||
| private static final String TARGET_SPACE_PROPERTY_NAME = "targetSpace"; | ||
| private static final String TARGET_ORG_PROPERTY_NAME = "targetOrg"; | ||
| private static final String SERVICE_INSTANCE_NAME_PROPERTY_NAME = "serviceInstanceName"; | ||
| private static final String SERVICE_KEY_NAME_PROPERTY_NAME = "serviceKeyName"; | ||
| private static final String LOG_LEVEL_PROPERTY_NAME = "logLevel"; | ||
| private static final String IS_FAILSAFE_PROPERTY_NAME = "isFailSafe"; | ||
|
|
||
| private final AuditLoggingFacade auditLoggingFacade; | ||
|
|
||
| public CloudLoggingServiceConfigurationAuditLog(AuditLoggingFacade auditLoggingFacade) { | ||
| this.auditLoggingFacade = auditLoggingFacade; | ||
| } | ||
|
|
||
| public void logCreateLoggingConfiguration(String username, String spaceId, LoggingConfiguration loggingConfiguration) { | ||
| String performedAction = MessageFormat.format(Messages.LOGGING_CONFIGURATION_CREATE, spaceId); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceId, | ||
| performedAction, | ||
| Messages.LOGGING_CONFIGURATION_CREATE_AUDIT_LOG_CONFIG, | ||
| buildIdentifiers(loggingConfiguration)), | ||
| ConfigurationChangeActions.CONFIGURATION_CREATE); | ||
| } | ||
|
|
||
| public void logUpdateLoggingConfiguration(String username, String spaceId, LoggingConfiguration newConfiguration) { | ||
| String performedAction = MessageFormat.format(Messages.LOGGING_CONFIGURATION_UPDATE, spaceId); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceId, | ||
| performedAction, | ||
| Messages.LOGGING_CONFIGURATION_UPDATE_AUDIT_LOG_CONFIG, | ||
| buildIdentifiers(newConfiguration)), | ||
| ConfigurationChangeActions.CONFIGURATION_UPDATE); | ||
| } | ||
|
|
||
| public void logDeleteLoggingConfiguration(String username, String spaceId, LoggingConfiguration loggingConfiguration) { | ||
| String performedAction = MessageFormat.format(Messages.LOGGING_CONFIGURATION_DELETE, spaceId); | ||
| auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(username, | ||
| spaceId, | ||
| performedAction, | ||
| Messages.LOGGING_CONFIGURATION_DELETE_AUDIT_LOG_CONFIG, | ||
| buildIdentifiers(loggingConfiguration)), | ||
| ConfigurationChangeActions.CONFIGURATION_DELETE); | ||
| } | ||
|
|
||
| public void logGetLoggingConfiguration(String username, String spaceId, LoggingConfiguration loggingConfiguration) { | ||
| String performedAction = MessageFormat.format(Messages.LOGGING_CONFIGURATION_GET, spaceId); | ||
| auditLoggingFacade.logDataAccessAuditLog(new AuditLogConfiguration(username, | ||
|
Yavor16 marked this conversation as resolved.
|
||
| spaceId, | ||
| performedAction, | ||
| Messages.LOGGING_CONFIGURATION_GET_AUDIT_LOG_CONFIG, | ||
| buildIdentifiers(loggingConfiguration))); | ||
| } | ||
|
|
||
| private Map<String, String> buildIdentifiers(LoggingConfiguration loggingConfiguration) { | ||
| Map<String, String> identifiers = new HashMap<>(); | ||
| identifiers.put(ID_PROPERTY_NAME, loggingConfiguration.getId()); | ||
| identifiers.put(MTA_ID_PROPERTY_NAME, loggingConfiguration.getMtaId()); | ||
| identifiers.put(MTA_SPACE_PROPERTY_NAME, loggingConfiguration.getMtaSpace()); | ||
| identifiers.put(MTA_SPACE_ID_PROPERTY_NAME, loggingConfiguration.getMtaSpaceId()); | ||
| identifiers.put(MTA_ORG_PROPERTY_NAME, loggingConfiguration.getMtaOrg()); | ||
| identifiers.put(NAMESPACE_PROPERTY_NAME, loggingConfiguration.getNamespace()); | ||
| identifiers.put(TARGET_SPACE_PROPERTY_NAME, loggingConfiguration.getTargetSpace()); | ||
| identifiers.put(TARGET_ORG_PROPERTY_NAME, loggingConfiguration.getTargetOrg()); | ||
| identifiers.put(SERVICE_INSTANCE_NAME_PROPERTY_NAME, loggingConfiguration.getServiceInstanceName()); | ||
| identifiers.put(SERVICE_KEY_NAME_PROPERTY_NAME, loggingConfiguration.getServiceKeyName()); | ||
|
Yavor16 marked this conversation as resolved.
|
||
| identifiers.put(LOG_LEVEL_PROPERTY_NAME, Objects.toString(loggingConfiguration.getLogLevel())); | ||
| identifiers.put(IS_FAILSAFE_PROPERTY_NAME, Objects.toString(loggingConfiguration.isFailSafe())); | ||
| return identifiers; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...org/cloudfoundry/multiapps/controller/core/model/ExternalLoggingServiceConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package org.cloudfoundry.multiapps.controller.core.model; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
| import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
| import org.cloudfoundry.multiapps.common.Nullable; | ||
| import org.immutables.value.Value; | ||
|
|
||
| @Value.Immutable | ||
| @JsonSerialize(as = ImmutableExternalLoggingServiceConfiguration.class) | ||
| @JsonDeserialize(as = ImmutableExternalLoggingServiceConfiguration.class) | ||
| public interface ExternalLoggingServiceConfiguration { | ||
|
|
||
| @Nullable | ||
| String getServiceInstanceName(); | ||
|
|
||
| @Nullable | ||
| String getServiceKeyName(); | ||
|
|
||
| @Nullable | ||
| String getTargetOrg(); | ||
|
|
||
| @Nullable | ||
| String getTargetSpace(); | ||
|
|
||
| @Nullable | ||
| String getOperationId(); | ||
|
|
||
| @Nullable | ||
| String getEndpointUrl(); | ||
|
|
||
| @Nullable | ||
| String getServerCa(); | ||
|
|
||
| @Nullable | ||
| String getClientCert(); | ||
|
|
||
| @Nullable | ||
| String getClientKey(); | ||
|
|
||
| @Value.Default | ||
| default List<String> getLogLevels() { | ||
| return List.of(); | ||
| } | ||
|
|
||
| @Value.Default | ||
| default Boolean isFailSafe() { | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.