service

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigValueNull   = 0
	ConfigValueString = iota
	ConfigValueTrue
	ConfigValueFalse
)
View Source
const ConfigName = "conductor-service.json"

Variables

Functions

func DisplayColumnEqual added in v0.0.48

func DisplayColumnEqual(v1, v2 DisplayColumn) bool

func DisplayColumnIsEmpty added in v0.0.48

func DisplayColumnIsEmpty(v DisplayColumn) bool

func EvaluateConditions added in v0.0.48

func EvaluateConditions(conditions []ServiceCondition, verbose bool) (res bool, err error)

func ServiceConfigUnit

func ServiceConfigUnit(path string) string

func ServiceDirByName

func ServiceDirByName(name string) (string, error)

func ServiceDirFromUnit

func ServiceDirFromUnit(u string) string

func ServiceFileByName

func ServiceFileByName(name string) (string, error)

func ServiceNameFromFile

func ServiceNameFromFile(service_file string) (string, error)

func ServiceRealpath

func ServiceRealpath(service_dir string) (string, error)

func ServiceUnit

func ServiceUnit(path string) string

func ServiceUnitByName

func ServiceUnitByName(name string) (string, error)

Types

type CaddyConfig

type CaddyConfig struct {
	ApiEndpoint string             `json:"api_endpoint"`
	Timeout     utils.JSONDuration `json:"timeout"`
}

type CommandRunnerDisplayCol added in v0.0.48

type CommandRunnerDisplayCol interface {
	RunCommandGetValue(c *ServiceCommand, cmd_name string, args ...string) (string, error)
}

type ConfigValue added in v0.0.24

type ConfigValue struct {
	Kind ConfigValueKind
	Str  string
}

func (*ConfigValue) MarshalJSON added in v0.0.24

func (v *ConfigValue) MarshalJSON() ([]byte, error)

func (*ConfigValue) String added in v0.0.24

func (v *ConfigValue) String() string

func (*ConfigValue) UnmarshalJSON added in v0.0.24

func (v *ConfigValue) UnmarshalJSON(data []byte) error

type ConfigValueKind added in v0.0.24

type ConfigValueKind int

type DisplayColumn added in v0.0.48

type DisplayColumn struct {
	DisplayColumnData
}

func (*DisplayColumn) MarshalJSON added in v0.0.48

func (c *DisplayColumn) MarshalJSON() ([]byte, error)

func (*DisplayColumn) UnmarshalJSON added in v0.0.48

func (c *DisplayColumn) UnmarshalJSON(data []byte) error

type DisplayColumnData added in v0.0.48

type DisplayColumnData struct {
	Name    string   `json:"name"`
	Config  string   `json:"config"`
	Command []string `json:"command"`
}

type HelpFlag added in v0.0.15

type HelpFlag struct {
	Name string
	Help string
}

type Hook

type Hook struct {
	Id         string   `json:"id"`
	When       string   `json:"when"`
	Exec       []string `json:"exec"`
	Part       []string `json:"parts"`
	TimeoutSec int64    `json:"timeout_sec"`
}

type InheritFile added in v0.0.15

type InheritFile struct {
	InheritFileBase
	Inherit *InheritedFile
}

func (*InheritFile) UnmarshalJSON added in v0.0.15

func (f *InheritFile) UnmarshalJSON(data []byte) error

type InheritFileBase added in v0.0.15

type InheritFileBase struct {
	Path        string `json:"path"`
	IgnoreError bool   `json:"ignore_error"`
	SetConfig   bool   `json:"set_config"`
}

type InheritedFile added in v0.0.15

type InheritedFile struct {
	Inherit []*InheritFile `json:"inherit"`
}

func DecodeInherit added in v0.0.15

func DecodeInherit(data []byte, dir string) (*InheritedFile, error)

type InheritedFileSingle added in v0.0.15

type InheritedFileSingle struct {
	Inherit *InheritFile `json:"inherit"`
}

type Service

