Skip to content

Commit 9899932

Browse files
authored
docs: use the 'latest' GH release API for the latest extension or agent release (#402)
The "Monitoring AWS Lambda $lang Functions" doc pages use some in-browser JS to interpolate the ARNs for the latest Lambda extension release and the latest APM agent release. This changes that JS to use the "latest release" GH API https://api.github.com/repos/elastic/${ghRepo}/releases/latest rather than listing all (or the first page of GH releases): https://api.github.com/repos/elastic/${ghRepo}/releases and picking the latest by `release.created_at`. GH releases for a repo have a sense of the "latest" release (see `--latest` flag to https://cli.github.com/manual/gh_release_create) even if it isn't the latest tag or published release in time. The Node.js APM agent will soon have 4.x releases and 3.x maintenance releases. It is possible that a 3.x release is the latest in time, but not marked as the "latest" release. This change ensures that the Lambda doc page will pick the correct (4.x) one.
1 parent fb6d2dc commit 9899932

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

docs/lambda-selector/lambda-attributes-selector.asciidoc

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,12 @@ const addArnGenerator = async (type, ghRepo, arnPattern) => {
8686
var releaseArns = [];
8787
8888
const retrieveLatestLayerVersion = async () => {
89-
const releases = await fetch(`https://api.github.com/repos/elastic/${ghRepo}/releases`).then(data => {
89+
var latestRelease = await fetch(`https://api.github.com/repos/elastic/${ghRepo}/releases/latest`).then(data => {
9090
return data.status >= 400 ? undefined : data.json();
9191
});
9292
93-
if(releases){
94-
var latestRelease = releases[0];
95-
96-
releases.forEach(release => {
97-
if(Date.parse(release.created_at) > Date.parse(latestRelease.created_at)){
98-
latestRelease = release;
99-
}
100-
});
101-
93+
if (latestRelease) {
10294
releaseArns = latestRelease.body.match(layerArnPattern);
103-
10495
version = latestRelease.tag_name.replace("v","ver-").replace(/\./g, '-');
10596
} else {
10697
document.getElementById("default-arn-selector-section").style.display = "none";

0 commit comments

Comments
 (0)