Skip to content

Commit

Permalink
Fix some issues with extensions creator's package in release 2.9 (#12637
Browse files Browse the repository at this point in the history
)

* fix build-extension-charts workflow + bump creators version

* remove fetchLatestVersion function and harcode meaningful annotation to pkg/package.json
  • Loading branch information
aalves08 authored Nov 25, 2024
1 parent 0a52f18 commit 0d6483c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Release Extension Charts

on:
workflow_dispatch:
release:
release:
types: [released]

defaults:
Expand All @@ -12,11 +12,12 @@ defaults:

jobs:
build-extension-charts:
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@master
uses: rancher/dashboard/.github/workflows/build-extension-charts.yml@release-2.9
permissions:
actions: write
contents: write
deployments: write
pages: write
with:
target_branch: gh-pages
tagged_release: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion creators/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rancher/create-extension",
"description": "Rancher UI Extension generator",
"version": "0.2.1-rc.1",
"version": "2.0.0",
"license": "Apache-2.0",
"author": "SUSE",
"packageManager": "[email protected]",
Expand Down
62 changes: 0 additions & 62 deletions creators/extension/pkg/init
Original file line number Diff line number Diff line change
Expand Up @@ -105,68 +105,6 @@ Object.keys(targets).forEach((target) => {
}
});

// Add annotation for the latest Rancher version by default
function fetchLatestVersion() {
console.log(' Fetching latest Rancher Version');
const options = { headers: { 'User-Agent': 'nodejs' } };

https.get('https://api.github.com/repos/rancher/rancher/releases/latest', options, (res) => {
const { statusCode } = res;
const contentType = res.headers['content-type'];

let error;

if ( statusCode !== 200 ) {
error = new Error(' Request Failed.\n' +
` Status Code: ${ statusCode }`);
} else if ( !/^application\/json/.test(contentType) ) {
error = new Error(' Invalid content-type.\n' +
` Expected application/json but received ${ contentType }`);
}

if ( error ) {
console.log(error.message);

res.resume();

return;
}

res.setEncoding('utf8');
let rawData = '';

res.on('data', (chunk) => {
rawData += chunk;
});
res.on('end', () => {
try {
const release = JSON.parse(rawData);

if ( release.tag_name ) {
console.log(` Adding rancher-version annotation '>= ${ release.tag_name }' to package.json`);

pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };

if ( !shellVersion ) {
console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
} else {
console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);

pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
}

writePackageJson();
}
} catch (e) {
console.log(' Error parsing release data', e);
}
});
}).on('error', (e) => {
console.log(' Error fetching latest Rancher Version', e);
});
}

fetchLatestVersion();
writePackageJson();

// Add dependencies
Expand Down
6 changes: 6 additions & 0 deletions creators/extension/pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"**/*.*",
"init"
],
"rancher": {
"annotations": {
"catalog.cattle.io/rancher-version": ">= 2.9.0 < 2.10.0",
"catalog.cattle.io/ui-extensions-version": "< 3.0.0"
}
},
"engines": {
"node": ">=16.0.0"
},
Expand Down

0 comments on commit 0d6483c

Please sign in to comment.