object

package
v1.108.7 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AgentBindingPending = "Pending"
	AgentBindingBound   = "Bound"
	AgentBindingError   = "Error"
)

Agent binding lifecycle states. Honest — each reflects a real, observable condition, never an optimistic guess:

  • Pending: binding recorded; the machine's @hanzo/bot runtime has not yet been confirmed running (machine still provisioning, or bot cloud-init not yet observed on the instance tags).
  • Bound: the machine is Active AND is tagged as running the @hanzo/bot runtime for this agent (the launch cloud-init path stamps a `hanzo-bot:<agentName>` provider tag).
  • Unbound: the binding was explicitly deleted; retained transiently only as a return value, never persisted (DELETE removes the row).
  • Error: the machine is in a terminal/failed cloud state, so the runtime cannot be running.
View Source
const (
	NoConnect    = "no_connect"
	Connecting   = "connecting"
	Connected    = "connected"
	Disconnected = "disconnected"
)
View Source
const BotRuntimeTag = "hanzo-bot"

BotRuntimeTag is the provider tag that marks a machine as running the @hanzo/bot runtime for a given agent. The launch cloud-init path is the single writer; reconcile is the single reader. The value is the agent name so one machine hosts exactly one agent's bot (the machine IS the bot's identity).

Variables

This section is empty.

Functions

func AddAgentBinding

func AddAgentBinding(binding *AgentBinding) (bool, error)

AddAgentBinding inserts a binding. Callers set identity + timestamps first.

func AddAsset

func AddAsset(asset *Asset) (bool, error)

func AddMachine

func AddMachine(machine *Machine) (bool, error)

func AddNodePool

func AddNodePool(pool *NodePool) (bool, error)

func AddPlan

func AddPlan(plan *Plan) (bool, error)

func AddProvider

func AddProvider(provider *Provider) (bool, error)

func AddRecord

func AddRecord(record *Record) bool

func AddSession

func AddSession(session *Session) (bool, error)

func AddVolume

func AddVolume(volume *Volume) (bool, error)

func AttachVolumeCloud

func AttachVolumeCloud(owner string, providerName string, volumeCloudID string, machineCloudID string) error

func ClaimMeterHour

func ClaimMeterHour(now time.Time) bool

ClaimMeterHour attempts to claim the hourly metering sweep for the wall-clock hour containing now, cluster-wide. It returns true to EXACTLY ONE caller per hour (the replica whose Insert wins the Hour primary key); every other replica — and any re-entry within the same hour after a restart — gets false and must skip the sweep.

A DB error (unreachable/constraint) yields false: fail SAFE for a paid product means NOT sweeping (better a missed hour, reconciled later, than a duplicate debit). Best-effort prune of stale rows runs only for the winner so it costs nothing on the hot skip path.

func CloseDBSession

func CloseDBSession(id string, code int, msg string) error

func CloseSession

func CloseSession(id string, code int, msg string) error

func CommitRecord

func CommitRecord(record *Record) (bool, error)

func DBPath

func DBPath(root, owner string) string

DBPath is the HIP-0302 per-org SQLite path for a visor org DB. It mirrors the layout hanzo/cloud uses (orgs/<org>/<service>.db) so every Hanzo service that moves onto Base shares one on-disk convention.

DBPath("/data", "acme")  ->  /data/orgs/acme/visor.db

The empty owner (catalog / cluster-global rows that no org owns) routes to the _global sentinel, matching hanzo/cloud's fail-loud migration bucket.

func DeleteAgentBinding

func DeleteAgentBinding(binding *AgentBinding) (bool, error)

DeleteAgentBinding removes a binding by PK (unbind). It does NOT touch the machine — unbinding severs the agent↔machine record; tearing down the machine is a separate DeleteMachine call so the two lifecycles stay orthogonal.

func DeleteAsset

func DeleteAsset(asset *Asset) (bool, error)