type Service struct {
	BasePath                string                     `json:"-"`
	FileName                string                     `json:"-"`
	ConfigSetFile           string                     `json:"-"`
	Name                    string                     `json:"-"`
	Id                      string                     `json:"-"`
	Inherit                 *InheritedFile             `json:"-"`
	AppName                 string                     `json:"app_name,omitempty"`      // my-app
	InstanceName            string                     `json:"instance_name,omitempty"` // staging
	Disable                 *bool                      `json:"disable"`
	Conditions              []ServiceCondition         `json:"conditions"`
	Config                  map[string]*ConfigValue    `json:"config,omitempty"`                // key-value pairs for config and templating, CHANNEL=staging
	ProxyConfigTemplate     string                     `json:"proxy_config_template,omitempty"` // Template file for the load-balancer config
	Pods                    ServicePods                `json:"pods,omitempty"`
	Functions               ServiceFunctions           `json:"functions,omitempty"`
	Hooks                   []*Hook                    `json:"hooks,omitempty"`
	CaddyLoadBalancer       CaddyConfig                `json:"caddy_load_balancer"`
	DisplayServiceConfig    []DisplayColumn            `json:"display_service_config"`
	DisplayServiceDepConfig *[]DisplayColumn           `json:"display_service_deployment_config"`
	DisplayDeploymentConfig []DisplayColumn            `json:"display_deployment_config"`
	Commands                map[string]*ServiceCommand `json:"commands"`
}

func LoadServiceByName

func LoadServiceByName(name string) (*Service, error)

func LoadServiceDir

func LoadServiceDir(dir string) (*Service, error)

func LoadServiceFile

func LoadServiceFile(path string) (*Service, error)

func (*Service) ComputeId

func (service *Service) ComputeId(extra string, exclude_vars []string) (string, error)

func (*Service) ComputeIdData added in v0.0.45

func (service *Service) ComputeIdData(extra string) ([]byte, error)

func (*Service) EvaluateCondition added in v0.0.48

func (s *Service) EvaluateCondition(verbose bool) (condition bool, disable bool, err error)

func (*Service) FillDefaults

func (service *Service) FillDefaults() error

func (*Service) FindFunction added in v0.0.61

func (service *Service) FindFunction(part_name string) *ServiceFunction

func (*Service) FindPod added in v0.0.61

func (service *Service) FindPod(part_name string) *ServicePod

func (*Service) GetDisplayColumn added in v0.0.48

func (s *Service) GetDisplayColumn(c DisplayColumn, runner CommandRunnerDisplayCol) (string, error)

func (*Service) PartId added in v0.0.45

func (service *Service) PartId(ctx context.Context, part string) (string, error)

func (*Service) PartIds added in v0.0.73

func (service *Service) PartIds(ctx context.Context) (map[string]string, error)

func (*Service) Parts added in v0.0.20

func (service *Service) Parts() ([]string, error)

func (*Service) ProxyConfig added in v0.0.45

func (service *Service) ProxyConfig(ctx context.Context) (caddy.ConfigItems, error)

func (*Service) RunHooks added in v0.0.61

func (s *Service) RunHooks(ctx context.Context, when string, part string, vars []string, extend_timeout time.Duration) error

func (*Service) UnitStatus added in v0.0.15

func (service *Service) UnitStatus(ctx context.Context) (dbus.UnitStatus, error)

func (*Service) Vars

func (service *Service) Vars() []string

func (*Service) VarsExcluding added in v0.0.61

func (service *Service) VarsExcluding(excluded []string) []string

type ServiceCommand added in v0.0.15

type ServiceCommand struct {
	Deployment           bool       `json:"deployment"`
	Service              bool       `json:"service"`
	ServiceAnyDeployment bool       `json:"service_any_deployment"`
	Description          string     `json:"description"`
	Exec                 []string   `json:"exec"`
	HelpFlags            [][]string `json:"help_flags"`
	HelpArgs             []string   `json:"help_args"`
}

func (*ServiceCommand) GetHelpFlags added in v0.0.15

func (c *ServiceCommand) GetHelpFlags() []HelpFlag

func (*ServiceCommand) GetTabbedHelpFlags added in v0.0.15

func (c *ServiceCommand) GetTabbedHelpFlags() *utils.Tabbed

type ServiceCondition added in v0.0.48

type ServiceCondition struct {
	Hostname *string `json:"hostname"`
}

func (*ServiceCondition) Evaluate added in v0.0.48

func (cond *ServiceCondition) Evaluate(verbose bool) (bool, error)

type ServiceFunction added in v0.0.29

type ServiceFunction struct {
	Name                 string                       `json:"name"`
	PartIdTemplate       string                       `json:"part_id_template"`
	ExcludeVars          []string                     `json:"exclude_vars"`
	ServiceDirectives    []string                     `json:"service_directives,omitempty"`
	Format               string                       `json:"format,omitempty"` // Format: cgi, http-stdio, sdactivate
	Exec                 []string                     `json:"exec,omitempty"`
	StderrAsStdout       bool                         `json:"stderr_as_stdout,omitempty"`
	ResponseHeaders      []string                     `json:"response_headers,omitempty"`    // Additional response headers
	NoResponseHeaders    bool                         `json:"no_response_headers,omitempty"` // Function does not add response headers
	PathInfoStrip        int                          `json:"path_info_strip,omitempty"`     // Strip this number of leading elements from PATH_INFO
	Policies             []string                     `json:"policies,omitempty"`            // Policies to match
	ProvidedReverseProxy []ServiceFunctionProxyConfig `json:"reverse_proxy"`
	DefaultReverseProxy  *bool                        `json:"default_reverse_proxy,omitempty"`
}

