...
This commit is contained in:
12
lib/apps/biz/cryptpad/.heroscript
Normal file
12
lib/apps/biz/cryptpad/.heroscript
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
!!hero_code.generate_installer
|
||||
name:''
|
||||
classname:'CryptPad'
|
||||
singleton:0
|
||||
templates:1
|
||||
default:1
|
||||
title:''
|
||||
supported_platforms:''
|
||||
startupmanager:1
|
||||
hasconfig:1
|
||||
build:1
|
||||
187
lib/apps/biz/cryptpad/cryptpad_actions.v
Normal file
187
lib/apps/biz/cryptpad/cryptpad_actions.v
Normal file
@@ -0,0 +1,187 @@
|
||||
module cryptpad
|
||||
|
||||
import incubaid.herolib.osal.core as osal
|
||||
import incubaid.herolib.ui.console
|
||||
import incubaid.herolib.core.texttools
|
||||
import incubaid.herolib.core.pathlib
|
||||
import incubaid.herolib.osal.systemd
|
||||
import incubaid.herolib.osal.startupmanager
|
||||
import incubaid.herolib.installers.ulist
|
||||
import incubaid.herolib.installers.lang.golang
|
||||
import incubaid.herolib.installers.lang.rust
|
||||
import incubaid.herolib.installers.lang.python
|
||||
import os
|
||||
|
||||
fn startupcmd() ![]startupmanager.ZProcessNewArgs {
|
||||
mut installer := get()!
|
||||
mut res := []startupmanager.ZProcessNewArgs{}
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// res << startupmanager.ZProcessNewArgs{
|
||||
// name: 'cryptpad'
|
||||
// cmd: 'cryptpad server'
|
||||
// env: {
|
||||
// 'HOME': '/root'
|
||||
// }
|
||||
// }
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
fn running() !bool {
|
||||
mut installer := get()!
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// this checks health of cryptpad
|
||||
// curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works
|
||||
// url:='http://127.0.0.1:${cfg.port}/api/v1'
|
||||
// mut conn := httpconnection.new(name: 'cryptpad', url: url)!
|
||||
|
||||
// if cfg.secret.len > 0 {
|
||||
// conn.default_header.add(.authorization, 'Bearer ${cfg.secret}')
|
||||
// }
|
||||
// conn.default_header.add(.content_type, 'application/json')
|
||||
// console.print_debug("curl -X 'GET' '${url}'/tags --oauth2-bearer ${cfg.secret}")
|
||||
// r := conn.get_json_dict(prefix: 'tags', debug: false) or {return false}
|
||||
// println(r)
|
||||
// if true{panic("ssss")}
|
||||
// tags := r['Tags'] or { return false }
|
||||
// console.print_debug(tags)
|
||||
// console.print_debug('cryptpad is answering.')
|
||||
return false
|
||||
}
|
||||
|
||||
fn start_pre() ! {
|
||||
}
|
||||
|
||||
fn start_post() ! {
|
||||
}
|
||||
|
||||
fn stop_pre() ! {
|
||||
}
|
||||
|
||||
fn stop_post() ! {
|
||||
}
|
||||
|
||||
//////////////////// following actions are not specific to instance of the object
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed() !bool {
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// res := os.execute('${osal.profile_path_source_and()!} cryptpad version')
|
||||
// if res.exit_code != 0 {
|
||||
// return false
|
||||
// }
|
||||
// r := res.output.split_into_lines().filter(it.trim_space().len > 0)
|
||||
// if r.len != 1 {
|
||||
// return error("couldn't parse cryptpad version.\n${res.output}")
|
||||
// }
|
||||
// if texttools.version(version) == texttools.version(r[0]) {
|
||||
// return true
|
||||
// }
|
||||
return false
|
||||
}
|
||||
|
||||
// get the Upload List of the files
|
||||
fn ulist_get() !ulist.UList {
|
||||
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
|
||||
return ulist.UList{}
|
||||
}
|
||||
|
||||
// uploads to S3 server if configured
|
||||
fn upload() ! {
|
||||
// installers.upload(
|
||||
// cmdname: 'cryptpad'
|
||||
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/cryptpad'
|
||||
// )!
|
||||
}
|
||||
|
||||
fn install() ! {
|
||||
console.print_header('install cryptpad')
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// mut url := ''
|
||||
// if core.is_linux_arm()! {
|
||||
// url = 'https://github.com/cryptpad-dev/cryptpad/releases/download/v${version}/cryptpad_${version}_linux_arm64.tar.gz'
|
||||
// } else if core.is_linux_intel()! {
|
||||
// url = 'https://github.com/cryptpad-dev/cryptpad/releases/download/v${version}/cryptpad_${version}_linux_amd64.tar.gz'
|
||||
// } else if core.is_osx_arm()! {
|
||||
// url = 'https://github.com/cryptpad-dev/cryptpad/releases/download/v${version}/cryptpad_${version}_darwin_arm64.tar.gz'
|
||||
// } else if osal.is_osx_intel()! {
|
||||
// url = 'https://github.com/cryptpad-dev/cryptpad/releases/download/v${version}/cryptpad_${version}_darwin_amd64.tar.gz'
|
||||
// } else {
|
||||
// return error('unsported platform')
|
||||
// }
|
||||
|
||||
// mut dest := osal.download(
|
||||
// url: url
|
||||
// minsize_kb: 9000
|
||||
// expand_dir: '/tmp/cryptpad'
|
||||
// )!
|
||||
|
||||
// //dest.moveup_single_subdir()!
|
||||
|
||||
// mut binpath := dest.file_get('cryptpad')!
|
||||
// osal.cmd_add(
|
||||
// cmdname: 'cryptpad'
|
||||
// source: binpath.path
|
||||
// )!
|
||||
}
|
||||
|
||||
fn build() ! {
|
||||
// url := 'https://github.com/threefoldtech/cryptpad'
|
||||
|
||||
// make sure we install base on the node
|
||||
// if core.platform() != .ubuntu {
|
||||
// return error('only support ubuntu for now')
|
||||
// }
|
||||
// golang.install()!
|
||||
|
||||
// console.print_header('build cryptpad')
|
||||
|
||||
// gitpath := gittools.get_repo(coderoot: '/tmp/builder', url: url, reset: true, pull: true)!
|
||||
|
||||
// cmd := '
|
||||
// cd ${gitpath}
|
||||
// source ~/.cargo/env
|
||||
// exit 1 #todo
|
||||
// '
|
||||
// osal.execute_stdout(cmd)!
|
||||
//
|
||||
// //now copy to the default bin path
|
||||
// mut binpath := dest.file_get('...')!
|
||||
// adds it to path
|
||||
// osal.cmd_add(
|
||||
// cmdname: 'griddriver2'
|
||||
// source: binpath.path
|
||||
// )!
|
||||
}
|
||||
|
||||
fn destroy() ! {
|
||||
// mut systemdfactory := systemd.new()!
|
||||
// systemdfactory.destroy("zinit")!
|
||||
|
||||
// osal.process_kill_recursive(name:'zinit')!
|
||||
// osal.cmd_delete('zinit')!
|
||||
|
||||
// osal.package_remove('
|
||||
// podman
|
||||
// conmon
|
||||
// buildah
|
||||
// skopeo
|
||||
// runc
|
||||
// ')!
|
||||
|
||||
// //will remove all paths where go/bin is found
|
||||
// osal.profile_path_add_remove(paths2delete:"go/bin")!
|
||||
|
||||
// osal.rm("
|
||||
// podman
|
||||
// conmon
|
||||
// buildah
|
||||
// skopeo
|
||||
// runc
|
||||
// /var/lib/containers
|
||||
// /var/lib/podman
|
||||
// /var/lib/buildah
|
||||
// /tmp/podman
|
||||
// /tmp/conmon
|
||||
// ")!
|
||||
}
|
||||
312
lib/apps/biz/cryptpad/cryptpad_factory_.v
Normal file
312
lib/apps/biz/cryptpad/cryptpad_factory_.v
Normal file
@@ -0,0 +1,312 @@
|
||||
module cryptpad
|
||||
|
||||
import incubaid.herolib.core.base
|
||||
import incubaid.herolib.core.playbook { PlayBook }
|
||||
import incubaid.herolib.ui.console
|
||||
import json
|
||||
import incubaid.herolib.osal.startupmanager
|
||||
import time
|
||||
|
||||
__global (
|
||||
cryptpad_global map[string]&CryptPad
|
||||
cryptpad_default string
|
||||
)
|
||||
|
||||
/////////FACTORY
|
||||
|
||||
@[params]
|
||||
pub struct ArgsGet {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
fromdb bool // will load from filesystem
|
||||
create bool // default will not create if not exist
|
||||
}
|
||||
|
||||
pub fn new(args ArgsGet) !&CryptPad {
|
||||
mut obj := CryptPad{
|
||||
name: args.name
|
||||
}
|
||||
set(obj)!
|
||||
return get(name: args.name)!
|
||||
}
|
||||
|
||||
pub fn get(args ArgsGet) !&CryptPad {
|
||||
mut context := base.context()!
|
||||
cryptpad_default = args.name
|
||||
if args.fromdb || args.name !in cryptpad_global {
|
||||
mut r := context.redis()!
|
||||
if r.hexists('context:cryptpad', args.name)! {
|
||||
data := r.hget('context:cryptpad', args.name)!
|
||||
if data.len == 0 {
|
||||
print_backtrace()
|
||||
return error('CryptPad with name: ${args.name} does not exist, prob bug.')
|
||||
}
|
||||
mut obj := json.decode(CryptPad, data)!
|
||||
set_in_mem(obj)!
|
||||
} else {
|
||||
if args.create {
|
||||
new(args)!
|
||||
} else {
|
||||
print_backtrace()
|
||||
return error("CryptPad with name '${args.name}' does not exist")
|
||||
}
|
||||
}
|
||||
return get(name: args.name)! // no longer from db nor create
|
||||
}
|
||||
return cryptpad_global[args.name] or {
|
||||
print_backtrace()
|
||||
return error('could not get config for cryptpad with name:${args.name}')
|
||||
}
|
||||
}
|
||||
|
||||
// register the config for the future
|
||||
pub fn set(o CryptPad) ! {
|
||||
mut o2 := set_in_mem(o)!
|
||||
cryptpad_default = o2.name
|
||||
mut context := base.context()!
|
||||
mut r := context.redis()!
|
||||
r.hset('context:cryptpad', o2.name, json.encode(o2))!
|
||||
}
|
||||
|
||||
// does the config exists?
|
||||
pub fn exists(args ArgsGet) !bool {
|
||||
mut context := base.context()!
|
||||
mut r := context.redis()!
|
||||
return r.hexists('context:cryptpad', args.name)!
|
||||
}
|
||||
|
||||
pub fn delete(args ArgsGet) ! {
|
||||
mut context := base.context()!
|
||||
mut r := context.redis()!
|
||||
r.hdel('context:cryptpad', args.name)!
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct ArgsList {
|
||||
pub mut:
|
||||
fromdb bool // will load from filesystem
|
||||
}
|
||||
|
||||
// if fromdb set: load from filesystem, and not from mem, will also reset what is in mem
|
||||
pub fn list(args ArgsList) ![]&CryptPad {
|
||||
mut res := []&CryptPad{}
|
||||
mut context := base.context()!
|
||||
if args.fromdb {
|
||||
// reset what is in mem
|
||||
cryptpad_global = map[string]&CryptPad{}
|
||||
cryptpad_default = ''
|
||||
}
|
||||
if args.fromdb {
|
||||
mut r := context.redis()!
|
||||
mut l := r.hkeys('context:cryptpad')!
|
||||
|
||||
for name in l {
|
||||
res << get(name: name, fromdb: true)!
|
||||
}
|
||||
return res
|
||||
} else {
|
||||
// load from memory
|
||||
for _, client in cryptpad_global {
|
||||
res << client
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// only sets in mem, does not set as config
|
||||
fn set_in_mem(o CryptPad) !CryptPad {
|
||||
mut o2 := obj_init(o)!
|
||||
cryptpad_global[o2.name] = &o2
|
||||
cryptpad_default = o2.name
|
||||
return o2
|
||||
}
|
||||
|
||||
pub fn play(mut plbook PlayBook) ! {
|
||||
if !plbook.exists(filter: 'cryptpad.') {
|
||||
return
|
||||
}
|
||||
mut install_actions := plbook.find(filter: 'cryptpad.configure')!
|
||||
if install_actions.len > 0 {
|
||||
for mut install_action in install_actions {
|
||||
heroscript := install_action.heroscript()
|
||||
mut obj2 := heroscript_loads(heroscript)!
|
||||
set(obj2)!
|
||||
install_action.done = true
|
||||
}
|
||||
}
|
||||
mut other_actions := plbook.find(filter: 'cryptpad.')!
|
||||
for mut other_action in other_actions {
|
||||
if other_action.name in ['destroy', 'install', 'build'] {
|
||||
mut p := other_action.params
|
||||
reset := p.get_default_false('reset')
|
||||
if other_action.name == 'destroy' || reset {
|
||||
console.print_debug('install action cryptpad.destroy')
|
||||
destroy()!
|
||||
}
|
||||
if other_action.name == 'install' {
|
||||
console.print_debug('install action cryptpad.install')
|
||||
install()!
|
||||
}
|
||||
}
|
||||
if other_action.name in ['start', 'stop', 'restart'] {
|
||||
mut p := other_action.params
|
||||
name := p.get('name')!
|
||||
mut cryptpad_obj := get(name: name)!
|
||||
console.print_debug('action object:\n${cryptpad_obj}')
|
||||
if other_action.name == 'start' {
|
||||
console.print_debug('install action cryptpad.${other_action.name}')
|
||||
cryptpad_obj.start()!
|
||||
}
|
||||
|
||||
if other_action.name == 'stop' {
|
||||
console.print_debug('install action cryptpad.${other_action.name}')
|
||||
cryptpad_obj.stop()!
|
||||
}
|
||||
if other_action.name == 'restart' {
|
||||
console.print_debug('install action cryptpad.${other_action.name}')
|
||||
cryptpad_obj.restart()!
|
||||
}
|
||||
}
|
||||
other_action.done = true
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fn startupmanager_get(cat startupmanager.StartupManagerType) !startupmanager.StartupManager {
|
||||
// unknown
|
||||
// screen
|
||||
// zinit
|
||||
// tmux
|
||||
// systemd
|
||||
match cat {
|
||||
.screen {
|
||||
console.print_debug("installer: cryptpad' startupmanager get screen")
|
||||
return startupmanager.get(.screen)!
|
||||
}
|
||||
.zinit {
|
||||
console.print_debug("installer: cryptpad' startupmanager get zinit")
|
||||
return startupmanager.get(.zinit)!
|
||||
}
|
||||
.systemd {
|
||||
console.print_debug("installer: cryptpad' startupmanager get systemd")
|
||||
return startupmanager.get(.systemd)!
|
||||
}
|
||||
else {
|
||||
console.print_debug("installer: cryptpad' startupmanager get auto")
|
||||
return startupmanager.get(.auto)!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load from disk and make sure is properly intialized
|
||||
pub fn (mut self CryptPad) reload() ! {
|
||||
switch(self.name)
|
||||
self = obj_init(self)!
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) start() ! {
|
||||
switch(self.name)
|
||||
if self.running()! {
|
||||
return
|
||||
}
|
||||
|
||||
console.print_header('installer: cryptpad start')
|
||||
|
||||
if !installed()! {
|
||||
install()!
|
||||
}
|
||||
|
||||
configure()!
|
||||
|
||||
start_pre()!
|
||||
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
|
||||
console.print_debug('installer: cryptpad starting with ${zprocess.startuptype}...')
|
||||
|
||||
sm.new(zprocess)!
|
||||
|
||||
sm.start(zprocess.name)!
|
||||
}
|
||||
|
||||
start_post()!
|
||||
|
||||
for _ in 0 .. 50 {
|
||||
if self.running()! {
|
||||
return
|
||||
}
|
||||
time.sleep(100 * time.millisecond)
|
||||
}
|
||||
return error('cryptpad did not install properly.')
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) install_start(args InstallArgs) ! {
|
||||
switch(self.name)
|
||||
self.install(args)!
|
||||
self.start()!
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) stop() ! {
|
||||
switch(self.name)
|
||||
stop_pre()!
|
||||
for zprocess in startupcmd()! {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
sm.stop(zprocess.name)!
|
||||
}
|
||||
stop_post()!
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) restart() ! {
|
||||
switch(self.name)
|
||||
self.stop()!
|
||||
self.start()!
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) running() !bool {
|
||||
switch(self.name)
|
||||
|
||||
// walk over the generic processes, if not running return
|
||||
for zprocess in startupcmd()! {
|
||||
if zprocess.startuptype != .screen {
|
||||
mut sm := startupmanager_get(zprocess.startuptype)!
|
||||
r := sm.running(zprocess.name)!
|
||||
if r == false {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return running()!
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct InstallArgs {
|
||||
pub mut:
|
||||
reset bool
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) install(args InstallArgs) ! {
|
||||
switch(self.name)
|
||||
if args.reset || (!installed()!) {
|
||||
install()!
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) build() ! {
|
||||
switch(self.name)
|
||||
build()!
|
||||
}
|
||||
|
||||
pub fn (mut self CryptPad) destroy() ! {
|
||||
switch(self.name)
|
||||
self.stop() or {}
|
||||
destroy()!
|
||||
}
|
||||
|
||||
// switch instance to be used for cryptpad
|
||||
pub fn switch(name string) {
|
||||
cryptpad_default = name
|
||||
}
|
||||
52
lib/apps/biz/cryptpad/cryptpad_model.v
Normal file
52
lib/apps/biz/cryptpad/cryptpad_model.v
Normal file
@@ -0,0 +1,52 @@
|
||||
module cryptpad
|
||||
|
||||
import incubaid.herolib.data.paramsparser
|
||||
import incubaid.herolib.data.encoderhero
|
||||
import os
|
||||
|
||||
pub const version = '0.0.0'
|
||||
const singleton = false
|
||||
const default = true
|
||||
|
||||
// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
|
||||
@[heap]
|
||||
pub struct CryptPad {
|
||||
pub mut:
|
||||
name string = 'default'
|
||||
domain string
|
||||
domain_sandbox string
|
||||
configpath string //can be left empty, will be set to default path (is kubernetes config file)
|
||||
cryptpad_configpath string //can be left empty, will be set to default path
|
||||
masters []string //list of master servers for kubernetes
|
||||
domainname string //can be 1 name e.g. mycryptpad or it can be a fully qualified domain name e.g. mycryptpad.mycompany.com
|
||||
}
|
||||
|
||||
// your checking & initialization code if needed
|
||||
fn obj_init(mycfg_ CryptPad) !CryptPad {
|
||||
mut mycfg := mycfg_
|
||||
if mycfg.domain == '' {
|
||||
return error('CryptPad client "${mycfg.name}" missing domain')
|
||||
}
|
||||
if mycfg.configpath == '' {
|
||||
mycfg.configpath = '${os.home_dir()}/.apps/cryptpad/${mycfg.name}/config.yaml'
|
||||
}
|
||||
//call kubernetes client to get master nodes and put them in
|
||||
mycfg.masters = []string{} //TODO get from kubernetes
|
||||
return mycfg
|
||||
}
|
||||
|
||||
// called before start if done
|
||||
fn configure() ! {
|
||||
mut installer := get()!
|
||||
mut mycode := $tmpl('templates/main.yaml')
|
||||
mut path := pathlib.get_file(path: cfg.configpath, create: true)!
|
||||
path.write(mycode)!
|
||||
console.print_debug(mycode)
|
||||
}
|
||||
|
||||
/////////////NORMALLY NO NEED TO TOUCH
|
||||
|
||||
pub fn heroscript_loads(heroscript string) !CryptPad {
|
||||
mut obj := encoderhero.decode[CryptPad](heroscript)!
|
||||
return obj
|
||||
}
|
||||
44
lib/apps/biz/cryptpad/readme.md
Normal file
44
lib/apps/biz/cryptpad/readme.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# cryptpad
|
||||
|
||||
|
||||
|
||||
To get started
|
||||
|
||||
```v
|
||||
|
||||
|
||||
import incubaid.herolib.installers.something.cryptpad as cryptpad_installer
|
||||
|
||||
heroscript:="
|
||||
!!cryptpad.configure name:'test'
|
||||
password: '1234'
|
||||
port: 7701
|
||||
|
||||
!!cryptpad.start name:'test' reset:1
|
||||
"
|
||||
|
||||
cryptpad_installer.play(heroscript=heroscript)!
|
||||
|
||||
//or we can call the default and do a start with reset
|
||||
//mut installer:= cryptpad_installer.get()!
|
||||
//installer.start(reset:true)!
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
## example heroscript
|
||||
|
||||
|
||||
```hero
|
||||
!!cryptpad.configure
|
||||
homedir: '/home/user/cryptpad'
|
||||
username: 'admin'
|
||||
password: 'secretpassword'
|
||||
title: 'Some Title'
|
||||
host: 'localhost'
|
||||
port: 8888
|
||||
|
||||
```
|
||||
|
||||
127
lib/apps/biz/cryptpad/templates/cryptpad.yaml
Normal file
127
lib/apps/biz/cryptpad/templates/cryptpad.yaml
Normal file
@@ -0,0 +1,127 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: collab
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: cryptpad-config
|
||||
namespace: collab
|
||||
data:
|
||||
config.js: |
|
||||
module.exports = {
|
||||
httpUnsafeOrigin: 'https://cryptpadp2.gent01.grid.tf',
|
||||
httpSafeOrigin: 'https://cryptpads2.gent01.grid.tf',
|
||||
httpAddress: '0.0.0.0',
|
||||
httpPort: 3000,
|
||||
|
||||
websocketPort: 3003,
|
||||
websocketPath: '/cryptpad_websocket',
|
||||
|
||||
blockPath: './block',
|
||||
blobPath: './blob',
|
||||
dataPath: './data',
|
||||
filePath: './datastore',
|
||||
logToStdout: true,
|
||||
logLevel: 'info',
|
||||
};
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: cryptpad
|
||||
namespace: collab
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: { app: cryptpad }
|
||||
template:
|
||||
metadata:
|
||||
labels: { app: cryptpad }
|
||||
spec:
|
||||
initContainers:
|
||||
- name: fix-perms
|
||||
image: busybox:1.36
|
||||
command: ["/bin/sh","-lc"]
|
||||
args:
|
||||
- >
|
||||
chown -R 4001:4001
|
||||
/cryptpad/blob /cryptpad/block /cryptpad/data /cryptpad/datastore /cryptpad/customize || true
|
||||
volumeMounts:
|
||||
- { name: blob, mountPath: /cryptpad/blob }
|
||||
- { name: block, mountPath: /cryptpad/block }
|
||||
- { name: data, mountPath: /cryptpad/data }
|
||||
- { name: files, mountPath: /cryptpad/datastore }
|
||||
- { name: customize, mountPath: /cryptpad/customize }
|
||||
containers:
|
||||
- name: cryptpad
|
||||
image: cryptpad/cryptpad:latest
|
||||
ports:
|
||||
- { name: http, containerPort: 3000 }
|
||||
- { name: ws, containerPort: 3003 }
|
||||
env:
|
||||
- { name: CPAD_CONF, value: "/cryptpad/config/config.js" }
|
||||
- { name: CPAD_MAIN_DOMAIN, value: "https://cryptpadp2.gent01.grid.tf" }
|
||||
- { name: CPAD_SANDBOX_DOMAIN, value: "https://cryptpads2.gent01.grid.tf" }
|
||||
- { name: CPAD_INSTALL_ONLYOFFICE, value: "no" }
|
||||
readinessProbe:
|
||||
httpGet: { path: /, port: 3000 }
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
volumeMounts:
|
||||
- { name: cfg, mountPath: /cryptpad/config/config.js, subPath: config.js, readOnly: true }
|
||||
- { name: blob, mountPath: /cryptpad/blob }
|
||||
- { name: block, mountPath: /cryptpad/block }
|
||||
- { name: data, mountPath: /cryptpad/data }
|
||||
- { name: files, mountPath: /cryptpad/datastore }
|
||||
- { name: customize, mountPath: /cryptpad/customize }
|
||||
volumes:
|
||||
- name: cfg
|
||||
configMap:
|
||||
name: cryptpad-config
|
||||
items: [{ key: config.js, path: config.js }]
|
||||
- { name: blob, emptyDir: {} }
|
||||
- { name: block, emptyDir: {} }
|
||||
- { name: data, emptyDir: {} }
|
||||
- { name: files, emptyDir: {} }
|
||||
- { name: customize, emptyDir: {} }
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: cryptpad
|
||||
namespace: collab
|
||||
spec:
|
||||
selector: { app: cryptpad }
|
||||
ports:
|
||||
- { name: http, port: 3000, targetPort: 3000 }
|
||||
- { name: ws, port: 3003, targetPort: 3003 }
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: cryptpad
|
||||
namespace: collab
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: traefik
|
||||
spec:
|
||||
rules:
|
||||
- host: cryptpadp2.gent01.grid.tf
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend: { service: { name: cryptpad, port: { number: 3000 } } }
|
||||
- path: /cryptpad_websocket
|
||||
pathType: Prefix
|
||||
backend: { service: { name: cryptpad, port: { number: 3003 } } }
|
||||
- host: cryptpads2.gent01.grid.tf
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend: { service: { name: cryptpad, port: { number: 3000 } } }
|
||||
- path: /cryptpad_websocket
|
||||
pathType: Prefix
|
||||
backend: { service: { name: cryptpad, port: { number: 3003 } } }
|
||||
28
lib/apps/biz/cryptpad/templates/tfgw-cryptpad.yaml
Normal file
28
lib/apps/biz/cryptpad/templates/tfgw-cryptpad.yaml
Normal file
@@ -0,0 +1,28 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: collab
|
||||
---
|
||||
apiVersion: ingress.grid.tf/v1
|
||||
kind: TFGW
|
||||
metadata:
|
||||
name: cryptpad-main
|
||||
namespace: collab
|
||||
spec:
|
||||
hostname: "cryptpadp2"
|
||||
backends:
|
||||
- "http://[49a:bfc3:59bf:872c:ff0f:d25f:751c:5106]:80"
|
||||
- "http://[53c:609e:6488:9ddd:ff0f:2ffc:ac2a:94a6]:80"
|
||||
- "http://[58e:ca1d:ce3d:355c:ff0f:a065:a40a:a08c]:80"
|
||||
---
|
||||
apiVersion: ingress.grid.tf/v1
|
||||
kind: TFGW
|
||||
metadata:
|
||||
name: cryptpad-sandbox
|
||||
namespace: collab
|
||||
spec:
|
||||
hostname: "cryptpads2"
|
||||
backends:
|
||||
- "http://[49a:bfc3:59bf:872c:ff0f:d25f:751c:5106]:80"
|
||||
- "http://[53c:609e:6488:9ddd:ff0f:2ffc:ac2a:94a6]:80"
|
||||
- "http://[58e:ca1d:ce3d:355c:ff0f:a065:a40a:a08c]:80"
|
||||
@@ -7,6 +7,23 @@ import incubaid.herolib.ui.console
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
@[params]
|
||||
pub struct KubectlExecArgs {
|
||||
pub mut:
|
||||
command string
|
||||
timeout int = 30
|
||||
retry int = 0
|
||||
}
|
||||
|
||||
pub struct KubectlResult {
|
||||
pub mut:
|
||||
exit_code int
|
||||
stdout string
|
||||
stderr string
|
||||
success bool
|
||||
}
|
||||
|
||||
// Execute kubectl command with proper error handling
|
||||
pub fn (mut k KubeClient) kubectl_exec(args KubectlExecArgs) !KubectlResult {
|
||||
mut cmd := 'kubectl'
|
||||
@@ -42,21 +59,6 @@ pub fn (mut k KubeClient) kubectl_exec(args KubectlExecArgs) !KubectlResult {
|
||||
}
|
||||
}
|
||||
|
||||
@[params]
|
||||
pub struct KubectlExecArgs {
|
||||
pub mut:
|
||||
command string
|
||||
timeout int = 30
|
||||
retry int = 0
|
||||
}
|
||||
|
||||
pub struct KubectlResult {
|
||||
pub mut:
|
||||
exit_code int
|
||||
stdout string
|
||||
stderr string
|
||||
success bool
|
||||
}
|
||||
|
||||
// Test connection to cluster
|
||||
pub fn (mut k KubeClient) test_connection() !bool {
|
||||
|
||||
Reference in New Issue
Block a user