func DeleteMachine

func DeleteMachine(machine *Machine) (bool, error)

func DeleteNodePool

func DeleteNodePool(pool *NodePool) (bool, error)

func DeletePlan

func DeletePlan(plan *Plan) (bool, error)

func DeleteProvider

func DeleteProvider(provider *Provider) (bool, error)

func DeleteRecord

func DeleteRecord(record *Record) (bool, error)

func DeleteSession

func DeleteSession(session *Session) (bool, error)

func DeleteSessionById

func DeleteSessionById(id string) (bool, error)

func DeleteVolume

func DeleteVolume(volume *Volume) (bool, error)

func DeleteVolumeCloud

func DeleteVolumeCloud(owner string, providerName string, volumeCloudID string) error

func DetachVolumeCloud

func DetachVolumeCloud(owner string, providerName string, volumeCloudID string) error

func EngineFor

func EngineFor(owner string) (*xorm.Engine, error)

EngineFor returns the storage engine that serves owner under the configured backend. This is the single entry point backend-agnostic code MUST use so a query works unchanged on either backend.

func GetAllNodePools

func GetAllNodePools(pools *[]*NodePool) error

GetAllNodePools fetches all node pools across all owners (for billing reporting).

func GetAssetCount

func GetAssetCount(owner, field, value string) (int64, error)

func GetBearerUser

func GetBearerUser(authHeader string) *iam.User

GetBearerUser validates an "Authorization: Bearer <IAM JWT>" header and returns the authenticated user, or nil. iam.ParseJwtToken verifies the token SIGNATURE (jwt.ParseWithClaims + x509), so a forged/tampered token is rejected.

