This commit is contained in:
2025-10-29 09:25:55 +04:00
parent c5f1d39958
commit 8583238fdb
71 changed files with 603 additions and 285 deletions

View File

@@ -4,68 +4,25 @@ module main
import incubaid.herolib.clients.openai
import os
import incubaid.herolib.core.playcmds
fn test1(mut client openai.OpenAI) ! {
instruction := '
You are a template language converter. You convert Pug templates to Jet templates.
The target template language, Jet, is defined as follows:
playcmds.run(
heroscript: '
!!openai.configure name:"qroq"
url:"https://api.groq.com/openai/v1"
model_default:"gpt-oss-120b"
'
// Create a chat completion request
res := client.chat_completion(
msgs: openai.Messages{
messages: [
openai.Message{
role: .user
content: 'What are the key differences between Groq and other AI inference providers?'
},
]
}
reset: true
)!
// Print the response
println('\nGroq AI Response:')
println('==================')
println(res.choices[0].message.content)
println('\nUsage Statistics:')
println('Prompt tokens: ${res.usage.prompt_tokens}')
println('Completion tokens: ${res.usage.completion_tokens}')
println('Total tokens: ${res.usage.total_tokens}')
}
mut client := openai.get(name: 'groq')!
fn test2(mut client openai.OpenAI) ! {
// Create a chat completion request
res := client.chat_completion(
model: 'deepseek-r1-distill-llama-70b'
msgs: openai.Messages{
messages: [
openai.Message{
role: .user
content: 'A story of 10 lines?'
},
]
}
response := client.chat_completion(
message: 'Explain quantum computing in simple terms'
temperature: 0.5
max_completion_tokens: 1024
)!
println('\nGroq AI Response:')
println('==================')
println(res.choices[0].message.content)
println('\nUsage Statistics:')
println('Prompt tokens: ${res.usage.prompt_tokens}')
println('Completion tokens: ${res.usage.completion_tokens}')
println('Total tokens: ${res.usage.total_tokens}')
}
println(response.result)
println("
TO USE:
export AIKEY='gsk_...'
export AIURL='https://api.groq.com/openai/v1'
export AIMODEL='llama-3.3-70b-versatile'
")
mut client := openai.get(name: 'test')!
println(client)
// test1(mut client)!
test2(mut client)!

View File

@@ -2,7 +2,7 @@
import incubaid.herolib.clients.jina
mut jina_client := jina.get()!
mut jina_client := jina.new()!
health := jina_client.health()!
println('Server health: ${health}')
@@ -34,7 +34,7 @@ train_result := jina_client.train(
label: 'positive'
},
jina.TrainingExample{
image: 'https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg'
image: 'https://picsum.photos/id/11/367/267'
label: 'negative'
},
]
@@ -50,7 +50,7 @@ classify_result := jina_client.classify(
text: 'A photo of a cat'
},
jina.ClassificationInput{
image: 'https://letsenhance.io/static/73136da51c245e80edc6ccfe44888a99/1015f/MainBefore.jpg'
image: 'https://picsum.photos/id/11/367/267'
},
]
labels: ['cat', 'dog']

View File

@@ -1,50 +0,0 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
import incubaid.herolib.clients.jina
import os
import json
fn main() {
// Initialize Jina client
mut j := jina.Jina{
name: 'test_client'
secret: os.getenv('JINAKEY')
}
// Initialize the client
j = jina.obj_init(j) or {
println('Error initializing Jina client: ${err}')
return
}
// Check if authentication works
auth_ok := j.check_auth() or {
println('Authentication failed: ${err}')
return
}
println('Authentication successful: ${auth_ok}')
// Create embeddings
model := 'jina-embeddings-v2-base-en'
input := ['Hello world', 'This is a test']
embeddings := j.create_embeddings(input, model, 'search') or {
println('Error creating embeddings: ${err}')
return
}
println('Embeddings created successfully!')
println('Model: ${embeddings.model}')
println('Dimension: ${embeddings.dimension}')
println('Number of embeddings: ${embeddings.data.len}')
// If there are embeddings, print the first one (truncated)
if embeddings.data.len > 0 {
first_embedding := embeddings.data[0]
println('First embedding (first 5 values): ${first_embedding.embedding[0..5]}')
}
// Usage information
println('Token usage: ${embeddings.usage.total_tokens} ${embeddings.usage.unit}')
}

30
examples/ai/jina_simple.vsh Executable file
View File

@@ -0,0 +1,30 @@
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
import incubaid.herolib.clients.jina
import os
import json
mut j := jina.new()!
embeddings := j.create_embeddings(
input: ['Hello world', 'This is a test']
model: .jina_embeddings_v3
task: 'separation'
) or {
println('Error creating embeddings: ${err}')
return
}
println('Embeddings created successfully!')
println('Model: ${embeddings.model}')
println('Dimension: ${embeddings.dimension}')
println('Number of embeddings: ${embeddings.data.len}')
// If there are embeddings, print the first one (truncated)
if embeddings.data.len > 0 {
first_embedding := embeddings.data[0]
println('First embedding (first 5 values): ${first_embedding.embedding[0..5]}')
}
// Usage information
println('Token usage: ${embeddings.usage.total_tokens} ${embeddings.usage.unit}')

9
examples/ai/readme.md Normal file
View File

@@ -0,0 +1,9 @@
configuration can happen by means of environment variables, e.g.:
```bash
export OPENROUTER_API_KEY='sk-or-v1-..'
export JINAKEY='jina_..'
export GROQKEY='gsk_'
```

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&ERPNext {
data := r.hget('context:erpnext', args.name)!
if data.len == 0 {
print_backtrace()
return error('ERPNext with name: erpnext does not exist, prob bug.')
return error('ERPNext with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(ERPNext, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&ERPNext {
new(args)!
} else {
print_backtrace()
return error("ERPNext with name 'erpnext' does not exist")
return error("ERPNext with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return erpnext_global[args.name] or {
print_backtrace()
return error('could not get config for erpnext with name:erpnext')
return error('could not get config for erpnext with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&GiteaClient {
data := r.hget('context:giteaclient', args.name)!
if data.len == 0 {
print_backtrace()
return error('GiteaClient with name: giteaclient does not exist, prob bug.')
return error('GiteaClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(GiteaClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&GiteaClient {
new(args)!
} else {
print_backtrace()
return error("GiteaClient with name 'giteaclient' does not exist")
return error("GiteaClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return giteaclient_global[args.name] or {
print_backtrace()
return error('could not get config for giteaclient with name:giteaclient')
return error('could not get config for giteaclient with name:${args.name}')
}
}

View File

@@ -2,6 +2,7 @@ module ipapi
import incubaid.herolib.core.base
import incubaid.herolib.core.playbook { PlayBook }
import incubaid.herolib.ui.console
import json
__global (
@@ -36,7 +37,7 @@ pub fn get(args ArgsGet) !&IPApi {
data := r.hget('context:ipapi', args.name)!
if data.len == 0 {
print_backtrace()
return error('IPApi with name: ipapi does not exist, prob bug.')
return error('IPApi with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(IPApi, data)!
set_in_mem(obj)!
@@ -45,14 +46,14 @@ pub fn get(args ArgsGet) !&IPApi {
new(args)!
} else {
print_backtrace()
return error("IPApi with name 'ipapi' does not exist")
return error("IPApi with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return ipapi_global[args.name] or {
print_backtrace()
return error('could not get config for ipapi with name:ipapi')
return error('could not get config for ipapi with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&Jina {
data := r.hget('context:jina', args.name)!
if data.len == 0 {
print_backtrace()
return error('Jina with name: jina does not exist, prob bug.')
return error('Jina with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(Jina, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&Jina {
new(args)!
} else {
print_backtrace()
return error("Jina with name 'jina' does not exist")
return error("Jina with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return jina_global[args.name] or {
print_backtrace()
return error('could not get config for jina with name:jina')
return error('could not get config for jina with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&MailClient {
data := r.hget('context:mailclient', args.name)!
if data.len == 0 {
print_backtrace()
return error('MailClient with name: mailclient does not exist, prob bug.')
return error('MailClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(MailClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&MailClient {
new(args)!
} else {
print_backtrace()
return error("MailClient with name 'mailclient' does not exist")
return error("MailClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return mailclient_global[args.name] or {
print_backtrace()
return error('could not get config for mailclient with name:mailclient')
return error('could not get config for mailclient with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&MeilisearchClient {
data := r.hget('context:meilisearch', args.name)!
if data.len == 0 {
print_backtrace()
return error('MeilisearchClient with name: meilisearch does not exist, prob bug.')
return error('MeilisearchClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(MeilisearchClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&MeilisearchClient {
new(args)!
} else {
print_backtrace()
return error("MeilisearchClient with name 'meilisearch' does not exist")
return error("MeilisearchClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return meilisearch_global[args.name] or {
print_backtrace()
return error('could not get config for meilisearch with name:meilisearch')
return error('could not get config for meilisearch with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&Mycelium {
data := r.hget('context:mycelium', args.name)!
if data.len == 0 {
print_backtrace()
return error('Mycelium with name: mycelium does not exist, prob bug.')
return error('Mycelium with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(Mycelium, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&Mycelium {
new(args)!
} else {
print_backtrace()
return error("Mycelium with name 'mycelium' does not exist")
return error("Mycelium with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return mycelium_global[args.name] or {
print_backtrace()
return error('could not get config for mycelium with name:mycelium')
return error('could not get config for mycelium with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&MyceliumRPC {
data := r.hget('context:mycelium_rpc', args.name)!
if data.len == 0 {
print_backtrace()
return error('MyceliumRPC with name: mycelium_rpc does not exist, prob bug.')
return error('MyceliumRPC with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(MyceliumRPC, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&MyceliumRPC {
new(args)!
} else {
print_backtrace()
return error("MyceliumRPC with name 'mycelium_rpc' does not exist")
return error("MyceliumRPC with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return mycelium_rpc_global[args.name] or {
print_backtrace()
return error('could not get config for mycelium_rpc with name:mycelium_rpc')
return error('could not get config for mycelium_rpc with name:${args.name}')
}
}

View File

@@ -12,8 +12,8 @@ pub mut:
max_completion_tokens int = 32000
}
struct Message {
mut:
pub struct Message {
pub mut:
role RoleType
content string
}
@@ -42,15 +42,15 @@ fn roletype_str(x RoleType) string {
}
}
struct Usage {
mut:
pub struct Usage {
pub mut:
prompt_tokens int
completion_tokens int
total_tokens int
}
struct ChatCompletion {
mut:
pub struct ChatCompletion {
pub mut:
id string
created u32
result string

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&OpenAI {
data := r.hget('context:openai', args.name)!
if data.len == 0 {
print_backtrace()
return error('OpenAI with name: openai does not exist, prob bug.')
return error('OpenAI with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(OpenAI, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&OpenAI {
new(args)!
} else {
print_backtrace()
return error("OpenAI with name 'openai' does not exist")
return error("OpenAI with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return openai_global[args.name] or {
print_backtrace()
return error('could not get config for openai with name:openai')
return error('could not get config for openai with name:${args.name}')
}
}

View File

@@ -45,6 +45,12 @@ fn obj_init(mycfg_ OpenAI) !OpenAI {
mycfg.api_key = k2
}
}
if mycfg.url.contains('groq') {
k2 := os.getenv('GROQKEY')
if k2 != '' {
mycfg.api_key = k2
}
}
}
if mycfg.api_key == '' {
return error('OpenAI client "${mycfg.name}" missing api_key')

View File

@@ -1,8 +1,74 @@
# openai
To get started
The OpenAI client library provides a comprehensive interface for interacting with OpenAI and OpenAI-compatible APIs (like OpenRouter and Groq).
## Quick Start
### Using Environment Variables
The easiest way to configure the OpenAI client is through environment variables:
```bash
export AIKEY='your-api-key-here'
export AIURL='https://api.openai.com/v1' # optional, defaults to OpenRouter
export AIMODEL='gpt-4o' # optional, sets default model
```
Supported environment variables:
- `AIKEY` - Your API key (fallback for all providers)
- `AIURL` - The API base URL
- `AIMODEL` - Default model to use
- `OPENROUTER_API_KEY` - OpenRouter specific API key (preferred for OpenRouter)
- `GROQKEY` - Groq specific API key (preferred for Groq)
### Basic Usage
```v
import incubaid.herolib.clients.openai
// Get the default client (uses AIKEY from environment)
mut client := openai.get()!
// Send a simple message
response := client.chat_completion(
message: 'Hello, world!'
temperature: 0.7
max_completion_tokens: 1024
)!
println(response.result)
```
## Configuration with HeroScript
For more control, use HeroScript configuration:
```v
import incubaid.herolib.clients.openai
import incubaid.herolib.core.playcmds
playcmds.run(
heroscript: '
!!openai.configure name:"default"
url:"https://openrouter.ai/api/v1"
api_key:"sk-or-v1-..."
model_default:"gpt-oss-120b"
'
reset: false
)!
mut client := openai.get()!
```
in case of using heroscript, we don't have to fill in the api_key it will be loaded from the environment variable `OPENROUTER_API_KEY` or `GROQKEY` depending on the url used.
## Examples
### Using OpenRouter
```v
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
import incubaid.herolib.clients.openai
import incubaid.herolib.core.playcmds
@@ -10,23 +76,321 @@ import incubaid.herolib.core.playcmds
playcmds.run(
heroscript: '
!!openai.configure name:"default"
key:"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"
url:"https://openrouter.ai/api/v1"
model_default:"gpt-oss-120b"
'
reset: false
)!
//name:'default' is the default, you can change it to whatever you want
mut client := openai.get()!
mut r:=client.chat_completion(
model: "gpt-3.5-turbo",
message: 'Hello, world!'
response := client.chat_completion(
model: 'qwen/qwen-2.5-coder-32b-instruct'
message: 'Write a hello world program in V'
temperature: 0.7
max_completion_tokens: 500
)!
println('Response:')
println(response.result)
println('Tokens used: ${response.usage.total_tokens}')
```
### Using Groq
```bash
export GROQKEY='gsk_...'
```v
import incubaid.herolib.clients.openai
import incubaid.herolib.core.playcmds
playcmds.run(
heroscript: '
!!openai.configure name:"qroq"
url:"https://api.groq.com/openai/v1"
model_default:"gpt-oss-120b"
'
reset: true
)!
mut client := openai.get(name:"groq")!
response := client.chat_completion(
message: 'Explain quantum computing in simple terms'
temperature: 0.5
max_completion_tokens: 1024
)!
println(response.result)
```
if key empty then will try to get it from environment variable `AIKEY` or `OPENROUTER_API_KEY`
## Chat Completion
### Simple Message
```v
mut client := openai.get()!
response := client.chat_completion(
message: 'What is 2 + 2?'
)!
println(response.result)
```
### Multi-Message Conversation
```v
response := client.chat_completion(
model: 'gpt-4o'
messages: [
Message{
role: .system
content: 'You are a helpful programming assistant.'
},
Message{
role: .user
content: 'How do I read a file in V?'
},
]
temperature: 0.7
max_completion_tokens: 2048
)!
println(response.result)
```
## Features
- **Chat Completions** - Generate text responses
- **Image Generation** - Create, edit, and generate variations of images
- **Audio** - Transcribe and translate audio files
- **Embeddings** - Generate text embeddings
- **File Management** - Upload and manage files for fine-tuning
- **Fine-tuning** - Create and manage fine-tuned models
- **Content Moderation** - Check content for policy violations
- **Multiple Providers** - Works with OpenAI, OpenRouter, Groq, and compatible APIs
## Advanced Usage: Coding Agent
Here's an example of building a coding assistant agent:
```v
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
import incubaid.herolib.clients.openai
import incubaid.herolib.ui.console
import incubaid.herolib.core.texttools
fn analyze_code(mut client openai.OpenAI, code string) !string {
response := client.chat_completion(
messages: [
openai.Message{
role: .system
content: 'You are an expert code analyzer. Analyze code and provide:
1. Code quality issues
2. Performance suggestions
3. Security concerns
4. Refactoring recommendations'
},
openai.Message{
role: .user
content: 'Analyze this code:\n\`\`\`\n${code}\n\`\`\`'
},
]
temperature: 0.3
max_completion_tokens: 2048
)!
return response.result
}
fn generate_code(mut client openai.OpenAI, requirement string, language string) !string {
response := client.chat_completion(
messages: [
openai.Message{
role: .system
content: 'You are an expert ${language} programmer. Generate clean, efficient,
well-documented code. Include comments and error handling.'
},
openai.Message{
role: .user
content: 'Generate ${language} code for: ${requirement}'
},
]
temperature: 0.5
max_completion_tokens: 2048
)!
return response.result
}
fn test_code(mut client openai.OpenAI, code string, language string) !string {
response := client.chat_completion(
messages: [
openai.Message{
role: .system
content: 'You are an expert ${language} test engineer. Generate comprehensive
unit tests with good coverage.'
},
openai.Message{
role: .user
content: 'Write tests for this ${language} code:\n\`\`\`\n${code}\n\`\`\`'
},
]
temperature: 0.4
max_completion_tokens: 2048
)!
return response.result
}
fn refactor_code(mut client openai.OpenAI, code string, language string) !string {
response := client.chat_completion(
messages: [
openai.Message{
role: .system
content: 'You are an expert code refactorer. Improve code readability,
maintainability, and follow best practices for ${language}.'
},
openai.Message{
role: .user
content: 'Refactor this ${language} code:\n\`\`\`\n${code}\n\`\`\`'
},
]
temperature: 0.3
max_completion_tokens: 2048
)!
return response.result
}
// Main coding agent loop
fn main() ! {
mut client := openai.get()!
mut console := console.new()
println('═'.repeat(60))
println(' Coding Agent - Your AI Programming Assistant')
println('═'.repeat(60))
loop {
action := console.ask_dropdown(
description: 'What would you like to do?'
items: ['Generate Code', 'Analyze Code', 'Generate Tests', 'Refactor Code', 'Exit']
)!
match action {
'Generate Code' {
requirement := console.ask_question(
description: 'Code Generation'
question: 'What code do you need? (describe the requirement)'
)!
language := console.ask_dropdown(
description: 'Programming Language'
items: ['V', 'Python', 'JavaScript', 'Rust', 'Go', 'C++']
)!
println('\n⏳ Generating code...\n')
generated := generate_code(mut client, requirement, language)!
console.cprint(
text: generated
foreground: .green
)
}
'Analyze Code' {
code := console.ask_question(
description: 'Code Analysis'
question: 'Paste your code (can be multiline):'
)!
println('\n⏳ Analyzing code...\n')
analysis := analyze_code(mut client, code)!
console.cprint(
text: analysis
foreground: .cyan
)
}
'Generate Tests' {
code := console.ask_question(
description: 'Test Generation'
question: 'Paste your code:'
)!
language := console.ask_dropdown(
description: 'Programming Language'
items: ['V', 'Python', 'JavaScript', 'Rust', 'Go', 'C++']
)!
println('\n⏳ Generating tests...\n')
tests := test_code(mut client, code, language)!
console.cprint(
text: tests
foreground: .yellow
)
}
'Refactor Code' {
code := console.ask_question(
description: 'Code Refactoring'
question: 'Paste your code:'
)!
language := console.ask_dropdown(
description: 'Programming Language'
items: ['V', 'Python', 'JavaScript', 'Rust', 'Go', 'C++']
)!
println('\n⏳ Refactoring code...\n')
refactored := refactor_code(mut client, code, language)!
console.cprint(
text: refactored
foreground: .green
)
}
'Exit' {
println('\n👋 Goodbye!')
break
}
else {
println('Invalid option')
}
}
println('\n')
}
}
```
## Configuration Details
Refer to `openai_model.v` for implementation details:
- **API Key Fallback Chain**: `api_key``AIKEY``OPENROUTER_API_KEY` / `GROQKEY`
- **URL Fallback**: Defaults to OpenRouter if not specified
- **Model Fallback**: Uses `AIMODEL` environment variable if not set
- **Validation**: Ensures API key is present before returning client
## Error Handling
```v
mut client := openai.get() or {
eprintln('Failed to initialize client: ${err}')
return
}
response := client.chat_completion(
message: 'Hello'
) or {
eprintln('API request failed: ${err}')
return
}
```
## Supported Providers
- **OpenAI** - `https://api.openai.com/v1`
- **OpenRouter** - `https://openrouter.ai/api/v1` (default)
- **Groq** - `https://api.groq.com/openai/v1`
- **Compatible APIs** - Any OpenAI-compatible endpoint

View File

@@ -95,4 +95,3 @@ pub fn (mut f OpenRouter) chat_completion(args_ CompletionArgs) !ChatCompletion
}
return chat_completion_result
}

View File

@@ -2,6 +2,7 @@ module openrouter
import incubaid.herolib.core.base
import incubaid.herolib.core.playbook { PlayBook }
import incubaid.herolib.ui.console
import json
__global (
@@ -36,7 +37,7 @@ pub fn get(args ArgsGet) !&OpenRouter {
data := r.hget('context:openrouter', args.name)!
if data.len == 0 {
print_backtrace()
return error('OpenRouter with name: openrouter does not exist, prob bug.')
return error('OpenRouter with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(OpenRouter, data)!
set_in_mem(obj)!
@@ -45,14 +46,14 @@ pub fn get(args ArgsGet) !&OpenRouter {
new(args)!
} else {
print_backtrace()
return error("OpenRouter with name 'openrouter' does not exist")
return error("OpenRouter with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return openrouter_global[args.name] or {
print_backtrace()
return error('could not get config for openrouter with name:openrouter')
return error('could not get config for openrouter with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&PostgresqlClient {
data := r.hget('context:postgresql_client', args.name)!
if data.len == 0 {
print_backtrace()
return error('PostgresqlClient with name: postgresql_client does not exist, prob bug.')
return error('PostgresqlClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(PostgresqlClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&PostgresqlClient {
new(args)!
} else {
print_backtrace()
return error("PostgresqlClient with name 'postgresql_client' does not exist")
return error("PostgresqlClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return postgresql_client_global[args.name] or {
print_backtrace()
return error('could not get config for postgresql_client with name:postgresql_client')
return error('could not get config for postgresql_client with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&QDrantClient {
data := r.hget('context:qdrant', args.name)!
if data.len == 0 {
print_backtrace()
return error('QDrantClient with name: qdrant does not exist, prob bug.')
return error('QDrantClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(QDrantClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&QDrantClient {
new(args)!
} else {
print_backtrace()
return error("QDrantClient with name 'qdrant' does not exist")
return error("QDrantClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return qdrant_global[args.name] or {
print_backtrace()
return error('could not get config for qdrant with name:qdrant')
return error('could not get config for qdrant with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&RCloneClient {
data := r.hget('context:rclone', args.name)!
if data.len == 0 {
print_backtrace()
return error('RCloneClient with name: rclone does not exist, prob bug.')
return error('RCloneClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(RCloneClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&RCloneClient {
new(args)!
} else {
print_backtrace()
return error("RCloneClient with name 'rclone' does not exist")
return error("RCloneClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return rclone_global[args.name] or {
print_backtrace()
return error('could not get config for rclone with name:rclone')
return error('could not get config for rclone with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&RunPod {
data := r.hget('context:runpod', args.name)!
if data.len == 0 {
print_backtrace()
return error('RunPod with name: runpod does not exist, prob bug.')
return error('RunPod with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(RunPod, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&RunPod {
new(args)!
} else {
print_backtrace()
return error("RunPod with name 'runpod' does not exist")
return error("RunPod with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return runpod_global[args.name] or {
print_backtrace()
return error('could not get config for runpod with name:runpod')
return error('could not get config for runpod with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&SendGrid {
data := r.hget('context:sendgrid', args.name)!
if data.len == 0 {
print_backtrace()
return error('SendGrid with name: sendgrid does not exist, prob bug.')
return error('SendGrid with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(SendGrid, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&SendGrid {
new(args)!
} else {
print_backtrace()
return error("SendGrid with name 'sendgrid' does not exist")
return error("SendGrid with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return sendgrid_global[args.name] or {
print_backtrace()
return error('could not get config for sendgrid with name:sendgrid')
return error('could not get config for sendgrid with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&VastAI {
data := r.hget('context:vastai', args.name)!
if data.len == 0 {
print_backtrace()
return error('VastAI with name: vastai does not exist, prob bug.')
return error('VastAI with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(VastAI, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&VastAI {
new(args)!
} else {
print_backtrace()
return error("VastAI with name 'vastai' does not exist")
return error("VastAI with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return vastai_global[args.name] or {
print_backtrace()
return error('could not get config for vastai with name:vastai')
return error('could not get config for vastai with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&WireGuard {
data := r.hget('context:wireguard', args.name)!
if data.len == 0 {
print_backtrace()
return error('WireGuard with name: wireguard does not exist, prob bug.')
return error('WireGuard with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(WireGuard, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&WireGuard {
new(args)!
} else {
print_backtrace()
return error("WireGuard with name 'wireguard' does not exist")
return error("WireGuard with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return wireguard_global[args.name] or {
print_backtrace()
return error('could not get config for wireguard with name:wireguard')
return error('could not get config for wireguard with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&ZeroDBClient {
data := r.hget('context:zerodb_client', args.name)!
if data.len == 0 {
print_backtrace()
return error('ZeroDBClient with name: zerodb_client does not exist, prob bug.')
return error('ZeroDBClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(ZeroDBClient, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&ZeroDBClient {
new(args)!
} else {
print_backtrace()
return error("ZeroDBClient with name 'zerodb_client' does not exist")
return error("ZeroDBClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return zerodb_client_global[args.name] or {
print_backtrace()
return error('could not get config for zerodb_client with name:zerodb_client')
return error('could not get config for zerodb_client with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&ZinitRPC {
data := r.hget('context:zinit', args.name)!
if data.len == 0 {
print_backtrace()
return error('ZinitRPC with name: zinit does not exist, prob bug.')
return error('ZinitRPC with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(ZinitRPC, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&ZinitRPC {
new(args)!
} else {
print_backtrace()
return error("ZinitRPC with name 'zinit' does not exist")
return error("ZinitRPC with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return zinit_global[args.name] or {
print_backtrace()
return error('could not get config for zinit with name:zinit')
return error('could not get config for zinit with name:${args.name}')
}
}

View File

@@ -55,7 +55,7 @@ pub fn get(args ArgsGet) !&${args.classname} {
data := r.hget('context:${args.name}', args.name)!
if data.len == 0 {
print_backtrace()
return error('${args.classname} with name: ${args.name} does not exist, prob bug.')
return error('${args.classname} with name: ??{args.name} does not exist, prob bug.')
}
mut obj := json.decode(${args.classname},data)!
set_in_mem(obj)!
@@ -64,14 +64,14 @@ pub fn get(args ArgsGet) !&${args.classname} {
new(args)!
}else{
print_backtrace()
return error("${args.classname} with name '${args.name}' does not exist")
return error("${args.classname} with name '??{args.name}' does not exist")
}
}
return get(name: args.name)! //no longer from db nor create
}
return ${args.name}_global[args.name] or {
print_backtrace()
return error('could not get config for ${args.name} with name:${args.name}')
return error('could not get config for ${args.name} with name:??{args.name}')
}
}
@@ -163,7 +163,7 @@ pub fn play(mut plbook PlayBook) ! {
install_action.done = true
}
@else
return error("can't configure ${args.name}, because no configuration allowed for this installer.")
return error("can't configure ${args.name}:??{args.name}, because no configuration allowed for this installer.")
@end
}
@if args.cat == .installer

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&Workspace {
data := r.hget('context:heroprompt', args.name)!
if data.len == 0 {
print_backtrace()
return error('Workspace with name: heroprompt does not exist, prob bug.')
return error('Workspace with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(Workspace, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&Workspace {
new(args)!
} else {
print_backtrace()
return error("Workspace with name 'heroprompt' does not exist")
return error("Workspace with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return heroprompt_global[args.name] or {
print_backtrace()
return error('could not get config for heroprompt with name:heroprompt')
return error('could not get config for heroprompt with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&CometBFT {
data := r.hget('context:cometbft', args.name)!
if data.len == 0 {
print_backtrace()
return error('CometBFT with name: cometbft does not exist, prob bug.')
return error('CometBFT with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(CometBFT, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&CometBFT {
new(args)!
} else {
print_backtrace()
return error("CometBFT with name 'cometbft' does not exist")
return error("CometBFT with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return cometbft_global[args.name] or {
print_backtrace()
return error('could not get config for cometbft with name:cometbft')
return error('could not get config for cometbft with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&MeilisearchInstaller {
data := r.hget('context:meilisearch_installer', args.name)!
if data.len == 0 {
print_backtrace()
return error('MeilisearchInstaller with name: meilisearch_installer does not exist, prob bug.')
return error('MeilisearchInstaller with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(MeilisearchInstaller, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&MeilisearchInstaller {
new(args)!
} else {
print_backtrace()
return error("MeilisearchInstaller with name 'meilisearch_installer' does not exist")
return error("MeilisearchInstaller with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return meilisearch_installer_global[args.name] or {
print_backtrace()
return error('could not get config for meilisearch_installer with name:meilisearch_installer')
return error('could not get config for meilisearch_installer with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&Postgresql {
data := r.hget('context:postgresql', args.name)!
if data.len == 0 {
print_backtrace()
return error('Postgresql with name: postgresql does not exist, prob bug.')
return error('Postgresql with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(Postgresql, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&Postgresql {
new(args)!
} else {
print_backtrace()
return error("Postgresql with name 'postgresql' does not exist")
return error("Postgresql with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return postgresql_global[args.name] or {
print_backtrace()
return error('could not get config for postgresql with name:postgresql')
return error('could not get config for postgresql with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&QDrant {
data := r.hget('context:qdrant_installer', args.name)!
if data.len == 0 {
print_backtrace()
return error('QDrant with name: qdrant_installer does not exist, prob bug.')
return error('QDrant with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(QDrant, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&QDrant {
new(args)!
} else {
print_backtrace()
return error("QDrant with name 'qdrant_installer' does not exist")
return error("QDrant with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return qdrant_installer_global[args.name] or {
print_backtrace()
return error('could not get config for qdrant_installer with name:qdrant_installer')
return error('could not get config for qdrant_installer with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&ZeroDB {
data := r.hget('context:zerodb', args.name)!
if data.len == 0 {
print_backtrace()
return error('ZeroDB with name: zerodb does not exist, prob bug.')
return error('ZeroDB with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(ZeroDB, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&ZeroDB {
new(args)!
} else {
print_backtrace()
return error("ZeroDB with name 'zerodb' does not exist")
return error("ZeroDB with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return zerodb_global[args.name] or {
print_backtrace()
return error('could not get config for zerodb with name:zerodb')
return error('could not get config for zerodb with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&CoreDNS {
data := r.hget('context:coredns', args.name)!
if data.len == 0 {
print_backtrace()
return error('CoreDNS with name: coredns does not exist, prob bug.')
return error('CoreDNS with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(CoreDNS, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&CoreDNS {
new(args)!
} else {
print_backtrace()
return error("CoreDNS with name 'coredns' does not exist")
return error("CoreDNS with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return coredns_global[args.name] or {
print_backtrace()
return error('could not get config for coredns with name:coredns')
return error('could not get config for coredns with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&GiteaServer {
data := r.hget('context:gitea', args.name)!
if data.len == 0 {
print_backtrace()
return error('GiteaServer with name: gitea does not exist, prob bug.')
return error('GiteaServer with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(GiteaServer, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&GiteaServer {
new(args)!
} else {
print_backtrace()
return error("GiteaServer with name 'gitea' does not exist")
return error("GiteaServer with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return gitea_global[args.name] or {
print_backtrace()
return error('could not get config for gitea with name:gitea')
return error('could not get config for gitea with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&LivekitServer {
data := r.hget('context:livekit', args.name)!
if data.len == 0 {
print_backtrace()
return error('LivekitServer with name: livekit does not exist, prob bug.')
return error('LivekitServer with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(LivekitServer, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&LivekitServer {
new(args)!
} else {
print_backtrace()
return error("LivekitServer with name 'livekit' does not exist")
return error("LivekitServer with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return livekit_global[args.name] or {
print_backtrace()
return error('could not get config for livekit with name:livekit')
return error('could not get config for livekit with name:${args.name}')
}
}

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'zinit_installer.configure')!
if install_actions.len > 0 {
return error("can't configure zinit_installer, because no configuration allowed for this installer.")
return error("can't configure zinit_installer:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'zinit_installer.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'golang.configure')!
if install_actions.len > 0 {
return error("can't configure golang, because no configuration allowed for this installer.")
return error("can't configure golang:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'golang.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'nodejs.configure')!
if install_actions.len > 0 {
return error("can't configure nodejs, because no configuration allowed for this installer.")
return error("can't configure nodejs:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'nodejs.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'python.configure')!
if install_actions.len > 0 {
return error("can't configure python, because no configuration allowed for this installer.")
return error("can't configure python:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'python.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'rust.configure')!
if install_actions.len > 0 {
return error("can't configure rust, because no configuration allowed for this installer.")
return error("can't configure rust:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'rust.')!
for mut other_action in other_actions {

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&MyceliumInstaller {
data := r.hget('context:mycelium_installer', args.name)!
if data.len == 0 {
print_backtrace()
return error('MyceliumInstaller with name: mycelium_installer does not exist, prob bug.')
return error('MyceliumInstaller with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(MyceliumInstaller, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&MyceliumInstaller {
new(args)!
} else {
print_backtrace()
return error("MyceliumInstaller with name 'mycelium_installer' does not exist")
return error("MyceliumInstaller with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return mycelium_installer_global[args.name] or {
print_backtrace()
return error('could not get config for mycelium_installer with name:mycelium_installer')
return error('could not get config for mycelium_installer with name:${args.name}')
}
}

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'wireguard_installer.configure')!
if install_actions.len > 0 {
return error("can't configure wireguard_installer, because no configuration allowed for this installer.")
return error("can't configure wireguard_installer:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'wireguard_installer.')!
for mut other_action in other_actions {

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'actrunner.configure')!
if install_actions.len > 0 {
return error("can't configure actrunner, because no configuration allowed for this installer.")
return error("can't configure actrunner:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'actrunner.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'b2.configure')!
if install_actions.len > 0 {
return error("can't configure b2, because no configuration allowed for this installer.")
return error("can't configure b2:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'b2.')!
for mut other_action in other_actions {

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'fungistor.configure')!
if install_actions.len > 0 {
return error("can't configure fungistor, because no configuration allowed for this installer.")
return error("can't configure fungistor:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'fungistor.')!
for mut other_action in other_actions {

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&GarageS3 {
data := r.hget('context:garage_s3', args.name)!
if data.len == 0 {
print_backtrace()
return error('GarageS3 with name: garage_s3 does not exist, prob bug.')
return error('GarageS3 with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(GarageS3, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&GarageS3 {
new(args)!
} else {
print_backtrace()
return error("GarageS3 with name 'garage_s3' does not exist")
return error("GarageS3 with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return garage_s3_global[args.name] or {
print_backtrace()
return error('could not get config for garage_s3 with name:garage_s3')
return error('could not get config for garage_s3 with name:${args.name}')
}
}

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'grafana.configure')!
if install_actions.len > 0 {
return error("can't configure grafana, because no configuration allowed for this installer.")
return error("can't configure grafana:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'grafana.')!
for mut other_action in other_actions {

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'prometheus.configure')!
if install_actions.len > 0 {
return error("can't configure prometheus, because no configuration allowed for this installer.")
return error("can't configure prometheus:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'prometheus.')!
for mut other_action in other_actions {

View File

@@ -4,10 +4,11 @@ import incubaid.herolib.core.base
import incubaid.herolib.core.playbook { PlayBook }
import incubaid.herolib.ui.console
import json
import incubaid.herolib.osal.startupmanager
__global (
rclone_installer_global map[string]&RClone
rclone_installer_default string
rclone_global map[string]&RClone
rclone_default string
)
/////////FACTORY
@@ -30,14 +31,14 @@ pub fn new(args ArgsGet) !&RClone {
pub fn get(args ArgsGet) !&RClone {
mut context := base.context()!
rclone_installer_default = args.name
if args.fromdb || args.name !in rclone_installer_global {
rclone_default = args.name
if args.fromdb || args.name !in rclone_global {
mut r := context.redis()!
if r.hexists('context:rclone', args.name)! {
data := r.hget('context:rclone', args.name)!
if data.len == 0 {
print_backtrace()
return error('RClone with name: rclone does not exist, prob bug.')
return error('RClone with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(RClone, data)!
set_in_mem(obj)!
@@ -46,21 +47,21 @@ pub fn get(args ArgsGet) !&RClone {
new(args)!
} else {
print_backtrace()
return error("RClone with name 'rclone' does not exist")
return error("RClone with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return rclone_installer_global[args.name] or {
return rclone_global[args.name] or {
print_backtrace()
return error('could not get config for rclone with name:rclone')
return error('could not get config for rclone with name:${args.name}')
}
}
// register the config for the future
pub fn set(o RClone) ! {
mut o2 := set_in_mem(o)!
rclone_installer_default = o2.name
rclone_default = o2.name
mut context := base.context()!
mut r := context.redis()!
r.hset('context:rclone', o2.name, json.encode(o2))!
@@ -91,8 +92,8 @@ pub fn list(args ArgsList) ![]&RClone {
mut context := base.context()!
if args.fromdb {
// reset what is in mem
rclone_installer_global = map[string]&RClone{}
rclone_installer_default = ''
rclone_global = map[string]&RClone{}
rclone_default = ''
}
if args.fromdb {
mut r := context.redis()!
@@ -104,7 +105,7 @@ pub fn list(args ArgsList) ![]&RClone {
return res
} else {
// load from memory
for _, client in rclone_installer_global {
for _, client in rclone_global {
res << client
}
}
@@ -114,8 +115,8 @@ pub fn list(args ArgsList) ![]&RClone {
// only sets in mem, does not set as config
fn set_in_mem(o RClone) !RClone {
mut o2 := obj_init(o)!
rclone_installer_global[o2.name] = &o2
rclone_installer_default = o2.name
rclone_global[o2.name] = &o2
rclone_default = o2.name
return o2
}
@@ -180,5 +181,5 @@ pub fn (mut self RClone) destroy() ! {
// switch instance to be used for rclone
pub fn switch(name string) {
rclone_installer_default = name
rclone_default = name
}

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'restic.configure')!
if install_actions.len > 0 {
return error("can't configure restic, because no configuration allowed for this installer.")
return error("can't configure restic:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'restic.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'griddriver.configure')!
if install_actions.len > 0 {
return error("can't configure griddriver, because no configuration allowed for this installer.")
return error("can't configure griddriver:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'griddriver.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'cloudhypervisor.configure')!
if install_actions.len > 0 {
return error("can't configure cloudhypervisor, because no configuration allowed for this installer.")
return error("can't configure cloudhypervisor:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'cloudhypervisor.')!
for mut other_action in other_actions {

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'docker.configure')!
if install_actions.len > 0 {
return error("can't configure docker, because no configuration allowed for this installer.")
return error("can't configure docker:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'docker.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'herorunner.configure')!
if install_actions.len > 0 {
return error("can't configure herorunner, because no configuration allowed for this installer.")
return error("can't configure herorunner:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'herorunner.')!
for mut other_action in other_actions {

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&LimaInstaller {
data := r.hget('context:lima', args.name)!
if data.len == 0 {
print_backtrace()
return error('LimaInstaller with name: lima does not exist, prob bug.')
return error('LimaInstaller with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(LimaInstaller, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&LimaInstaller {
new(args)!
} else {
print_backtrace()
return error("LimaInstaller with name 'lima' does not exist")
return error("LimaInstaller with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return lima_global[args.name] or {
print_backtrace()
return error('could not get config for lima with name:lima')
return error('could not get config for lima with name:${args.name}')
}
}

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'pacman.configure')!
if install_actions.len > 0 {
return error("can't configure pacman, because no configuration allowed for this installer.")
return error("can't configure pacman:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'pacman.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'podman.configure')!
if install_actions.len > 0 {
return error("can't configure podman, because no configuration allowed for this installer.")
return error("can't configure podman:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'podman.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'youki.configure')!
if install_actions.len > 0 {
return error("can't configure youki, because no configuration allowed for this installer.")
return error("can't configure youki:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'youki.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'bun.configure')!
if install_actions.len > 0 {
return error("can't configure bun, because no configuration allowed for this installer.")
return error("can't configure bun:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'bun.')!
for mut other_action in other_actions {

View File

@@ -33,7 +33,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'lighttpd.configure')!
if install_actions.len > 0 {
return error("can't configure lighttpd, because no configuration allowed for this installer.")
return error("can't configure lighttpd:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'lighttpd.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'tailwind.configure')!
if install_actions.len > 0 {
return error("can't configure tailwind, because no configuration allowed for this installer.")
return error("can't configure tailwind:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'tailwind.')!
for mut other_action in other_actions {

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'tailwind4.configure')!
if install_actions.len > 0 {
return error("can't configure tailwind4, because no configuration allowed for this installer.")
return error("can't configure tailwind4:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'tailwind4.')!
for mut other_action in other_actions {

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&TraefikServer {
data := r.hget('context:traefik', args.name)!
if data.len == 0 {
print_backtrace()
return error('TraefikServer with name: traefik does not exist, prob bug.')
return error('TraefikServer with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(TraefikServer, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&TraefikServer {
new(args)!
} else {
print_backtrace()
return error("TraefikServer with name 'traefik' does not exist")
return error("TraefikServer with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return traefik_global[args.name] or {
print_backtrace()
return error('could not get config for traefik with name:traefik')
return error('could not get config for traefik with name:${args.name}')
}
}

View File

@@ -32,7 +32,7 @@ pub fn play(mut plbook PlayBook) ! {
}
mut install_actions := plbook.find(filter: 'zola.configure')!
if install_actions.len > 0 {
return error("can't configure zola, because no configuration allowed for this installer.")
return error("can't configure zola:${args.name}, because no configuration allowed for this installer.")
}
mut other_actions := plbook.find(filter: 'zola.')!
for mut other_action in other_actions {

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&TFGridDeployer {
data := r.hget('context:deployer', args.name)!
if data.len == 0 {
print_backtrace()
return error('TFGridDeployer with name: deployer does not exist, prob bug.')
return error('TFGridDeployer with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(TFGridDeployer, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&TFGridDeployer {
new(args)!
} else {
print_backtrace()
return error("TFGridDeployer with name 'deployer' does not exist")
return error("TFGridDeployer with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return deployer_global[args.name] or {
print_backtrace()
return error('could not get config for deployer with name:deployer')
return error('could not get config for deployer with name:${args.name}')
}
}

View File

@@ -37,7 +37,7 @@ pub fn get(args ArgsGet) !&HetznerManager {
data := r.hget('context:hetznermanager', args.name)!
if data.len == 0 {
print_backtrace()
return error('HetznerManager with name: hetznermanager does not exist, prob bug.')
return error('HetznerManager with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(HetznerManager, data)!
set_in_mem(obj)!
@@ -46,14 +46,14 @@ pub fn get(args ArgsGet) !&HetznerManager {
new(args)!
} else {
print_backtrace()
return error("HetznerManager with name 'hetznermanager' does not exist")
return error("HetznerManager with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return hetznermanager_global[args.name] or {
print_backtrace()
return error('could not get config for hetznermanager with name:hetznermanager')
return error('could not get config for hetznermanager with name:${args.name}')
}
}

View File

@@ -39,7 +39,7 @@ pub fn get(args ArgsGet) !&KubeClient {
data := r.hget('context:kubernetes', args.name)!
if data.len == 0 {
print_backtrace()
return error('KubeClient with name: kubernetes does not exist, prob bug.')
return error('KubeClient with name: ${args.name} does not exist, prob bug.')
}
mut obj := json.decode(KubeClient, data)!
set_in_mem(obj)!
@@ -48,14 +48,14 @@ pub fn get(args ArgsGet) !&KubeClient {
new(args)!
} else {
print_backtrace()
return error("KubeClient with name 'kubernetes' does not exist")
return error("KubeClient with name '${args.name}' does not exist")
}
}
return get(name: args.name)! // no longer from db nor create
}
return kubernetes_global[args.name] or {
print_backtrace()
return error('could not get config for kubernetes with name:kubernetes')
return error('could not get config for kubernetes with name:${args.name}')
}
}