diff --git a/README.md b/README.md index 0cbd32c..a3a777b 100644 --- a/README.md +++ b/README.md @@ -253,11 +253,32 @@ In the new branch, make any updates that are needed, when the changes are commit Kasm Workspaces will automatically pull the version of the schema that it understands. -**Updating to 1.17.x support** +If only the latest version is building (so 1.1 works but 1.0 doesn't), open build_all_branches.sh, search for `echo "All branches:` and check if there is `git fetch --all` on the line underneath, if not, add it. -1.17.x changed the schema from 1.0 to 1.1, the main changes to this are the compatibility changes from a simple array to an array of objects, this allows us to tie the image used and the image size to the kasm version. +**Updating to 1.16.x support** + +1.16.x changed the schema from 1.0 to 1.1, the main changes to this are the compatibility changes from a simple array to an array of objects, this allows us to tie the image used and the image size to the kasm version. In addition the top level name is removed as is top level uncompessed_size_mb as these are now available in the compatibility matrix (name is called image). +If you have an older version you will probably need to update the following files: +* build_all_branches.sh +* processing/processjson.js +* site/components/Workspace.js +* site/pages/index.js +* site/pages/new/[[..workspace]].js + +If you have a lot of workspaces (or just want an easier way to update your workspaces), there is an update file in processing called `update_1_0_to_1_1.js` copy that across to your own install, edit it and make sure the tags etc match your install. If you don't want to use channels, you can remove the available_tags section entirely. + +Then to use it, create a 1.1 branch from your current 1.0 source, then in a terminal: + +``` +cd processing +npm install +node update_1_0_to_1_1.js +``` + +This will convert your existing workspaces to a 1.1 compatible format. + ## Channels Schema 1.1 added the concept of channels. Each registry can specify the channels they support, these are defined by the tags an image has. For example you might have develop, 1.17.0 and 1.17.0-rolling-daily. When the registry json is built it loops through all the workspaces and generates a list of all the possible "Channels" (tags) that are listed in compatibility.available_tags. Available tags is an optional list, if you don't include it on any of the workspaces then your registry will work as before without presenting the end user with a channels option. You shouldn't mix and match though, if you add available tags to 1 workspace, you should add available tags to all workspaces. diff --git a/build_all_branches.sh b/build_all_branches.sh index 78f9085..a4a34db 100755 --- a/build_all_branches.sh +++ b/build_all_branches.sh @@ -10,6 +10,7 @@ touch base/.nojekyll # Generating documentation for each other branch in a subdirectory echo "All branches:" +git fetch --all echo "$(git branch --remotes --format '%(refname:lstrip=3)' | grep -Ev '^(HEAD|develop|gh-pages)$')" for BRANCH in $(git branch --remotes --format '%(refname:lstrip=3)' | grep -Ev '^(HEAD|develop|gh-pages)$'); do SANITIZED_BRANCH="$(echo $BRANCH | sed 's/\//_/g')" diff --git a/processing/processjson.js b/processing/processjson.js index 8ab94df..d076048 100644 --- a/processing/processjson.js +++ b/processing/processjson.js @@ -41,7 +41,7 @@ glob("**/workspace.json", async function (err, files) { let parsed = JSON.parse(filedata); parsed.sha = hash.hash; - console.log(parsed.name + ' added') + console.log(parsed.friendly_name + ' added') parsed.compatibility.forEach((element, index) => { if ('available_tags' in element) { element.available_tags.forEach((el) => { diff --git a/processing/update_1_0_to_1_1.js b/processing/update_1_0_to_1_1.js new file mode 100644 index 0000000..4967963 --- /dev/null +++ b/processing/update_1_0_to_1_1.js @@ -0,0 +1,41 @@ +const fs = require("fs"); +const glob = require("glob"); + +glob("../workspaces/**/workspace.json", async function (err, files) { + if (err) { + console.log( + "cannot read the folder, something goes wrong with glob", + err + ); + } + + + for (const file of files) { + + let filedata = fs.readFileSync(file); + let parsed = JSON.parse(filedata); + delete parsed.compatibility + + parsed.compatibility = [] + + let details = { + version: '1.16.x', + image: parsed.name.split(':')[0] + ':1.16.0-rolling-daily', + uncompressed_size_mb: 0, + available_tags: [ + 'develop', + '1.16.0', + '1.16.0-rolling-weekly', + '1.16.0-rolling-daily' + ] + } + + parsed.compatibility.push(details) + delete parsed.uncompressed_size_mb + delete parsed.name + + fs.writeFileSync(file, JSON.stringify(parsed, null, 2)); + } + + +}); diff --git a/site/components/Workspace.js b/site/components/Workspace.js index 897e3f3..b8fe793 100644 --- a/site/components/Workspace.js +++ b/site/components/Workspace.js @@ -6,12 +6,12 @@ function Workspace({ Component, pageProps, workspace }) { const viewexample = (workspace) => { router.push({ pathname: '/new/[workspace]', - query: { workspace: btoa(workspace.name)} + query: { workspace: btoa(workspace.friendly_name)} }) } return ( -
viewexample(workspace)} className="w-[245px] h-[88px] transition-all relative cursor-pointer group flex p-2 items-center justify-center bg-slate-100/90 shadow rounded hover:shadow-xl hover:bg-gradient-to-r hover:from-slate-900 hover:to-cyan-800 hover:text-white"> +
viewexample(workspace)} className="w-[245px] h-[88px] transition-all relative cursor-pointer group flex p-2 items-center justify-center bg-slate-100/90 shadow rounded hover:shadow-xl hover:bg-gradient-to-r hover:from-[#162d48] hover:to-[#2980b9] hover:text-white">
diff --git a/site/pages/index.js b/site/pages/index.js index 35201c6..c6c47be 100644 --- a/site/pages/index.js +++ b/site/pages/index.js @@ -18,7 +18,7 @@ export default function Home({ searchText }) { workspaces.workspaces.forEach((workspace) => { if(workspace.compatibility) { workspace.compatibility.forEach((v) => { - const value = parseFloat(v) + const value = parseFloat(v.version) if(wsversions.indexOf(value) === -1) { wsversions.push(value) } @@ -43,7 +43,7 @@ export default function Home({ searchText }) { } let filteredworkspaces = workspaces && workspaces.workspaces && workspaces.workspaces.length > 0 ? [...workspaces.workspaces] : []; - filteredworkspaces = filteredworkspaces.filter((v) => v.compatibility.some((el) => el === version + '.x')) + filteredworkspaces = filteredworkspaces.filter((v) => v.compatibility.some((el) => el.version === version + '.x')) const lowerSearch = searchText && searchText.toLowerCase(); if (searchText && searchText !== "") { filteredworkspaces = filteredworkspaces.filter((i) => { diff --git a/site/pages/new/[[...workspace]].js b/site/pages/new/[[...workspace]].js index b20508b..dbc7afd 100644 --- a/site/pages/new/[[...workspace]].js +++ b/site/pages/new/[[...workspace]].js @@ -10,7 +10,7 @@ import allworkspaces from '../../../public/list.json' export async function getStaticPaths() { let paths = allworkspaces.workspaces.map(workspace => ({ params: { - workspace: [btoa(workspace.name)] + workspace: [btoa(workspace.friendly_name)] } })) paths.push({ @@ -47,7 +47,6 @@ export default function New({ workspace }) { friendly_name: null, image_src: null, description: null, - name: null, cores: 2, memory: 2768, gpu_count: 0, @@ -75,7 +74,7 @@ export default function New({ workspace }) { setCombined(defaultState) } else if (workspace && workspace[0]) { - const workspaceDetails = allworkspaces.workspaces.find(el => el.name === atob(workspace[0])) + const workspaceDetails = allworkspaces.workspaces.find(el => el.friendly_name === atob(workspace[0])) delete workspaceDetails['sha'] description.current.value = workspaceDetails.description name.current.value = workspaceDetails.name @@ -296,7 +295,7 @@ export default function New({ workspace }) {
{JSON.stringify(displayWorkspace(), null, 2)}
- +