Signature alone is NOT sufficient: Hanzo IAM publishes ONE shared JWKS holding every brand's cert (hanzo/lux/zoo/pars/...), so a validly-signed token from any brand — including public self-service signups — passes the signature check. We therefore bind the token to THIS deployment by BRAND (issuer), not by a single org:

  • owner (org) must be non-empty (an empty-org token can't be scoped), and
  • issuer must match the configured brand issuer(s) in iamIssuer, so a sibling brand's token (lux.id/zoo.id/pars.id) is rejected even though its signature verifies.

EVERY org within this brand is accepted — the resell compute surface is multi-tenant (org "hanzo", "maxpower", and every self-service customer org). Each request is org-scoped downstream: resolveComputeOrg pins org = user.Owner (no ?owner override for real users) and Casbin enforces subOwner==objOwner, so one org can never reach another's machines. This is how API/console callers authenticate as a user (org = user.Owner) from a forwarded short-lived Bearer, without a browser cookie session.

func GetMachineCount

func GetMachineCount(owner, field, value string) (int64, error)

func GetNodePoolCount

func GetNodePoolCount(owner, field, value string) (int64, error)

func GetProviderCount

func GetProviderCount(owner, field, value string) (int64, error)

func GetRecordCount

func GetRecordCount(owner, field, value string) (int64, error)

func GetSession

func GetSession(owner string, offset, limit int, field, value, sortField, sortOrder string) *xorm.Session

func GetSessionCount

func GetSessionCount(owner, status, field, value string) (int64, error)

func InitAdapter

func InitAdapter()

func InitConfig

func InitConfig()

func InitStore

func InitStore()

InitStore selects and installs the process-wide engine provider. It is called by InitAdapter after the Postgres adapter is built. The Postgres engine is ALWAYS opened (the live query path depends on it, and the migration reads from it); the flag only decides what EngineFor hands back to new code.

func QueryRecord

func QueryRecord(id string) (string, error)

func ResizeVolumeCloud

func ResizeVolumeCloud(owner string, providerName string, volumeCloudID string, sizeGB int) error

func SeedDefaultPlans

func SeedDefaultPlans(owner string) error

SeedDefaultPlans inserts default plans if none exist for the given owner.

func SyncMachinesCloud

func SyncMachinesCloud(owner string) (bool, error)

func SyncNodePoolsCloud

func SyncNodePoolsCloud(owner string) (bool, error)

SyncNodePoolsCloud fetches node pools from DO for all active DigitalOcean providers with a ClusterID and upserts them into the DB.

func UnbindAgent

func UnbindAgent(machineId string) (bool, error)

UnbindAgent removes the binding for a machine. Returns whether a binding was present. Orthogonal to the machine lifecycle — it never deletes the machine.

func UpdateAgentBinding

func UpdateAgentBinding(binding *AgentBinding) (bool, error)

UpdateAgentBinding writes all columns of an existing binding by PK.

func UpdateAsset

func UpdateAsset(id string, asset *Asset) (bool, error)

func UpdateMachine

func UpdateMachine(id string, machine *Machine) (bool, error)

func UpdateNodePool

func UpdateNodePool(id string, pool *NodePool) (bool, error)

func UpdatePlan

func UpdatePlan(owner string, name string, plan *Plan) (bool, error)

func UpdateProvider

func UpdateProvider(id string, provider *Provider) (bool, error)

func UpdateRecord

func UpdateRecord(id string, record *Record) (bool, error)

func UpdateSession

func UpdateSession(id string, session *Session, columns ...string) (bool, error)

func UpdateVolume

func UpdateVolume(owner string, name string, volume *Volume) (bool, error)

func WriteCloseMessage

func WriteCloseMessage(session *guacamole.Session, mode string, code int, msg string)

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter represents the database adapter for policy storage.

func NewAdapter

func NewAdapter(driverName string, dataSourceName string) *Adapter

NewAdapter is the constructor for Adapter.

type AgentBinding

type AgentBinding struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`

	// Bound cloud Agent identity. `Org` is the cloud/IAM organization that owns
	// the Agent (`<org>-<agent>` service-account naming); `AgentName` is the
	// Agent's name in the cloud `/v1/agents` registry.
	Org       string `xorm:"varchar(100)" json:"org"`
	AgentName string `xorm:"varchar(100)" json:"agentName"`

	// MachineId is the machine's id (`owner/machine-name`), duplicated from the
	// PK for a stable JSON field the operator can echo without re-splitting.
	MachineId string `xorm:"varchar(200)" json:"machineId"`
	// Provider + PublicIp are denormalized snapshots of the bound machine for
	// quick status reads without a second machine lookup.
	Provider string `xorm:"varchar(100)" json:"provider"`
	PublicIp string `xorm:"varchar(100)" json:"publicIp"`

	// BotVersion is the @hanzo/bot npm version the runtime targets. Empty means
	// "track the machine's launch default" (the cloud-init installs `@hanzo/bot`
	// latest at provision time); a pinned semver is recorded verbatim.
	BotVersion string `xorm:"varchar(100)" json:"botVersion"`

	// Status is the reconciled lifecycle state (Pending/Bound/Error). Message
	// carries the human-readable reason behind the current Status.
	Status  string `xorm:"varchar(100)" json:"status"`
	Message string `xorm:"varchar(500)" json:"message"`
}

AgentBinding records that a machine runs the @hanzo/bot runtime for a specific cloud Agent. It is the vm half of the Bot lifecycle: a Bot = Agent (execution_mode=long-running) + a bound compute running @hanzo/bot. The operator's AgentDeployment controller drives this over `POST /v1/machines/:id/bind-agent`.

The machine is the identity: PK is (Owner, Name) where Name == the machine id (`owner/machine-name`). One machine hosts one agent's bot runtime, so the binding is 1:1 with the machine — re-binding a different agent replaces the prior binding rather than layering.

func BindAgent

func BindAgent(machineId string, org string, agentName string, botVersion string) (*AgentBinding, error)

BindAgent provisions/marks a machine as running the @hanzo/bot runtime for a cloud Agent. It is idempotent: binding a machine that is already bound to the same agent re-reconciles status; binding it to a DIFFERENT agent replaces the prior binding (the machine hosts exactly one agent's bot). The returned binding carries the freshly reconciled honest Status.

It does not itself install the runtime — the runtime is installed by the machine's launch cloud-init, which the operator drives via a machine launch with a `hanzo-bot:<agent>` tag before calling this. BindAgent records the agent↔machine relation and reports the observed convergence state.

func GetAgentBindings

func GetAgentBindings(owner string) ([]*AgentBinding, error)

GetAgentBindings lists every binding owned by `owner`, newest first.

func ReconcileAgentBinding

func ReconcileAgentBinding(machineId string) (*AgentBinding, error)

ReconcileAgentBinding re-derives and persists the honest Status of an existing binding against the live machine state. Used by the GET path so a read always reflects current convergence, and returns nil when the machine has no binding.

type Asset

type Asset struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
	DisplayName string `xorm:"varchar(100)" json:"displayName"`

	Category string `xorm:"varchar(100)" json:"category"`
	Type     string `xorm:"varchar(100)" json:"type"`
	Tag      string `xorm:"varchar(100)" json:"tag"`

	MachineName string `xorm:"varchar(100)" json:"machineName"`
	Os          string `xorm:"varchar(100)" json:"os"`

	PublicIp  string `xorm:"varchar(100)" json:"publicIp"`
	PrivateIp string `xorm:"varchar(100)" json:"privateIp"`

	Size    string `xorm:"varchar(100)" json:"size"`
	CpuSize string `xorm:"varchar(100)" json:"cpuSize"`
	MemSize string `xorm:"varchar(100)" json:"memSize"`

	RemoteProtocol string `xorm:"varchar(100)" json:"remoteProtocol"`
	RemotePort     int    `json:"remotePort"`
	RemoteUsername string `xorm:"varchar(100)" json:"remoteUsername"`
	RemotePassword string `xorm:"varchar(100)" json:"remotePassword"`

	AutoQuery   bool `json:"autoQuery"`
	IsPermanent bool `json:"isPermanent"`

	Language string `xorm:"varchar(100)" json:"language"`

	EnableRemoteApp bool         `json:"enableRemoteApp"`
	RemoteApps      []*RemoteApp `json:"remoteApps"`
	Services        []*Service   `json:"services"`
	Patches         []*Patch     `json:"patches"`
}

func GetAsset

func GetAsset(id string) (*Asset, error)

func GetAssets

func GetAssets(owner string) ([]*Asset, error)

func GetMaskedAsset

func GetMaskedAsset(asset *Asset, errs ...error) (*Asset, error)

func GetMaskedAssets

func GetMaskedAssets(assets []*Asset, errs ...error) ([]*Asset, error)

func GetPaginationAssets

func GetPaginationAssets(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Asset, error)

type Machine

type Machine struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	Id          string `xorm:"varchar(100)" json:"id"`
	Provider    string `xorm:"varchar(100)" json:"provider"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
	ExpireTime  string `xorm:"varchar(100)" json:"expireTime"`
	DisplayName string `xorm:"varchar(100)" json:"displayName"`

	Region   string `xorm:"varchar(100)" json:"region"`
	Zone     string `xorm:"varchar(100)" json:"zone"`
	Category string `xorm:"varchar(100)" json:"category"`
	Type     string `xorm:"varchar(100)" json:"type"`
	Size     string `xorm:"varchar(100)" json:"size"`
	Tag      string `xorm:"varchar(500)" json:"tag"`
	State    string `xorm:"varchar(100)" json:"state"`

	Image     string `xorm:"varchar(100)" json:"image"`
	Os        string `xorm:"varchar(100)" json:"os"`
	PublicIp  string `xorm:"varchar(100)" json:"publicIp"`
	PrivateIp string `xorm:"varchar(100)" json:"privateIp"`
	CpuSize   string `xorm:"varchar(100)" json:"cpuSize"`
	MemSize   string `xorm:"varchar(100)" json:"memSize"`

	// DB info
	RemoteProtocol string `xorm:"varchar(100)" json:"remoteProtocol"`
	RemotePort     int    `json:"remotePort"`
	RemoteUsername string `xorm:"varchar(100)" json:"remoteUsername"`
	RemotePassword string `xorm:"varchar(100)" json:"remotePassword"`
}

