Skip to content

Commit

Permalink
Add config for skipDeletionAdditionalGuardCheck pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ruhan1 committed Nov 16, 2023
1 parent b1624c1 commit 473b8e0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ public interface IndyTrackingConfiguration
@WithDefault( "false" )
Boolean deletionAdditionalGuardCheck();

@WithName( "skipDeletionAdditionalGuardCheck" )
@WithDefault( "^temporary-.*" )
String skipDeletionAdditionalGuardCheck();
}
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,11 @@ public boolean recordArtifact( InputStream stream )
*/
public boolean deletionAdditionalGuardCheck( BatchDeleteRequest deleteRequest )
{
if ( !config.deletionAdditionalGuardCheck() )
if ( !config.deletionAdditionalGuardCheck() || deleteRequest.getStoreKey().getName()
.matches(config.skipDeletionAdditionalGuardCheck()))
{
return true; // as passed if guard check is not enabled
logger.debug("Deletion additional check not enabled or skipped, store: {}", deleteRequest.getStoreKey());
return true;
}

String trackingID = deleteRequest.getTrackingID();
Expand Down Expand Up @@ -409,7 +411,7 @@ public boolean deletionAdditionalGuardCheck( BatchDeleteRequest deleteRequest )
logger.warn("Deletion guard check failed", e);
return false;
}
logger.info("Deletion guard check, trackingID: {}, passed: {}", trackingID, isOk.get());
logger.info("Deletion guard check, trackingID: {}, store: {}, passed: {}", trackingID, deleteRequest.getStoreKey(), isOk.get());
return isOk.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,22 @@ public void testImportReportSuccess()
}

@Test
public void testDoDeleteSuccess() throws IndyWorkflowException, JsonProcessingException
public void testDoDeleteSuccess() throws Exception
{
StoreKey storeKey = new StoreKey( "maven", StoreType.remote, "test" );
testDoDeleteInternal( storeKey );
}

@Test
public void testDoDeleteSkipGuardCheck() throws Exception
{
// By default, skip repos with name matching "^temporary-.*"
StoreKey storeKey = new StoreKey( "maven", StoreType.remote, "temporary-builds" );
testDoDeleteInternal( storeKey );
}

private void testDoDeleteInternal( StoreKey storeKey ) throws Exception
{
BatchDeleteRequest batchDeleteRequest = new BatchDeleteRequest();
batchDeleteRequest.setStoreKey( storeKey );
batchDeleteRequest.setTrackingID( TRACKING_ID );
Expand Down

0 comments on commit 473b8e0

Please sign in to comment.