Documentation
¶
Overview ¶
Package types holds the types that the API, the SDK and the CLI share, such as the states of an agent and the roles of a token.
Index ¶
- Constants
- Variables
- func FormatSteps(steps []Step) string
- type AddressFamily
- type AdmissionState
- type AgentJobStatus
- type AgentState
- type ColumnKind
- type ComponentType
- type ConditionType
- type ContainerState
- type ContentType
- type FieldIn
- type FieldKind
- type InterfaceType
- type Interval
- type JobStatus
- type JobType
- type Lock
- type LogLevel
- type MethodKind
- type Permission
- type Reason
- type Role
- type RowStatus
- type Signal
- type SpanStatus
- type Step
- type TypeSpec
- type Verb
Constants ¶
const ( // TargetAny routes to any available agent (load-balanced). TargetAny = "_any" // TargetAll broadcasts to every agent. TargetAll = "_all" )
Target constants for job routing.
Variables ¶
var JobTypes = []JobType{JobTypeQuery, JobTypeModify}
JobTypes are each type of a job operation.
Functions ¶
func FormatSteps ¶
FormatSteps is steps on one line: netplan update (changed) → managedfile update (changed), with the calls of a step that called more than one in parentheses, and a step that failed marked failed.
Types ¶
type AddressFamily ¶
type AddressFamily string
AddressFamily is the IP address family of an interface.
const ( // FamilyInet is IPv4. FamilyInet AddressFamily = "inet" // FamilyInet6 is IPv6. FamilyInet6 AddressFamily = "inet6" // FamilyDual is IPv4 and IPv6. FamilyDual AddressFamily = "dual" )
The values of AddressFamily: the address families.
func (AddressFamily) Doc ¶
func (AddressFamily) Doc() string
Doc is what AddressFamily is, from its doc comment.
func (AddressFamily) Valid ¶
func (a AddressFamily) Valid() bool
Valid reports whether a is one of the values.
func (AddressFamily) Values ¶
func (AddressFamily) Values() []AddressFamily
Values are the address families.
type AdmissionState ¶
type AdmissionState string
AdmissionState is the state of a machine's admission record. A machine has one at a time: the state of its latest record.
const ( // AdmissionPending is a machine that asked to join and waits for a // decision. AdmissionPending AdmissionState = "pending" // AdmissionAdmitted is a machine whose key the controller admitted. AdmissionAdmitted AdmissionState = "admitted" // AdmissionRejected is a machine whose request the controller rejected. AdmissionRejected AdmissionState = "rejected" // AdmissionRevoked is a machine whose admission the controller revoked. AdmissionRevoked AdmissionState = "revoked" )
The states of an admission record.
func (AdmissionState) Doc ¶
func (AdmissionState) Doc() string
Doc is what AdmissionState is, from its doc comment.
func (AdmissionState) Valid ¶
func (s AdmissionState) Valid() bool
Valid reports whether s is one of the states.
func (AdmissionState) Values ¶
func (AdmissionState) Values() []AdmissionState
Values are the states of an admission record, in their order.
type AgentJobStatus ¶
type AgentJobStatus string
AgentJobStatus is the status of a job on one host: the event that a status key of the job records, the state of an agent, and the status of an agent's response. The controller records submitted and retried for the host _api, and an agent records the others. It is one of Values.
const ( // AgentJobStatusSubmitted is the event of the controller that put the // job in the queue. AgentJobStatusSubmitted AgentJobStatus = "submitted" // AgentJobStatusAcknowledged is an agent that received the job. AgentJobStatusAcknowledged AgentJobStatus = "acknowledged" // AgentJobStatusStarted is an agent that started the operation. AgentJobStatusStarted AgentJobStatus = "started" // AgentJobStatusCompleted is an agent that completed the operation. AgentJobStatusCompleted AgentJobStatus = "completed" // AgentJobStatusFailed is an agent on which the operation failed. AgentJobStatusFailed AgentJobStatus = "failed" // AgentJobStatusSkipped is an agent that skipped the operation, because // it is not supported on the OS family of the host. AgentJobStatusSkipped AgentJobStatus = "skipped" // AgentJobStatusRetried is the event of the controller that sent the // job again as a new job. AgentJobStatusRetried AgentJobStatus = "retried" // AgentJobStatusTimeout is a host whose agent did not answer in time. // The controller sets it on the response, and no event records it. // Distinct from failed, which means the operation ran and did not // succeed: a timeout says nothing about whether it ran. AgentJobStatusTimeout AgentJobStatus = "timeout" // AgentJobStatusRefused is a host whose result the controller refused, // because the agent's signature is not the admitted key's. Whatever the // agent reported for the job, the controller did not take its result // (osapi-io/osapi#1484). AgentJobStatusRefused AgentJobStatus = "refused" )
The statuses of a job on a host.
func (AgentJobStatus) Doc ¶
func (AgentJobStatus) Doc() string
Doc is what AgentJobStatus is, from its doc comment.
func (AgentJobStatus) Valid ¶
func (s AgentJobStatus) Valid() bool
Valid is whether s is one of Values.
func (AgentJobStatus) Values ¶
func (AgentJobStatus) Values() []AgentJobStatus
Values are the statuses of a job on a host, in the order of their life.
type AgentState ¶
type AgentState string
AgentState is the scheduling state of an agent, one of its Values.
const ( // AgentReady indicates the agent is accepting and processing jobs. AgentReady AgentState = "Ready" // AgentDraining indicates the agent is finishing in-flight jobs // but not accepting new ones. AgentDraining AgentState = "Draining" // AgentCordoned indicates the agent is blocked from receiving // new jobs until manually uncordoned. AgentCordoned AgentState = "Cordoned" // AgentPending indicates the agent is awaiting PKI enrollment // acceptance and will not process jobs until accepted. AgentPending AgentState = "Pending" // AgentRefused indicates the controller refuses each result that the // agent signs, because its keys are not the keys that the controller // admitted. The KeyMismatch condition says which. AgentRefused AgentState = "Refused" )
The scheduling states of an agent.
func (AgentState) Doc ¶
func (AgentState) Doc() string
Doc is what AgentState is, from its doc comment.
func (AgentState) Values ¶
func (AgentState) Values() []AgentState
Values are each scheduling state of an agent.
type ColumnKind ¶
type ColumnKind string
ColumnKind is what a field of an answer holds.
const ( // ColumnValue holds one value. ColumnValue ColumnKind = "value" // ColumnValues holds a list of values. ColumnValues ColumnKind = "values" // ColumnObject holds an object. ColumnObject ColumnKind = "object" // ColumnList holds a list of objects. ColumnList ColumnKind = "list" )
The values of ColumnKind: the kinds of an output field.
func (ColumnKind) Doc ¶
func (ColumnKind) Doc() string
Doc is what ColumnKind is, from its doc comment.
func (ColumnKind) Valid ¶
func (c ColumnKind) Valid() bool
Valid reports whether c is one of the values.
func (ColumnKind) Values ¶
func (ColumnKind) Values() []ColumnKind
Values are the kinds of an output field.
type ComponentType ¶
type ComponentType string
ComponentType is the type of a part of osapi that reports its health.
const ( // ComponentController is the controller. ComponentController ComponentType = "controller" // ComponentNATS is the NATS server. ComponentNATS ComponentType = "nats" // ComponentAgent is an agent. ComponentAgent ComponentType = "agent" )
The values of ComponentType: the types of a component.
func (ComponentType) Doc ¶
func (ComponentType) Doc() string
Doc is what ComponentType is, from its doc comment.
func (ComponentType) Valid ¶
func (c ComponentType) Valid() bool
Valid reports whether c is one of the values.
func (ComponentType) Values ¶
func (ComponentType) Values() []ComponentType
Values are the types of a component.
type ConditionType ¶
type ConditionType string
ConditionType is a node or process condition that the agent evaluates, one of its Values.
const ( ConditionMemoryPressure ConditionType = "MemoryPressure" ConditionHighLoad ConditionType = "HighLoad" ConditionDiskPressure ConditionType = "DiskPressure" // ConditionDrainStuck is set when a drain's consumers have not stopped // within the agent's limit, so the agent cannot reach Cordoned. ConditionDrainStuck ConditionType = "DrainStuck" // agent cannot be created or bound, so the agent does not get all of // its jobs. ConditionConsumersUnavailable ConditionType = "ConsumersUnavailable" // ConditionProcessMemoryPressure is set while the RSS of the osapi // process is over its limit. ConditionProcessMemoryPressure ConditionType = "ProcessMemoryPressure" // ConditionProcessHighCPU is set while the CPU use of the osapi process // is over its limit. ConditionProcessHighCPU ConditionType = "ProcessHighCPU" // ConditionKeyMismatch is set by the controller, not the agent, when the // agent's keys are not the keys that it admitted: the controller refuses // each result that the agent signs (osapi-io/osapi#1484). ConditionKeyMismatch ConditionType = "KeyMismatch" )
The conditions that an agent evaluates.
func (ConditionType) Doc ¶
func (ConditionType) Doc() string
Doc is what ConditionType is, from its doc comment.
func (ConditionType) Valid ¶
func (c ConditionType) Valid() bool
Valid is whether c is one of Values.
func (ConditionType) Values ¶
func (ConditionType) Values() []ConditionType
Values are each condition that an agent evaluates.
type ContainerState ¶
type ContainerState string
ContainerState is the containers that a list shows, by their state.
const ( // ContainerRunning shows the containers that run. ContainerRunning ContainerState = "running" // ContainerStopped shows the containers that do not run. ContainerStopped ContainerState = "stopped" // ContainerAll shows each container. ContainerAll ContainerState = "all" )
The values of ContainerState: the states that a container list filters by.
func (ContainerState) Doc ¶
func (ContainerState) Doc() string
Doc is what ContainerState is, from its doc comment.
func (ContainerState) Valid ¶
func (c ContainerState) Valid() bool
Valid reports whether c is one of the values.
func (ContainerState) Values ¶
func (ContainerState) Values() []ContainerState
Values are the states that a container list filters by.
type ContentType ¶
type ContentType string
ContentType is how a deploy treats a file: raw writes its bytes as they are; template renders it with Go text/template and the agent's facts.
const ( // ContentRaw writes the bytes as they are. ContentRaw ContentType = "raw" // ContentTemplate renders the file with Go text/template and the agent's // facts before it writes it. ContentTemplate ContentType = "template" )
The content types of a file.
func (ContentType) Doc ¶
func (ContentType) Doc() string
Doc is what ContentType is, from its doc comment.
func (ContentType) Valid ¶
func (c ContentType) Valid() bool
Valid reports whether c is one of the content types.
type FieldIn ¶
type FieldIn string
FieldIn is where a field of a request goes.
type FieldKind ¶
type FieldKind string
FieldKind is how a form takes the value of a field.
const ( // FieldString is text. FieldString FieldKind = "string" // FieldNumber is a number. FieldNumber FieldKind = "number" // FieldBool is true or false. FieldBool FieldKind = "bool" // FieldList is a list of values. FieldList FieldKind = "list" // FieldObject is an object. FieldObject FieldKind = "object" )
The values of FieldKind: the kinds of an input field.
type InterfaceType ¶
type InterfaceType string
InterfaceType is the type of a network interface that osapi manages.
const ( // InterfaceEthernet is an interface that the host has. InterfaceEthernet InterfaceType = "ethernet" // InterfaceDummy is a virtual interface that osapi makes. InterfaceDummy InterfaceType = "dummy" )
The values of InterfaceType: the types of an interface.
func (InterfaceType) Doc ¶
func (InterfaceType) Doc() string
Doc is what InterfaceType is, from its doc comment.
func (InterfaceType) Valid ¶
func (i InterfaceType) Valid() bool
Valid reports whether i is one of the values.
func (InterfaceType) Values ¶
func (InterfaceType) Values() []InterfaceType
Values are the types of an interface.
type Interval ¶
type Interval string
Interval is how often a scheduled job runs, in place of a cron schedule.
const ( // IntervalHourly runs the job each hour. IntervalHourly Interval = "hourly" // IntervalDaily runs the job each day. IntervalDaily Interval = "daily" // IntervalWeekly runs the job each week. IntervalWeekly Interval = "weekly" // IntervalMonthly runs the job each month. IntervalMonthly Interval = "monthly" )
The values of Interval: the intervals of a scheduled job.
type JobStatus ¶
type JobStatus string
JobStatus is the status of a job: what the controller computes from the status events of each agent that the job went to. It is one of Values.
const ( // JobStatusSubmitted is a job in the queue that no agent has taken. JobStatusSubmitted JobStatus = "submitted" // JobStatusProcessing is a job that an agent acknowledged or started. JobStatusProcessing JobStatus = "processing" // JobStatusCompleted is a job that each agent completed, or completed // or skipped. JobStatusCompleted JobStatus = "completed" // JobStatusFailed is a job that failed on each agent that did not skip // it. JobStatusFailed JobStatus = "failed" // JobStatusPartialFailure is a job that completed on some agents and // failed on others. JobStatusPartialFailure JobStatus = "partial_failure" // JobStatusSkipped is a job that each agent skipped, because the // operation is not supported on its OS family. JobStatusSkipped JobStatus = "skipped" )
The statuses of a job.
type Lock ¶
type Lock string
Lock is whether a user account refuses logins with its password.
type LogLevel ¶
type LogLevel string
LogLevel is the level that a process logs at, one of its Values.
const ( // LogDebug logs each line, the debug lines too. LogDebug LogLevel = "debug" // LogInfo logs the info, warn and error lines. LogInfo LogLevel = "info" // LogWarn logs the warn and error lines. LogWarn LogLevel = "warn" // LogError logs the error lines. LogError LogLevel = "error" )
The levels that a process logs at, as log/slog names them.
type MethodKind ¶
type MethodKind string
MethodKind is what a method of a behavior does to a host, by the verb of its permission. It is a separate set from Verb: execute, shell and exec are each an action.
const ( // KindRead changes nothing. KindRead MethodKind = "read" // KindWrite changes what the host is configured to be. KindWrite MethodKind = "write" // KindAction makes something happen on the host, such as a restart or a // reboot. KindAction MethodKind = "action" )
The kinds of a method.
func (MethodKind) Doc ¶
func (MethodKind) Doc() string
Doc is what MethodKind is, from its doc comment.
func (MethodKind) Values ¶
func (MethodKind) Values() []MethodKind
Values are each kind of a method.
type Permission ¶
type Permission string
Permission represents a fine-grained resource:verb permission. Permissions use the format "resource:verb" (e.g., "status:read", "command:execute").
const ( PermHealthRead Permission = "health:read" PermTraceRead Permission = "trace:read" PermSecretUse Permission = "secret:use" PermSecretReveal Permission = "secret:reveal" PermCertificateRead Permission = "certificate:read" PermCertificateWrite Permission = "certificate:write" PermCommandExecute Permission = "command:execute" PermCommandShell Permission = "command:shell" PermConnectivityExecute Permission = "connectivity:execute" PermDiskRead Permission = "disk:read" PermDnsRead Permission = "dns:read" PermDnsWrite Permission = "dns:write" PermDockerRead Permission = "docker:read" PermDockerWrite Permission = "docker:write" PermDockerExecute Permission = "docker:execute" PermDockerExec Permission = "docker:exec" PermFileRead Permission = "file:read" PermFileWrite Permission = "file:write" PermGroupRead Permission = "group:read" PermGroupWrite Permission = "group:write" PermHostnameRead Permission = "hostname:read" PermHostnameWrite Permission = "hostname:write" PermImageRead Permission = "image:read" PermImageExecute Permission = "image:execute" PermImageWrite Permission = "image:write" PermInterfaceRead Permission = "interface:read" PermInterfaceWrite Permission = "interface:write" PermLoadRead Permission = "load:read" PermLogRead Permission = "log:read" PermMemoryRead Permission = "memory:read" PermNtpRead Permission = "ntp:read" PermNtpWrite Permission = "ntp:write" PermOsRead Permission = "os:read" PermPackageRead Permission = "package:read" PermPackageWrite Permission = "package:write" PermPowerExecute Permission = "power:execute" PermProcessRead Permission = "process:read" PermProcessExecute Permission = "process:execute" PermScheduleRead Permission = "schedule:read" PermScheduleWrite Permission = "schedule:write" PermServiceRead Permission = "service:read" PermServiceWrite Permission = "service:write" PermServiceExecute Permission = "service:execute" PermStatusRead Permission = "status:read" PermSysctlRead Permission = "sysctl:read" PermSysctlWrite Permission = "sysctl:write" PermTimezoneRead Permission = "timezone:read" PermTimezoneWrite Permission = "timezone:write" PermUptimeRead Permission = "uptime:read" PermUserRead Permission = "user:read" PermUserWrite Permission = "user:write" PermAdmissionRead Permission = "admission:read" PermAdmissionWrite Permission = "admission:write" PermAgentRead Permission = "agent:read" PermAgentWrite Permission = "agent:write" PermAuditRead Permission = "audit:read" PermCatalogRead Permission = "catalog:read" PermJobRead Permission = "job:read" PermJobWrite Permission = "job:write" PermPkiRead Permission = "pki:read" PermPkiWrite Permission = "pki:write" PermSecretRead Permission = "secret:read" PermSecretWrite Permission = "secret:write" )
Permission constants, one for each permission osapi knows.
func NewPermission ¶
func NewPermission( resource string, v Verb, ) Permission
NewPermission is the permission of verb v on resource, as resource:verb, such as sysctl:read.
func (Permission) Doc ¶
func (Permission) Doc() string
Doc is what Permission is, from its doc comment.
func (Permission) Valid ¶
func (p Permission) Valid() bool
Valid reports whether p is a permission that osapi knows.
func (Permission) Values ¶
func (Permission) Values() []Permission
Values are each permission that osapi knows.
type Reason ¶
type Reason string
Reason is the reason of an error answer, one of its Values. A program branches on it, so a reason outside the list breaks the contract of the spec's ErrorResponse.
const ( ReasonInvalidRequest Reason = "invalid_request" ReasonForbidden Reason = "forbidden" ReasonNotFound Reason = "not_found" ReasonNotManaged Reason = "not_managed" ReasonNotInstalled Reason = "not_installed" ReasonConflict Reason = "conflict" ReasonServerError Reason = "server_error" )
The reasons of an error answer: why the request failed, as a word that a program branches on. The HTTP status is the class of the problem, the reason its cause, and the message is for a person. The ErrorResponse schema of the spec lists the same words.
type Role ¶
type Role string
Role represents a built-in RBAC role name.
const ( // RoleAdmin is the owner of the fleet: each permission. RoleAdmin Role = "admin" // RoleOperator is the person on call: each read, and each action that // makes something happen (execute), such as a restart, a signal or a // reboot, but no change to the configuration. RoleOperator Role = "operator" // RoleAutomation is CI or a workflow that changes the configuration: // each read and each write, and the use of a secret in a write, but no // action. RoleAutomation Role = "automation" // RoleAuditor reads the audit log, the traces and the jobs, and the // health. It changes and runs nothing. RoleAuditor Role = "auditor" // RoleRead reads each thing that is not admin only. Logs, files and // process arguments can hold secrets, and read has them. RoleRead Role = "read" // RoleObserver is a dashboard or a monitor: the health, the status of // each host, and the agents with their facts. It reads no file, log or // command output. RoleObserver Role = "observer" )
The built-in roles, one for each kind of person or program that uses osapi. internal/authtoken gives each its permissions.
type RowStatus ¶
type RowStatus string
RowStatus is the status of one host in the answer of a behavior method: what happened on that host.
const ( // RowStatusOK is a host where the operation ran and succeeded. RowStatusOK RowStatus = "ok" // RowStatusFailed is a host where the operation ran and did not succeed. RowStatusFailed RowStatus = "failed" // RowStatusSkipped is a host whose OS family the operation does not // support, so it did not run there. RowStatusSkipped RowStatus = "skipped" // RowStatusTimeout is a host that did not answer. It is not failed: a // timeout says nothing about whether the operation ran, so an operator // has to go and look. RowStatusTimeout RowStatus = "timeout" )
The statuses of a host's row.
type Signal ¶
type Signal string
Signal is a signal that osapi sends to a process, by its name without SIG.
const ( // SignalTerm asks the process to stop. SignalTerm Signal = "TERM" // SignalKill stops the process at once. SignalKill Signal = "KILL" // SignalHup tells the process that its terminal closed; many daemons read their config again. SignalHup Signal = "HUP" // SignalInt interrupts the process, as Ctrl-C does. SignalInt Signal = "INT" // SignalUsr1 has the meaning that the program gives it. SignalUsr1 Signal = "USR1" // SignalUsr2 has the meaning that the program gives it. SignalUsr2 Signal = "USR2" )
The values of Signal: the signals.
type SpanStatus ¶
type SpanStatus string
SpanStatus is whether the work of a span failed.
const ( // SpanOK is a span whose work succeeded. SpanOK SpanStatus = "ok" // SpanError is a span whose work failed. SpanError SpanStatus = "error" )
The values of SpanStatus: the statuses of a span.
func (SpanStatus) Doc ¶
func (SpanStatus) Doc() string
Doc is what SpanStatus is, from its doc comment.
func (SpanStatus) Valid ¶
func (s SpanStatus) Valid() bool
Valid reports whether s is one of the values.
func (SpanStatus) Values ¶
func (SpanStatus) Values() []SpanStatus
Values are the statuses of a span.
type Step ¶
type Step struct {
// Behavior is the behavior that the step called, such as netplan.
Behavior string `json:"behavior"`
// Method is the method of the behavior, such as update.
Method string `json:"method"`
// Changed is true when the step changed the host, and false when it did
// not. It is nil for a method whose output has no changed field.
Changed *bool `json:"changed,omitempty"`
// Error is the error of a step that failed.
Error string `json:"error,omitempty"`
// DurationMS is how long the step ran, in milliseconds.
DurationMS int64 `json:"duration_ms"`
// Steps are the calls that the step made.
Steps []Step `json:"steps,omitempty"`
}
Step is one call of a behavior method that a job made on a host, with the calls that it made in turn: dns update calls netplan update, which calls managedfile update. A job's response has the steps that its method made. The format is the same wherever a step comes from, so a behavior that an extension serves returns its steps in it too.
type TypeSpec ¶
type TypeSpec struct {
// Name is the Go name of the type, such as ContentType.
Name string `json:"name"`
// Doc is what the type is, from its doc comment.
Doc string `json:"doc"`
// Values are its values, in the order of its Values.
Values []string `json:"values"`
}
TypeSpec is one closed set of the SDK: its name, what it is and its values. All lists them, so a program or an agent reads what the SDK has from the SDK itself.
type Verb ¶
type Verb string
Verb is the verb of a permission, the part after the colon of resource:verb. It also says whether a method of a behavior reads the host or changes it.
const ( // VerbRead reads and changes nothing. VerbRead Verb = "read" // VerbWrite changes something. The output of a write of a behavior // reports whether it did. VerbWrite Verb = "write" // VerbExecute is the permission verb of an action, such as a restart or // a reboot: it makes something happen on the host, but it does not change // what the host is configured to be. The operator role gets it and the // automation role does not. VerbExecute Verb = "execute" // VerbShell is the permission verb of an action that runs a shell // command line, which reaches anything the host can do. Only the admin // role gets a shell permission. VerbShell Verb = "shell" // VerbExec is the permission verb of an action that runs a command that // the caller gives inside something on the host, such as docker exec in // a container. Only the admin role gets an exec permission. VerbExec Verb = "exec" )
The verbs of a permission.