func CreateMachineCloud

func CreateMachineCloud(owner string, providerName string, spec *service.CreateMachineSpec) (*Machine, error)

CreateMachineCloud launches a new VM via the cloud provider and registers it in the DB.

func GetMachine

func GetMachine(id string) (*Machine, error)

func GetMachines

func GetMachines(owner string) ([]*Machine, error)

func GetMaskedMachine

func GetMaskedMachine(machine *Machine, errs ...error) (*Machine, error)

func GetMaskedMachines

func GetMaskedMachines(machines []*Machine, errs ...error) ([]*Machine, error)

func GetPaginationMachines

func GetPaginationMachines(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Machine, error)

func (*Machine) GetId

func (machine *Machine) GetId() string

type MeterLease

type MeterLease struct {
	Hour        string `xorm:"varchar(12) notnull pk" json:"hour"` // UTC "YYYYMMDDHH" bucket — the billable unit.
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
}

MeterLease is a single-flight lease for the hourly compute-metering sweep. Its whole purpose is a MONEY-SAFETY invariant: the visor Deployment runs replicas: 2 with no leader election, so without a lease BOTH replicas would run service.MeterRunningMachines every hour and debit every running machine twice (the per-machine hour-bucketed RequestID is only a dedup HINT — commerce's RecordUsage does NOT dedup the withdraw transaction on requestId, so the client key alone does not stop a duplicate debit). The lease makes exactly one replica perform the sweep per wall-clock hour, cluster-wide.

The mechanism is the same insert-once-wins primitive the rest of object uses: Hour is the PK, so only the FIRST Insert for a given hour succeeds; a concurrent replica's Insert fails the unique-key constraint and that replica skips the hour. It survives a mid-hour restart too — a restarted replica finds the hour already claimed and does not re-sweep (so a rollout cannot re-bill the hour).

type MigrationReport

type MigrationReport struct {
	Table       string
	SourceRows  int
	WrittenRows int
	Orgs        int // distinct owner DBs the rows fanned into
}

MigrationReport records what MigratePostgresToBase copied for one table.

func MigratePostgresToBase

func MigratePostgresToBase(src *xorm.Engine, dst *baseStore) ([]MigrationReport, error)

MigratePostgresToBase copies every visor table from the shared Postgres engine into per-org Base SQLite files, routing each row to DBPath(owner). It iterates the same models() registry the schema sync uses, so it can never drift from the live schema.

It NEVER runs at boot: an operator invokes it explicitly during the cutover window (e.g. a `visor migrate` subcommand). Rows are grouped by their Owner field; models without an Owner (MeterLease -- a cluster-global lease, see the CTO note in LLM.md) route to the _global sentinel DB. This mirrors hanzo/cloud's introspective migration/pg_to_sqlite.go, but is schema-aware because visor owns its models rather than a drifted upstream schema.

type NodePool

type NodePool struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`

	ClusterID   string `xorm:"varchar(100)" json:"clusterId"`
	PoolID      string `xorm:"varchar(100)" json:"poolId"`
	Provider    string `xorm:"varchar(100)" json:"provider"`
	Size        string `xorm:"varchar(100)" json:"size"`
	Count       int    `json:"count"`
	MinNodes    int    `json:"minNodes"`
	MaxNodes    int    `json:"maxNodes"`
	AutoScale   bool   `json:"autoScale"`
	State       string `xorm:"varchar(100)" json:"state"`
	CostPerHour int64  `json:"costPerHour"` // cents
	OrgID       string `xorm:"varchar(100)" json:"orgId"`
	ProjectID   string `xorm:"varchar(100)" json:"projectId"`
}

func CreateNodePoolCloud

func CreateNodePoolCloud(owner, providerName, clusterID string, spec *service.CreateNodePoolSpec) (*NodePool, error)

CreateNodePoolCloud creates a new node pool in DOKS via the cloud provider and persists it.

func GetNodePool

func GetNodePool(id string) (*NodePool, error)

func GetNodePools

func GetNodePools(owner string) ([]*NodePool, error)

func GetPaginationNodePools

func GetPaginationNodePools(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*NodePool, error)

func ScaleNodePoolCloud

func ScaleNodePoolCloud(owner, providerName, clusterID, poolID string, count int) (*NodePool, error)

ScaleNodePoolCloud updates the node count of an existing DOKS node pool.

func (*NodePool) GetId

func (pool *NodePool) GetId() string

type Param

type Param struct {
	Key   string `json:"key"`
	Field string `json:"field"`
	Value string `json:"value"`
}

type Patch

type Patch struct {
	Name           string `json:"name"`
	Category       string `json:"category"`
	Title          string `json:"title"`
	Url            string `json:"url"`
	Size           string `json:"size"`
	ExpectedStatus string `json:"expectedStatus"`
	Status         string `json:"status"`
	InstallTime    string `json:"installTime"`
	Message        string `json:"message"`
}

type Plan

type Plan struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`

	DisplayName string `xorm:"varchar(100)" json:"displayName"`
	Description string `xorm:"varchar(500)" json:"description"`
	Category    string `xorm:"varchar(100)" json:"category"` // "bot", "standard", "pro", "power"
	State       string `xorm:"varchar(100)" json:"state"`    // "Active", "Inactive"

	// Specs advertised to the customer
	VCpu    int    `json:"vCpu"`
	Ram     int    `json:"ram"`                        // MB
	Disk    int    `json:"disk"`                       // GB
	CpuType string `xorm:"varchar(50)" json:"cpuType"` // "shared", "dedicated"

	// Pricing (cents/mo)
	PriceMonthly int `json:"priceMonthly"` // customer price in cents USD

	// Region availability
	Regions string `xorm:"varchar(500)" json:"regions"` // comma-separated: "us,eu,sg"

	// Provider mapping per region (JSON)
	// e.g. {"us":{"provider":"Hetzner","serverType":"cpx31","location":"ash"},...}
	ProviderMapping string `xorm:"mediumtext" json:"providerMapping"`

	// Traffic included (GB)
	TrafficIncluded int `json:"trafficIncluded"`

	SortOrder int `json:"sortOrder"`
}

