Documentation
¶
Overview ¶
Package hook is a generated GoMock package.
Index ¶
- Constants
- type CertificateMetadata
- type CommandLineVarKey
- type EnrollmentActionResult
- type EnrollmentContext
- type Manager
- type MockManager
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) OnAfterEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
- func (m *MockManager) OnAfterRebooting(ctx context.Context) error
- func (m *MockManager) OnAfterUpdating(ctx context.Context, current, desired *v1beta1.DeviceSpec, systemRebooted bool) error
- func (m *MockManager) OnBeforeEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
- func (m *MockManager) OnBeforeRebooting(ctx context.Context) error
- func (m *MockManager) OnBeforeUpdating(ctx context.Context, current, desired *v1beta1.DeviceSpec) error
- func (m *MockManager) Sync(current, desired *v1beta1.DeviceSpec) error
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) OnAfterEnrolling(ctx, enrollCtx any) *gomock.Call
- func (mr *MockManagerMockRecorder) OnAfterRebooting(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) OnAfterUpdating(ctx, current, desired, systemRebooted any) *gomock.Call
- func (mr *MockManagerMockRecorder) OnBeforeEnrolling(ctx, enrollCtx any) *gomock.Call
- func (mr *MockManagerMockRecorder) OnBeforeRebooting(ctx any) *gomock.Call
- func (mr *MockManagerMockRecorder) OnBeforeUpdating(ctx, current, desired any) *gomock.Call
- func (mr *MockManagerMockRecorder) Sync(current, desired any) *gomock.Call
Constants ¶
const ( // HookContextDir is the runtime directory for hook context files. HookContextDir = "/run/flightctl" // HookContextFile is the filename for the hook context JSON. HookContextFile = "hook-context.json" // HookContextPath is the full path to the hook context JSON file. HookContextPath = "/run/flightctl/hook-context.json" // HookContextMode is the file permission for the hook context file (owner read/write only). HookContextMode = 0600 )
const ( // ReadOnlyConfigDir is where read-only configuration files are stored ReadOnlyConfigDir = "/usr/lib/flightctl" // ReadOnlyConfigDir is where read-only configuration files are stored UserWritableConfigDir = "/etc/flightctl" // HooksDropInDirName is the subdirectory in which hooks are stored HooksDropInDirName = "hooks.d" )
TODO: Deduplicate with internal/agent/config.go after agreeing how to best break import cycles
const HookLabelsPath = "/run/flightctl/hook-labels.json"
HookLabelsPath is the well-known file where pre-enrollment hooks write labels.
const MaxEnrollmentHookActionOutput = 4096
MaxEnrollmentHookActionOutput bounds stdout+stderr capture per enrollment hook action (4096 bytes total: 2048 per stream at the executor).
const MaxHookLabelsFileSize = 16 * 1024
MaxHookLabelsFileSize is the maximum allowed size of hook-labels.json.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CertificateMetadata ¶ added in v1.4.0
type CertificateMetadata struct {
// SerialNumber is the certificate serial number as colon-separated uppercase hex
// (e.g. "46:E5:42:26:2B:79:34:F2").
SerialNumber string `json:"serialNumber"`
// NotAfter is the certificate expiry time formatted as RFC 3339
// (e.g. "2027-09-06T00:00:00Z").
NotAfter string `json:"notAfter"`
// SHA256 is the lowercase hex SHA-256 fingerprint of the DER-encoded certificate.
SHA256 string `json:"sha256"`
}
CertificateMetadata contains management certificate identity info (no private key).
func ParseCertMetadata ¶ added in v1.4.0
func ParseCertMetadata(pemData []byte) (*CertificateMetadata, error)
ParseCertMetadata extracts identity metadata from a PEM-encoded certificate. Returns nil, nil for nil/empty input (pre-enrollment case). Returns error for malformed PEM.
String formats:
- serialNumber: colon-separated uppercase hex (e.g. "46:E5:42:26:2B:79:34:F2")
- notAfter: RFC 3339 via time.RFC3339 (e.g. "2027-09-06T00:00:00Z")
- sha256: lowercase hex fingerprint of DER bytes
type CommandLineVarKey ¶ added in v0.4.0
type CommandLineVarKey string
const ( DefaultHookActionTimeout = 10 * time.Second // PathKey defines the name of the variable that contains the path operated on PathKey CommandLineVarKey = "Path" // FilesKey defines the name of the variable that contains a space- // separated list of files created, updated, or removed during the update FilesKey CommandLineVarKey = "Files" // CreatedKey defines the name of the variable that contains a space- // separated list of files created during the update CreatedKey CommandLineVarKey = "CreatedFiles" // UpdatedKey defines the name of the variable that contains a space- // separated list of files updated during the update UpdatedKey CommandLineVarKey = "UpdatedFiles" // RemovedKey defines the name of the variable that contains a space- // separated list of files removed during the update RemovedKey CommandLineVarKey = "RemovedFiles" // BackupKey defines the name of the variable that contains a space- // separated list of files backed up before removal from the system // into a temporary location deleted after the action completes. BackupKey CommandLineVarKey = "BackupFiles" )
type EnrollmentActionResult ¶ added in v1.4.0
EnrollmentActionResult is the outcome of a single executed enrollment hook action.
type EnrollmentContext ¶ added in v1.4.0
type EnrollmentContext struct {
// Input fields (set by caller before OnBeforeEnrolling)
DeviceName string
SystemInfo map[string]interface{}
Labels map[string]string
ManagementCertificate *CertificateMetadata
// Result fields (populated by OnBeforeEnrolling)
Success bool
Actions []EnrollmentActionResult
HookLabels map[string]string
}
EnrollmentContext carries device metadata for enrollment hook execution. Callers populate input fields before invoking OnBeforeEnrolling/OnAfterEnrolling. Result fields are populated by the hook manager after execution.
type Manager ¶
type Manager interface {
Sync(current, desired *api.DeviceSpec) error
OnBeforeUpdating(ctx context.Context, current *api.DeviceSpec, desired *api.DeviceSpec) error
OnAfterUpdating(ctx context.Context, current *api.DeviceSpec, desired *api.DeviceSpec, systemRebooted bool) error
OnBeforeRebooting(ctx context.Context) error
OnAfterRebooting(ctx context.Context) error
// Enrollment hook methods — added by EDM-5701.
// Callers provide an EnrollmentContext with device metadata; the hook type
// string is set internally by each method.
OnBeforeEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
OnAfterEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
}
func NewManager ¶
func NewManager(readWriter fileio.ReadWriter, exec executer.Executer, log *log.PrefixLogger) Manager
NewManager creates a hook manager. The readWriter provides both read access for loading hook YAML and write access for writing hook-context.json.
type MockManager ¶
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) EXPECT ¶
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) OnAfterEnrolling ¶ added in v1.4.0
func (m *MockManager) OnAfterEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
OnAfterEnrolling mocks base method.
func (*MockManager) OnAfterRebooting ¶ added in v0.4.0
func (m *MockManager) OnAfterRebooting(ctx context.Context) error
OnAfterRebooting mocks base method.
func (*MockManager) OnAfterUpdating ¶ added in v0.4.0
func (m *MockManager) OnAfterUpdating(ctx context.Context, current, desired *v1beta1.DeviceSpec, systemRebooted bool) error
OnAfterUpdating mocks base method.
func (*MockManager) OnBeforeEnrolling ¶ added in v1.4.0
func (m *MockManager) OnBeforeEnrolling(ctx context.Context, enrollCtx *EnrollmentContext) error
OnBeforeEnrolling mocks base method.
func (*MockManager) OnBeforeRebooting ¶ added in v0.4.0
func (m *MockManager) OnBeforeRebooting(ctx context.Context) error
OnBeforeRebooting mocks base method.
func (*MockManager) OnBeforeUpdating ¶ added in v0.4.0
func (m *MockManager) OnBeforeUpdating(ctx context.Context, current, desired *v1beta1.DeviceSpec) error
OnBeforeUpdating mocks base method.
func (*MockManager) Sync ¶
func (m *MockManager) Sync(current, desired *v1beta1.DeviceSpec) error
Sync mocks base method.
type MockManagerMockRecorder ¶
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) OnAfterEnrolling ¶ added in v1.4.0
func (mr *MockManagerMockRecorder) OnAfterEnrolling(ctx, enrollCtx any) *gomock.Call
OnAfterEnrolling indicates an expected call of OnAfterEnrolling.
func (*MockManagerMockRecorder) OnAfterRebooting ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) OnAfterRebooting(ctx any) *gomock.Call
OnAfterRebooting indicates an expected call of OnAfterRebooting.
func (*MockManagerMockRecorder) OnAfterUpdating ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) OnAfterUpdating(ctx, current, desired, systemRebooted any) *gomock.Call
OnAfterUpdating indicates an expected call of OnAfterUpdating.
func (*MockManagerMockRecorder) OnBeforeEnrolling ¶ added in v1.4.0
func (mr *MockManagerMockRecorder) OnBeforeEnrolling(ctx, enrollCtx any) *gomock.Call
OnBeforeEnrolling indicates an expected call of OnBeforeEnrolling.
func (*MockManagerMockRecorder) OnBeforeRebooting ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) OnBeforeRebooting(ctx any) *gomock.Call
OnBeforeRebooting indicates an expected call of OnBeforeRebooting.
func (*MockManagerMockRecorder) OnBeforeUpdating ¶ added in v0.4.0
func (mr *MockManagerMockRecorder) OnBeforeUpdating(ctx, current, desired any) *gomock.Call
OnBeforeUpdating indicates an expected call of OnBeforeUpdating.