Skip to content

Commit

Permalink
Initial commit for schema version 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
emrul committed Sep 12, 2024
1 parent 6a6cebf commit f49108b
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# build output
dist
public
public/*
.next
target
packages/next/wasm/@next
out
site/public/icons
site/public/list.json
!site/public/logo.svg

# dependencies
node_modules
Expand Down
1 change: 1 addition & 0 deletions build_all_branches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
48 changes: 48 additions & 0 deletions processing/add_next_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const fs = require("fs");
const glob = require("glob");

const baseversion = '1.16'
const tag = ':develop'

const version = baseversion + '.x'
const tagversion = baseversion + '.0'

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);

const current = parsed.compatibility[parsed.compatibility.length - 1]
const image = current.image.split(':')[0]

const exists = parsed.compatibility.findIndex(el => el.version === version)

let details = {
version,
image: image + tag,
uncompressed_size_mb: 0,
available_tags: [
'develop',
tagversion,
tagversion + '-rolling-weekly',
tagversion + '-rolling-daily'
]
}

if (exists === -1) {
parsed.compatibility.push(details)
fs.writeFileSync(file, JSON.stringify(parsed, null, 2));
}
}


});
45 changes: 45 additions & 0 deletions processing/get_image_sizes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const fs = require("fs");
const glob = require("glob");
const { execSync } = require('child_process');


glob("../workspaces/**/workspace.json", function (err, files) {
if (err) {
console.log(
"cannot read the folder, something goes wrong with glob",
err
);
}

let total = 0
for (const file of files) {

let filedata = fs.readFileSync(file);
let parsed = JSON.parse(filedata);


parsed.compatibility.forEach((element, index) => {
total++
if (element.uncompressed_size_mb === 0) {
execSync('docker image prune -a -f')
execSync('docker system prune --all --force --volumes')

let pull = execSync('docker pull ' + element.image)
// console.log(pull)
let inspect = execSync('docker inspect -f "{{ .Size }}" ' + element.image)
let size = Math.round(inspect / 1000000)
let remove = execSync('docker rmi ' + element.image)
console.log(remove)
parsed.compatibility[index].uncompressed_size_mb = size
console.log('Write file: ' + parsed.friendly_name + ' - ' + element.version + ': ' + size)
fs.writeFileSync(file, JSON.stringify(parsed, null, 2));
} else {
console.log(parsed.friendly_name + ' - ' + element.version + ': skipped')
}

})

}
console.log(total + ' entries processed')

});
24 changes: 23 additions & 1 deletion processing/processjson.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ glob("**/workspace.json", async function (err, files) {
encoding: "hex",
};

let channels = new Set()
let versions = new Set()

for (const file of files) {
//files.forEach(async function(file) {

Expand All @@ -39,7 +42,17 @@ 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) => {
channels.add(el)
})
}
if ('version' in element) {
versions.add(element.version)
}
})
workspaces.push(parsed);

if (fs.existsSync(folder + "/" + parsed.image_src)) {
Expand All @@ -60,9 +73,18 @@ glob("**/workspace.json", async function (err, files) {
contact_url: nextConfig.env.contactUrl || null,
modified: Date.now(),
workspaces: workspaces,
channels: [...channels],
default_channel: 'develop'
};

if (channels.size === 0) {
json.default_channel = null
}

let data = JSON.stringify(json);

fs.writeFileSync(dir + "/list.json", data);
fs.writeFileSync(dir + "/versions.json", JSON.stringify({
versions: [...versions]
}));
});
35 changes: 35 additions & 0 deletions processing/update_1_0_to_1_1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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,
uncompressed_size_mb: parsed.uncompressed_size_mb
}

parsed.compatibility.push(details)
delete parsed.uncompressed_size_mb
delete parsed.name

fs.writeFileSync(file, JSON.stringify(parsed, null, 2));
}


});
4 changes: 2 additions & 2 deletions site/components/Workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div onClick={() => 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">
<div onClick={() => 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-[#5b2e91] hover:to-[#ff4f97] hover:text-white">
<div className="w-full h-full">
<div className="show-grid flex h-full items-center">
<div className="kasmcard-img flex h-full mx-4 items-center justify-center">
Expand Down
6 changes: 3 additions & 3 deletions site/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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) => {
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function Home({ searchText }) {
<h1 className='flex flex-wrap-reverse uppercase tracking-widest justify-center mb-10 gap-5'>
<span className='flex items-center text-lg bg-slate-100/90 rounded overflow-hidden shadow'>
<span className='flex px-3 text-xs opacity-100'>Workspaces</span>
<span className='text-white p-3 py-1 flex bg-[#2980b9]'>{workspaces && workspaces.workspacecount}</span>
<span className='text-white p-3 py-1 flex bg-[#2980b9]'>{filteredworkspaces && filteredworkspaces.length}</span>
</span>
<span className='flex items-center text-lg bg-slate-100/90 rounded overflow-hidden shadow'>
<span className='flex px-3 text-xs opacity-100'>Kasm Version</span>
Expand Down
4 changes: 2 additions & 2 deletions site/pages/new/[[...workspace]].js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -75,7 +75,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
Expand Down
14 changes: 7 additions & 7 deletions workspaces/Twingate Chrome/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"description": "Google Chrome with Twingate Zero-Trust Network Access.",
"docker_registry": "https://europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/",
"image_src": "twingate-chrome.svg",
"name": "europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/tg-chrome:dev",
"run_config": {
"cap_add": [
"NET_ADMIN"
Expand All @@ -27,11 +26,12 @@
"architecture": [
"amd64"
],
"notes": "For setup instructions please refer to Twingate documentation at https://[TODO]",
"compatibility": [
"1.13.x",
"1.14.x",
"1.15.x"
],
"uncompressed_size_mb": 2170,
"notes": "For setup instructions please refer to Twingate documentation at https://[TODO]"
{
"version": "1.16.x",
"image": "europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/tg-chrome:dev",
"uncompressed_size_mb": 2170
}
]
}
14 changes: 7 additions & 7 deletions workspaces/Twingate Desktop/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"description": "Ubuntu Desktop with Twingate Zero-Trust Network Access.",
"docker_registry": "https://europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/",
"image_src": "twingate-desktop.svg",
"name": "europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/tg-desktop:dev",
"run_config": {
"cap_add": [
"NET_ADMIN"
Expand All @@ -29,11 +28,12 @@
"architecture": [
"amd64"
],
"notes": "For setup instructions please refer to Twingate documentation at https://[TODO]",
"compatibility": [
"1.13.x",
"1.14.x",
"1.15.x"
],
"uncompressed_size_mb": 7660,
"notes": "For setup instructions please refer to Twingate documentation at https://[TODO]"
{
"version": "1.16.x",
"image": "europe-west2-docker.pkg.dev/twingate-labs/tg-agentless-images/tg-desktop:dev",
"uncompressed_size_mb": 7660
}
]
}

0 comments on commit f49108b

Please sign in to comment.