func (*ServiceFunction) CaddyConfig added in v0.0.45

func (f *ServiceFunction) CaddyConfig(ctx context.Context, service *Service, name string) (json.RawMessage, error)

func (*ServiceFunction) CaddyConfigName added in v0.0.45

func (f *ServiceFunction) CaddyConfigName(service *Service, name string) string

func (*ServiceFunction) FillDefaults added in v0.0.45

func (f *ServiceFunction) FillDefaults(service *Service) error

func (*ServiceFunction) IsSingle added in v0.0.45

func (f *ServiceFunction) IsSingle() bool

func (*ServiceFunction) ReverseProxy added in v0.0.45

func (f *ServiceFunction) ReverseProxy(ctx context.Context, service *Service) (res []ServiceFunctionProxyConfig, err error)

func (*ServiceFunction) ReverseProxyConfigs added in v0.0.45

func (f *ServiceFunction) ReverseProxyConfigs(ctx context.Context, service *Service) (configs caddy.ConfigItems, err error)

type ServiceFunctionProxyConfig added in v0.0.45

type ServiceFunctionProxyConfig struct {
	Name          string          `json:"name"`
	MountPoint    string          `json:"mount_point,omitempty"`
	Route         json.RawMessage `json:"route,omitempty"` // if unspecified, generate default, if false, do not generate Route
	UpstreamsPath string          `json:"upstreams_path"`
}

type ServiceFunctions added in v0.0.29

type ServiceFunctions []*ServiceFunction

func (*ServiceFunctions) FillDefaults added in v0.0.29

func (functions *ServiceFunctions) FillDefaults(service *Service) error

func (*ServiceFunctions) FindFunction added in v0.0.29

func (functions *ServiceFunctions) FindFunction(name string) *ServiceFunction

func (*ServiceFunctions) FindMainFunction added in v0.0.29

func (functions *ServiceFunctions) FindMainFunction() *ServiceFunction

func (*ServiceFunctions) FixPaths added in v0.0.29

func (functions *ServiceFunctions) FixPaths(dir string) error

func (*ServiceFunctions) UnmarshalJSON added in v0.0.29

func (functions *ServiceFunctions) UnmarshalJSON(data []byte) error

type ServicePod added in v0.0.20

type ServicePod struct {
	Name                 string                  `json:"name"`
	PartIdTemplate       string                  `json:"part_id_template"`
	ExcludeVars          []string                `json:"exclude_vars"`
	ServiceDirectives    []string                `json:"service_directives,omitempty"`
	PodTemplate          string                  `json:"pod_template,omitempty"`        // Template file for pod
	ConfigMapTemplate    string                  `json:"config_map_template,omitempty"` // ConfigMap template file
	ProvidedReverseProxy []ServicePodProxyConfig `json:"reverse_proxy"`
}

func (*ServicePod) CaddyConfigName added in v0.0.45

func (pod *ServicePod) CaddyConfigName(service *Service, name string) string

func (*ServicePod) ReverseProxy added in v0.0.45

func (pod *ServicePod) ReverseProxy(service *Service) (res []ServicePodProxyConfig, err error)

func (*ServicePod) ReverseProxyConfigs added in v0.0.45

func (pod *ServicePod) ReverseProxyConfigs(service *Service) (configs caddy.ConfigItems, err error)

type ServicePodProxyConfig added in v0.0.45

type ServicePodProxyConfig struct {
	Name          string          `json:"name"`
	MountPoint    string          `json:"mount_point"`
	Route         json.RawMessage `json:"route"`
	UpstreamsPath string          `json:"upstreams_path"`
	Port          int             `json:"port"`
}

type ServicePods added in v0.0.20

type ServicePods []*ServicePod

func (*ServicePods) FillDefaults added in v0.0.20

func (pods *ServicePods) FillDefaults(service *Service) error

func (*ServicePods) FindMainPod added in v0.0.20

func (pods *ServicePods) FindMainPod() *ServicePod

func (*ServicePods) FindPod added in v0.0.20

func (pods *ServicePods) FindPod(name string) *ServicePod

func (*ServicePods) FixPaths added in v0.0.20

func (pods *ServicePods) FixPaths(dir string) error

func (*ServicePods) UnmarshalJSON added in v0.0.20

func (pods *ServicePods) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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