-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Added migration/index.asciidoc generation support #87318
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
Merged
craigtaverner
merged 6 commits into
elastic:master
from
craigtaverner:release-notes-migration-index
Jun 2, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b0cea2e
Extract static content from migration/index
craigtaverner 51a3fe0
Added migration/index.asciidoc generation support
craigtaverner 8ae4c50
Code review cleanup for dynamic migration/index
craigtaverner 599ab3f
Update build-tools-internal/src/main/java/org/elasticsearch/gradle/in…
craigtaverner 2c71b26
Update build-tools-internal/src/main/java/org/elasticsearch/gradle/in…
craigtaverner 4824aee
Removed unused import
craigtaverner 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
50 changes: 50 additions & 0 deletions
50
...rnal/src/main/java/org/elasticsearch/gradle/internal/release/MigrationIndexGenerator.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,50 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal.release; | ||
|
||
import com.google.common.annotations.VisibleForTesting; | ||
|
||
import java.io.File; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.TreeSet; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Comparator.reverseOrder; | ||
|
||
/** | ||
* This class ensures that the migrate/index page has the appropriate anchors and include directives | ||
* for the current repository version. | ||
*/ | ||
public class MigrationIndexGenerator { | ||
|
||
static void update(Set<MinorVersion> versions, File indexTemplate, File indexFile) throws IOException { | ||
try (FileWriter indexFileWriter = new FileWriter(indexFile)) { | ||
indexFileWriter.write(generateFile(versions, Files.readString(indexTemplate.toPath()))); | ||
} | ||
} | ||
|
||
@VisibleForTesting | ||
static String generateFile(Set<MinorVersion> versionsSet, String template) throws IOException { | ||
final Set<MinorVersion> versions = new TreeSet<>(reverseOrder()); | ||
versions.addAll(versionsSet); | ||
final List<String> includeVersions = versions.stream().map(MinorVersion::underscore).collect(Collectors.toList()); | ||
|
||
final Map<String, Object> bindings = new HashMap<>(); | ||
bindings.put("versions", versions); | ||
bindings.put("includeVersions", includeVersions); | ||
|
||
return TemplateUtils.render(template, bindings); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/MinorVersion.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,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.gradle.internal.release; | ||
|
||
import java.util.Comparator; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Encapsulates comparison and printing logic for an x.y. | ||
*/ | ||
public record MinorVersion(int major, int minor) implements Comparable<MinorVersion> { | ||
/** | ||
* Converts a QualifiedVersion into a MinorVersion by deleting all but the major and minor components. | ||
*/ | ||
public static MinorVersion of(final QualifiedVersion v) { | ||
Objects.requireNonNull(v); | ||
return new MinorVersion(v.major(), v.minor()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return major + "." + minor; | ||
} | ||
|
||
/** Generate version string with underscore instead of dot */ | ||
public String underscore() { | ||
return major + "_" + minor; | ||
} | ||
|
||
private static final Comparator<MinorVersion> COMPARATOR = Comparator.comparing((MinorVersion v) -> v.major) | ||
.thenComparing(v -> v.minor); | ||
|
||
@Override | ||
public int compareTo(MinorVersion other) { | ||
return COMPARATOR.compare(this, other); | ||
} | ||
|
||
public boolean isBefore(MinorVersion other) { | ||
return this.compareTo(other) < 0; | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
build-tools-internal/src/main/resources/templates/migration-index.asciidoc
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,4 @@ | ||
include::migration_intro.asciidoc[] | ||
|
||
<% versions.each { print "* <<migrating-${ it },Migrating to ${ it }>>\n" } %> | ||
<% includeVersions.each { print "include::migrate_${ it }.asciidoc[]\n" } %> |
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
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,31 @@ | ||
[[breaking-changes]] | ||
= Migration guide | ||
|
||
This section discusses the changes that you need to be aware of to migrate | ||
your application to {version}. For more information about what's new in this | ||
release, see the <<release-highlights>> and <<es-release-notes>>. | ||
|
||
As {es} introduces new features and improves existing ones, the changes | ||
sometimes make older settings, APIs, and parameters obsolete. We typically | ||
deprecate obsolete functionality as part of a release. If possible, we support | ||
the deprecated functionality for several subsequent releases before removing it. | ||
This enables applications to continue working unchanged while you prepare to | ||
migrate away from the deprecated functionality. | ||
|
||
To get the most out of {es} and facilitate future upgrades, we strongly | ||
encourage migrating away from using deprecated functionality as soon as | ||
possible. | ||
|
||
To give you insight into what deprecated features you're using, {es}: | ||
|
||
- Returns a `Warn` HTTP header whenever you | ||
submit a request that uses deprecated functionality. | ||
- <<deprecation-logging, Logs deprecation warnings>> when | ||
deprecated functionality is used. | ||
- <<migration-api-deprecation, Provides a deprecation info API>> | ||
that scans a cluster's configuration | ||
and mappings for deprecated functionality. | ||
|
||
For more information about {minor-version}, | ||
see the <<release-highlights>> and <<es-release-notes>>. | ||
For information about how to upgrade your cluster, see <<setup-upgrade>>. |
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.