Plan represents a resale VM plan available to customers.

func DefaultPlans

func DefaultPlans(owner string) []*Plan

DefaultPlans returns the Hanzo Cloud plan catalog. Provider mapping is internal — customers never see backend provider names.

Regions: "us" (ash/hil), "eu" (fsn1/nbg1), "sg" (sin) Pricing aligned with hanzo/pricing cloudPlans.

func GetAllPlans

func GetAllPlans(owner string) ([]*Plan, error)

func GetPlan

func GetPlan(owner string, name string) (*Plan, error)

func GetPlans

func GetPlans(owner string) ([]*Plan, error)

type Provider

type Provider struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
	DisplayName string `xorm:"varchar(100)" json:"displayName"`

	Category string `xorm:"varchar(100)" json:"category"`
	Type     string `xorm:"varchar(100)" json:"type"`

	ClientId     string `xorm:"varchar(100)" json:"clientId"`
	ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
	Region       string `xorm:"varchar(100)" json:"region"`
	Network      string `xorm:"varchar(100)" json:"network"`
	Chain        string `xorm:"varchar(100)" json:"chain"`
	BrowserUrl   string `xorm:"varchar(200)" json:"browserUrl"`

	State       string `xorm:"varchar(100)" json:"state"`
	ProviderUrl string `xorm:"varchar(200)" json:"providerUrl"`

	ClusterID string `xorm:"varchar(100)" json:"clusterId"` // DOKS cluster UUID
}

