service_ledger

package
v0.0.0-...-b33afb8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

README

Service Ledger

One thing that OpenCloud tries to do differently is its approach to Infrastructure as Code (IaC). IaC is the practice of defining and managing infrastructure through code instead of manual setup, which makes environments reproducible, scalable, and consistent. However, it usually requires you to write and maintain code before deploying anything. OpenCloud flips this model: every action you take in the UI automatically generates and updates IaC behind the scenes, giving you all the benefits of reproducibility and portability without the overhead of writing the code first.

Introducing one of the core features of OpenCloud: The Service Ledger. The Service Ledger keeps track of your infrastructure's state as you provision services in the UI, and allows a developer to download a JSON that serves as the IaC of that OpenCloud instance. This makes it extremely easy to replicate and share OpenCloud configurations across environments.

In other words, every change you make in the OpenCloud UI, whether provisioning, updating, or removing resources, is automatically recorded in the Service Ledger. Instead of requiring you to write IaC, deploying, then checking the UI of your cloud provider to see if it was successful, OpenCloud reverses the process: It allows you to use the UI to get your infrastructure working, then you can easily download the resulting IaC for that configuration. This creates a living, always up-to-date representation of your infrastructure that can be used as your IaC.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFunctionEntry

func DeleteFunctionEntry(functionName string) error

DeleteFunctionEntry removes a function entry from the Functions service ledger

func DeletePipelineEntry

func DeletePipelineEntry(pipelineID string) error

DeletePipelineEntry removes a pipeline entry from the pipelines service ledger

func EnableService

func EnableService(serviceName string) error

EnableService enables a specific service in the ledger

func EnableServiceHandler

func EnableServiceHandler(w http.ResponseWriter, r *http.Request)

EnableServiceHandler is an HTTP handler that enables a service

func GetAllFunctionEntries

func GetAllFunctionEntries() (map[string]FunctionEntry, error)

GetAllFunctionEntries retrieves all function entries from the Functions service ledger

func GetAllPipelineEntries

func GetAllPipelineEntries() (map[string]PipelineEntry, error)

GetAllPipelineEntries retrieves all pipeline entries from the pipelines service ledger

func GetServiceStatusHandler

func GetServiceStatusHandler(w http.ResponseWriter, r *http.Request)

GetServiceStatusHandler is an HTTP handler that returns the status of a service

func InitializeServiceLedger

func InitializeServiceLedger() error

InitializeServiceLedger ensures the service ledger file exists with default services

func IsServiceEnabled

func IsServiceEnabled(serviceName string) (bool, error)

IsServiceEnabled checks if a specific service is enabled

func SyncFunctions

func SyncFunctions() error

SyncFunctions scans the ~/.opencloud/functions/ directory and updates the service ledger with any functions that exist on disk but are not yet tracked in the ledger

func SyncFunctionsHandler

func SyncFunctionsHandler(w http.ResponseWriter, r *http.Request)

SyncFunctionsHandler is an HTTP handler that syncs functions from disk to the service ledger

func SyncPipelines

func SyncPipelines() error

SyncPipelines scans the ~/.opencloud/pipelines/ directory and updates the service ledger with any pipelines that exist on disk but are not yet tracked in the ledger

func SyncPipelinesHandler

func SyncPipelinesHandler(w http.ResponseWriter, r *http.Request)

SyncPipelinesHandler is an HTTP handler that syncs pipelines from disk to the service ledger

func UpdateFunctionEntry

func UpdateFunctionEntry(functionName, runtime, trigger, schedule, content string) error

UpdateFunctionEntry updates a specific function entry in the Functions service ledger

func UpdatePipelineEntry

func UpdatePipelineEntry(pipelineID, name, description, code, branch, status, createdAt string) error

UpdatePipelineEntry updates a specific pipeline entry in the pipelines service ledger

func WriteServiceLedger

func WriteServiceLedger(ledger ServiceLedger) error

WriteServiceLedger writes the service ledger to the JSON file

Types

type FunctionEntry

type FunctionEntry struct {
	Runtime  string        `json:"runtime"`
	Trigger  string        `json:"trigger,omitempty"`
	Schedule string        `json:"schedule,omitempty"`
	Content  string        `json:"content"`
	Logs     []FunctionLog `json:"logs,omitempty"`
}

FunctionEntry represents an individual function's metadata in the ledger

func GetFunctionEntry

func GetFunctionEntry(functionName string) (*FunctionEntry, error)

GetFunctionEntry retrieves a specific function entry from the Functions service ledger

type FunctionLog

type FunctionLog struct {
	Timestamp string `json:"timestamp"`
	Output    string `json:"output"`
	Error     string `json:"error,omitempty"`
	Status    string `json:"status"` // "success" or "error"
}

FunctionLog represents a single function execution log

type PipelineEntry

type PipelineEntry struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Code        string `json:"code"`
	Branch      string `json:"branch"`
	Status      string `json:"status"`
	CreatedAt   string `json:"createdAt"`
}

PipelineEntry represents an individual pipeline's metadata in the ledger

func GetPipelineEntry

func GetPipelineEntry(pipelineID string) (*PipelineEntry, error)

GetPipelineEntry retrieves a specific pipeline entry from the pipelines service ledger

type ServiceLedger

type ServiceLedger map[string]ServiceStatus

ServiceLedger represents the complete service ledger

func ReadServiceLedger

func ReadServiceLedger() (ServiceLedger, error)

ReadServiceLedger reads and parses the service ledger JSON file

type ServiceStatus

type ServiceStatus struct {
	Enabled   bool                     `json:"enabled"`
	Functions map[string]FunctionEntry `json:"functions,omitempty"`
	Pipelines map[string]PipelineEntry `json:"pipelines,omitempty"`
}

ServiceStatus represents the status of a single service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL