- Add Kubernetes client module for interacting with kubectl - Implement methods to get cluster info, pods, deployments, and services - Create a Kubernetes example script demonstrating client usage - Add JSON response structs for parsing kubectl output - Define runtime resource structs (Pod, Deployment, Service) for structured data - Include comprehensive unit tests for data structures and client logic
43 lines
1.1 KiB
V
43 lines
1.1 KiB
V
module kubernetes
|
|
|
|
import incubaid.herolib.data.encoderhero
|
|
|
|
pub const version = '0.0.0'
|
|
const singleton = false
|
|
const default = true
|
|
|
|
@[heap]
|
|
pub struct KubeClient {
|
|
pub mut:
|
|
name string = 'default'
|
|
kubeconfig_path string // Path to kubeconfig file
|
|
config KubeConfig // Kubernetes configuration
|
|
connected bool // Connection status
|
|
api_version string = 'v1'
|
|
cache_enabled bool = true
|
|
cache_ttl_seconds int = 300
|
|
}
|
|
|
|
// your checking & initialization code if needed
|
|
fn obj_init(mycfg_ KubeClient) !KubeClient {
|
|
mut mycfg := mycfg_
|
|
return mycfg
|
|
}
|
|
|
|
// called before start if done
|
|
fn configure() ! {
|
|
// mut installer := get()!
|
|
// mut mycode := $tmpl('templates/atemplate.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) !KubeClient {
|
|
// TODO: will have to be implemented manual
|
|
mut obj := encoderhero.decode[KubeClient](heroscript)!
|
|
return obj
|
|
}
|