func GetMaskedProvider

func GetMaskedProvider(provider *Provider, errs ...error) (*Provider, error)

func GetMaskedProviders

func GetMaskedProviders(providers []*Provider, errs ...error) ([]*Provider, error)

func GetPaginationProviders

func GetPaginationProviders(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Provider, error)

func GetProvider

func GetProvider(id string) (*Provider, error)

func GetProviders

func GetProviders(owner string) ([]*Provider, error)

type Record

type Record struct {
	Id int `xorm:"int notnull pk autoincr" json:"id"`

	Owner       string `xorm:"varchar(100) index" json:"owner"`
	Name        string `xorm:"varchar(100) index" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	Organization string `xorm:"varchar(100)" json:"organization"`
	ClientIp     string `xorm:"varchar(100)" json:"clientIp"`
	UserAgent    string `xorm:"varchar(100)" json:"userAgent"`
	User         string `xorm:"varchar(100)" json:"user"`
	Method       string `xorm:"varchar(100)" json:"method"`
	RequestUri   string `xorm:"varchar(1000)" json:"requestUri"`
	Action       string `xorm:"varchar(1000)" json:"action"`
	Language     string `xorm:"varchar(100)" json:"language"`

	Object   string `xorm:"mediumtext" json:"object"`
	Response string `xorm:"mediumtext" json:"response"`

	Provider    string `xorm:"varchar(100)" json:"provider"`
	Block       string `xorm:"varchar(100)" json:"block"`
	Transaction string `xorm:"varchar(500)" json:"transaction"`
	IsTriggered bool   `json:"isTriggered"`
}

func GetPaginationRecords

func GetPaginationRecords(owner string, offset, limit int, field, value, sortField, sortOrder string) ([]*Record, error)

func GetRecord

func GetRecord(id string) (*Record, error)

func GetRecords

func GetRecords(owner string) ([]*Record, error)

func NewRecord

func NewRecord(ctx *context.Context) (*Record, error)

type RemoteApp

type RemoteApp struct {
	No            int    `json:"no"`
	RemoteAppName string `xorm:"varchar(100)" json:"remoteAppName"`
	RemoteAppDir  string `xorm:"varchar(100)" json:"remoteAppDir"`
	RemoteAppArgs string `xorm:"varchar(100)" json:"remoteAppArgs"`
}

type Response

type Response struct {
	Status string `json:"status"`
	Msg    string `json:"msg"`
}

type Service

type Service struct {
	No             int    `json:"no"`
	Name           string `json:"name"`
	Path           string `json:"path"`
	Port           int    `json:"port"`
	ProcessId      int    `json:"processId"`
	ExpectedStatus string `json:"expectedStatus"`
	Status         string `json:"status"`
	SubStatus      string `json:"subStatus"`
	Message        string `json:"message"`
}

type Session

type Session struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`

	StartTime string `xorm:"varchar(100)" json:"startTime"`
	EndTime   string `xorm:"varchar(100)" json:"endTime"`

	Protocol      string `xorm:"varchar(20)" json:"protocol"`
	ConnectionId  string `xorm:"varchar(50)" json:"connectionId"`
	Asset         string `xorm:"varchar(200) index" json:"asset"`
	Creator       string `xorm:"varchar(36) index" json:"creator"`
	ClientIp      string `xorm:"varchar(200)" json:"clientIp"`
	UserAgent     string `xorm:"varchar(200)" json:"userAgent"`
	ClientIpDesc  string `xorm:"varchar(100)" json:"clientIpDesc"`
	UserAgentDesc string `xorm:"varchar(100)" json:"userAgentDesc"`
	Width         int    `json:"width"`
	Height        int    `json:"height"`
	Status        string `xorm:"varchar(20) index" json:"status"`
	Recording     string `xorm:"varchar(1000)" json:"recording"`
	Code          int    `json:"code"`
	Message       string `json:"message"`

	Mode       string   `xorm:"varchar(10)" json:"mode"`
	Operations []string `xorm:"json varchar(1000)" json:"operations"`

	Reviewed     bool  `json:"reviewed"`
	CommandCount int64 `json:"commandCount"`
}

