Skip to content

Commit

Permalink
Fix IsIncludedOutOfTheBox to account for snapshots (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Jul 5, 2022
1 parent e94a88c commit 6615fc4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Elastic.Stack.ArtifactsApi/Products/SubProduct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,19 @@ public SubProduct(string subProject, Func<ElasticVersion, bool> isValid = null,
public string GetExistsMoniker(ElasticVersion version) => _getExistsMoniker(version);

/// <summary>Whether the sub project is included in the distribution out of the box for the given version</summary>
public bool IsIncludedOutOfTheBox(ElasticVersion version) =>
ShippedByDefaultAsOf != null && version >= ShippedByDefaultAsOf;
public bool IsIncludedOutOfTheBox(ElasticVersion version)
{
if (ShippedByDefaultAsOf is null)
return false;

// When we are using a snapshot version of Elasticsearch compare on base version.
// This ensures that when testing with a snapshot, we install plugins correctly.
// e.g. When testing with 8.4.0-SNAPSHOT of elasticsearch, we don't expect to ingest-attachment,
// added in-box in 8.4.0 to be installed.
return version.ArtifactBuildState == ArtifactBuildState.Snapshot
? version.BaseVersion() >= ShippedByDefaultAsOf.BaseVersion()
: version >= ShippedByDefaultAsOf;
}

/// <summary>Whether the subProject is valid for the given version</summary>
public bool IsValid(ElasticVersion version) => IsIncludedOutOfTheBox(version) || _isValid(version);
Expand Down

0 comments on commit 6615fc4

Please sign in to comment.