func CreateSession

func CreateSession(session *Session, machineId string, mode string) (*Session, error)

func GetConnSession

func GetConnSession(id string) (*Session, error)

func GetPaginationSessions

func GetPaginationSessions(owner, status string, offset, limit int, field, value, sortField, sortOrder string) ([]*Session, error)

func GetSessions

func GetSessions(owner string) ([]*Session, error)

func GetSessionsByStatus

func GetSessionsByStatus(statuses []string) ([]*Session, error)

func (*Session) GetId

func (s *Session) GetId() string

type StorageBackend

type StorageBackend string

StorageBackend names the configured persistence backend.

const (
	// BackendPostgres is the historical shared-Postgres backend (default).
	BackendPostgres StorageBackend = "postgres"
	// BackendBase is the per-org SQLite substrate (hanzoai/base, HIP-0302).
	BackendBase StorageBackend = "base"
)

func ConfiguredBackend

func ConfiguredBackend() StorageBackend

ConfiguredBackend reads the storageBackend config knob (default "postgres").

type Volume

type Volume struct {
	Owner       string `xorm:"varchar(100) notnull pk" json:"owner"`
	Name        string `xorm:"varchar(100) notnull pk" json:"name"`
	CreatedTime string `xorm:"varchar(100)" json:"createdTime"`
	UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`

	DisplayName string `xorm:"varchar(100)" json:"displayName"`
	Id          string `xorm:"varchar(100)" json:"id"`       // Cloud provider volume ID
	Provider    string `xorm:"varchar(100)" json:"provider"` // Provider name
	Machine     string `xorm:"varchar(100)" json:"machine"`  // Attached machine name (empty if detached)
	Region      string `xorm:"varchar(100)" json:"region"`
	Size        int    `json:"size"`                           // GB
	State       string `xorm:"varchar(100)" json:"state"`      // "Available", "Attached", "Creating"
	Format      string `xorm:"varchar(50)" json:"format"`      // "ext4", "xfs", etc.
	MountPoint  string `xorm:"varchar(200)" json:"mountPoint"` // e.g. "/mnt/data"
}

Volume represents a block storage volume attached to a machine.

func CreateVolumeCloud

func CreateVolumeCloud(owner string, providerName string, spec *service.CreateVolumeSpec) (*Volume, error)

func GetVolume

func GetVolume(owner string, name string) (*Volume, error)

func GetVolumes

func GetVolumes(owner string) ([]*Volume, error)

func (*Volume) GetId

func (v *Volume) GetId() string

type WhitelabelConfig

type WhitelabelConfig struct {
	AppName      string `json:"appName"`
	LogoUrl      string `json:"logoUrl"`
	FaviconUrl   string `json:"faviconUrl"`
	PrimaryColor string `json:"primaryColor"`
	SupportUrl   string `json:"supportUrl"`
	DocsUrl      string `json:"docsUrl"`
	OrgFilter    string `json:"orgFilter"`
}

WhitelabelConfig holds per-hostname branding configuration.

func GetWhitelabelConfig

func GetWhitelabelConfig(host string) *WhitelabelConfig

GetWhitelabelConfig returns the branding config for a given hostname. Falls back to the default (Hanzo) config if no match is found.

Jump to

Keyboard shortcuts

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