client

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package client is a generated GoMock package.

Index

Constants

View Source
const (
	// DefaultBootIDPath is the path to the boot ID file.
	DefaultBootIDPath    = "/proc/sys/kernel/random/boot_id"
	SystemStatusFileName = "system.json"
)
View Source
const (
	BootcCmd = "bootc"
)

Variables

View Source
var (
	ErrEmptyResponse = errors.New("empty response")
)

Functions

func IsCommandAvailable added in v0.3.0

func IsCommandAvailable(cmdName string) bool

IsCommandAvailable checks if a command is available in the PATH.

func IsComposeAvailable added in v0.3.0

func IsComposeAvailable() bool

func IsPodmanRootless added in v0.3.0

func IsPodmanRootless() bool

func NewFromConfig

func NewFromConfig(config *baseclient.Config) (*client.ClientWithResponses, error)

NewFromConfig returns a new FlightCtl API client from the given config.

func NewGRPCClientFromConfig

func NewGRPCClientFromConfig(config *baseclient.Config) (grpc_v1.RouterServiceClient, error)

func SanitizePodmanLabel added in v0.4.0

func SanitizePodmanLabel(name string) string

SanitizePodmanLabel sanitizes a string to be used as a label in Podman. Podman labels must be lowercase and can only contain alpha numeric characters, hyphens, and underscores. Any other characters are replaced with an underscore.

Types

type AuthInfo

type AuthInfo = baseclient.AuthInfo

type Bootc added in v0.4.0

type Bootc interface {
	// Status returns the current bootc status.
	Status(ctx context.Context) (*container.BootcHost, error)
	// Switch targets a new container image reference to boot.
	Switch(ctx context.Context, image string) error
	// UsrOverlay adds a transient writable overlayfs on `/usr` that will be discarded on reboot.
	UsrOverlay(ctx context.Context) error
	// Apply restart or reboot into the new target image.
	Apply(ctx context.Context) error
}

func NewBootc added in v0.4.0

func NewBootc(log *log.PrefixLogger, executer executer.Executer) Bootc

NewBootc creates a new bootc client.

type ClientOption added in v0.4.0

type ClientOption func(*clientOptions)

ClientOption is a functional option for configuring the client.

func WithRetry added in v0.4.0

func WithRetry() ClientOption

WithRetry enables enables retry based on the backoff config provided.

type Compose added in v0.3.0

type Compose struct {
	*Podman
}

func (*Compose) Down added in v0.3.0

func (p *Compose) Down(ctx context.Context, path string) error

func (*Compose) Up added in v0.3.0

func (p *Compose) Up(ctx context.Context, path string) error

func (*Compose) UpFromWorkDir added in v0.3.0

func (p *Compose) UpFromWorkDir(ctx context.Context, workDir, projectName string, noRecreate bool) error

UpFromWorkDir runs `docker-compose up -d` or `podman-compose up -d` from the given workDir. The last argument is a flag to prevent recreation of existing containers.

type ComposeService added in v0.4.0

type ComposeService struct {
	Image         string `json:"image"`
	ContainerName string `json:"container_name"`
}

type ComposeSpec added in v0.4.0

type ComposeSpec struct {
	Services map[string]ComposeService `json:"services"`
}

func ParseComposeSpecFromDir added in v0.4.0

func ParseComposeSpecFromDir(reader fileio.Reader, dir string) (*ComposeSpec, error)

ParseComposeSpecFromDir reads a compose spec from the given directory and will perform a merge of the base {docker,podman}-compose.yaml and -override.yaml files.

func (*ComposeSpec) Images added in v0.4.0

func (c *ComposeSpec) Images() map[string]string

Images returns a map of service names to their images.

func (*ComposeSpec) Verify added in v0.4.0

func (c *ComposeSpec) Verify() error

Verify validates the compose spec.

type Config

type Config = baseclient.Config

func NewDefault

func NewDefault() *Config

type Enrollment

type Enrollment interface {
	SetRPCMetricsCallback(cb func(operation string, durationSeconds float64, err error))
	CreateEnrollmentRequest(ctx context.Context, req v1alpha1.EnrollmentRequest, cb ...client.RequestEditorFn) (*v1alpha1.EnrollmentRequest, error)
	GetEnrollmentRequest(ctx context.Context, id string, cb ...client.RequestEditorFn) (*v1alpha1.EnrollmentRequest, error)
}

Enrollment is client the interface for managing device enrollment.

func NewEnrollment

func NewEnrollment(
	client *client.ClientWithResponses,
) Enrollment

type ImageConfig added in v0.3.0

type ImageConfig struct {
	Labels map[string]string `json:"Labels"`
}

type Management

type Management interface {
	UpdateDeviceStatus(ctx context.Context, name string, device v1alpha1.Device, rcb ...client.RequestEditorFn) error
	GetRenderedDeviceSpec(ctx context.Context, name string, params *v1alpha1.GetRenderedDeviceSpecParams, rcb ...client.RequestEditorFn) (*v1alpha1.RenderedDeviceSpec, int, error)
}

Management is the client interface for managing devices.

func NewManagement

func NewManagement(
	client *client.ClientWithResponses,
) Management

type MockBootc added in v0.4.0

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

MockBootc is a mock of Bootc interface.

func NewMockBootc added in v0.4.0

func NewMockBootc(ctrl *gomock.Controller) *MockBootc

NewMockBootc creates a new mock instance.

func (*MockBootc) Apply added in v0.4.0

func (m *MockBootc) Apply(ctx context.Context) error

Apply mocks base method.

func (*MockBootc) EXPECT added in v0.4.0

func (m *MockBootc) EXPECT() *MockBootcMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBootc) Status added in v0.4.0

func (m *MockBootc) Status(ctx context.Context) (*container.BootcHost, error)

Status mocks base method.

func (*MockBootc) Switch added in v0.4.0

func (m *MockBootc) Switch(ctx context.Context, image string) error

Switch mocks base method.

func (*MockBootc) UsrOverlay added in v0.4.0

func (m *MockBootc) UsrOverlay(ctx context.Context) error

UsrOverlay mocks base method.

type MockBootcMockRecorder added in v0.4.0

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

MockBootcMockRecorder is the mock recorder for MockBootc.

func (*MockBootcMockRecorder) Apply added in v0.4.0

func (mr *MockBootcMockRecorder) Apply(ctx any) *gomock.Call

Apply indicates an expected call of Apply.

func (*MockBootcMockRecorder) Status added in v0.4.0

func (mr *MockBootcMockRecorder) Status(ctx any) *gomock.Call

Status indicates an expected call of Status.

func (*MockBootcMockRecorder) Switch added in v0.4.0

func (mr *MockBootcMockRecorder) Switch(ctx, image any) *gomock.Call

Switch indicates an expected call of Switch.

func (*MockBootcMockRecorder) UsrOverlay added in v0.4.0

func (mr *MockBootcMockRecorder) UsrOverlay(ctx any) *gomock.Call

UsrOverlay indicates an expected call of UsrOverlay.

type MockEnrollment

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

MockEnrollment is a mock of Enrollment interface.

func NewMockEnrollment

func NewMockEnrollment(ctrl *gomock.Controller) *MockEnrollment

NewMockEnrollment creates a new mock instance.

func (*MockEnrollment) CreateEnrollmentRequest

CreateEnrollmentRequest mocks base method.

func (*MockEnrollment) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockEnrollment) GetEnrollmentRequest

func (m *MockEnrollment) GetEnrollmentRequest(ctx context.Context, id string, cb ...client.RequestEditorFn) (*v1alpha1.EnrollmentRequest, error)

GetEnrollmentRequest mocks base method.

func (*MockEnrollment) SetRPCMetricsCallback

func (m *MockEnrollment) SetRPCMetricsCallback(cb func(string, float64, error))

SetRPCMetricsCallback mocks base method.

type MockEnrollmentMockRecorder

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

MockEnrollmentMockRecorder is the mock recorder for MockEnrollment.

func (*MockEnrollmentMockRecorder) CreateEnrollmentRequest

func (mr *MockEnrollmentMockRecorder) CreateEnrollmentRequest(ctx, req any, cb ...any) *gomock.Call

CreateEnrollmentRequest indicates an expected call of CreateEnrollmentRequest.

func (*MockEnrollmentMockRecorder) GetEnrollmentRequest

func (mr *MockEnrollmentMockRecorder) GetEnrollmentRequest(ctx, id any, cb ...any) *gomock.Call

GetEnrollmentRequest indicates an expected call of GetEnrollmentRequest.

func (*MockEnrollmentMockRecorder) SetRPCMetricsCallback

func (mr *MockEnrollmentMockRecorder) SetRPCMetricsCallback(cb any) *gomock.Call

SetRPCMetricsCallback indicates an expected call of SetRPCMetricsCallback.

type MockManagement

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

MockManagement is a mock of Management interface.

func NewMockManagement

func NewMockManagement(ctrl *gomock.Controller) *MockManagement

NewMockManagement creates a new mock instance.

func (*MockManagement) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockManagement) GetRenderedDeviceSpec

GetRenderedDeviceSpec mocks base method.

func (*MockManagement) UpdateDeviceStatus

func (m *MockManagement) UpdateDeviceStatus(ctx context.Context, name string, device v1alpha1.Device, rcb ...client.RequestEditorFn) error

UpdateDeviceStatus mocks base method.

type MockManagementMockRecorder

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

MockManagementMockRecorder is the mock recorder for MockManagement.

func (*MockManagementMockRecorder) GetRenderedDeviceSpec

func (mr *MockManagementMockRecorder) GetRenderedDeviceSpec(ctx, name, params any, rcb ...any) *gomock.Call

GetRenderedDeviceSpec indicates an expected call of GetRenderedDeviceSpec.

func (*MockManagementMockRecorder) UpdateDeviceStatus

func (mr *MockManagementMockRecorder) UpdateDeviceStatus(ctx, name, device any, rcb ...any) *gomock.Call

UpdateDeviceStatus indicates an expected call of UpdateDeviceStatus.

type MockSystem added in v0.4.0

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

MockSystem is a mock of System interface.

func NewMockSystem added in v0.4.0

func NewMockSystem(ctrl *gomock.Controller) *MockSystem

NewMockSystem creates a new mock instance.

func (*MockSystem) BootID added in v0.4.0

func (m *MockSystem) BootID() string

BootID mocks base method.

func (*MockSystem) BootTime added in v0.4.0

func (m *MockSystem) BootTime() string

BootTime mocks base method.

func (*MockSystem) EXPECT added in v0.4.0

func (m *MockSystem) EXPECT() *MockSystemMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSystem) Initialize added in v0.4.0

func (m *MockSystem) Initialize() error

Initialize mocks base method.

func (*MockSystem) IsRebooted added in v0.4.0

func (m *MockSystem) IsRebooted() bool

IsRebooted mocks base method.

type MockSystemMockRecorder added in v0.4.0

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

MockSystemMockRecorder is the mock recorder for MockSystem.

func (*MockSystemMockRecorder) BootID added in v0.4.0

func (mr *MockSystemMockRecorder) BootID() *gomock.Call

BootID indicates an expected call of BootID.

func (*MockSystemMockRecorder) BootTime added in v0.4.0

func (mr *MockSystemMockRecorder) BootTime() *gomock.Call

BootTime indicates an expected call of BootTime.

func (*MockSystemMockRecorder) Initialize added in v0.4.0

func (mr *MockSystemMockRecorder) Initialize() *gomock.Call

Initialize indicates an expected call of Initialize.

func (*MockSystemMockRecorder) IsRebooted added in v0.4.0

func (mr *MockSystemMockRecorder) IsRebooted() *gomock.Call

IsRebooted indicates an expected call of IsRebooted.

type Podman added in v0.3.0

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

func NewPodman added in v0.3.0

func NewPodman(log *log.PrefixLogger, exec executer.Executer, backoff wait.Backoff) *Podman

func (*Podman) Compose added in v0.3.0

func (p *Podman) Compose() *Compose

func (*Podman) Copy added in v0.3.0

func (p *Podman) Copy(ctx context.Context, src, dst string) error

func (*Podman) EventsSinceCmd added in v0.3.0

func (p *Podman) EventsSinceCmd(ctx context.Context, events []string, sinceTime string) *exec.Cmd

EventsSinceCmd returns a command to get podman events since the given time. After creating the command, it should be started with exec.Start(). When the events are in sync with the current time a sync event is emitted.

func (*Podman) ImageExists added in v0.3.0

func (p *Podman) ImageExists(ctx context.Context, image string) bool

func (*Podman) Inspect added in v0.3.0

func (p *Podman) Inspect(ctx context.Context, image string) (string, error)

Inspect returns the JSON output of the image inspection. The expectation is that the image exists in local container storage.

func (*Podman) InspectLabels added in v0.3.0

func (p *Podman) InspectLabels(ctx context.Context, image string) (map[string]string, error)

func (*Podman) ListNetworks added in v0.3.0

func (p *Podman) ListNetworks(ctx context.Context, labels []string) ([]string, error)

func (*Podman) Mount added in v0.3.0

func (p *Podman) Mount(ctx context.Context, image string) (string, error)

func (*Podman) Pull added in v0.3.0

func (p *Podman) Pull(ctx context.Context, image string, opts ...ClientOption) (resp string, err error)

Pull pulls the image from the registry and the response. Users can pass in options to configure the client.

func (*Podman) RemoveContainer added in v0.3.0

func (p *Podman) RemoveContainer(ctx context.Context, labels []string) error

func (*Podman) RemoveNetworks added in v0.3.0

func (p *Podman) RemoveNetworks(ctx context.Context, networks ...string) error

func (*Podman) RemoveVolumes added in v0.3.0

func (p *Podman) RemoveVolumes(ctx context.Context, labels []string) error

func (*Podman) StopContainers added in v0.3.0

func (p *Podman) StopContainers(ctx context.Context, labels []string) error

func (*Podman) Unmount added in v0.3.0

func (p *Podman) Unmount(ctx context.Context, image string) error

func (*Podman) Unshare added in v0.3.0

func (p *Podman) Unshare(ctx context.Context, args ...string) (string, error)

type RPMOSTree added in v0.4.0

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

func NewRPMOSTree added in v0.4.0

func NewRPMOSTree(exec executer.Executer) *RPMOSTree

NewRPMOSTree creates a new rpm-ostree client.

func (*RPMOSTree) Apply added in v0.4.0

func (c *RPMOSTree) Apply(ctx context.Context) error

func (*RPMOSTree) RemoveRollback added in v0.4.0

func (c *RPMOSTree) RemoveRollback(_ context.Context) error

func (*RPMOSTree) RemoveStaged added in v0.4.0

func (c *RPMOSTree) RemoveStaged(_ context.Context) error

func (*RPMOSTree) Status added in v0.4.0

func (c *RPMOSTree) Status(_ context.Context) (*container.BootcHost, error)

func (*RPMOSTree) Switch added in v0.4.0

func (c *RPMOSTree) Switch(_ context.Context, target string) error

type Service

type Service = baseclient.Service

type System added in v0.4.0

type System interface {
	// Initialize initializes the system client.
	Initialize() error
	// IsRebooted returns true if the system has been rebooted since the last boot.
	IsRebooted() bool
	// BootTime returns the time the system was booted as a string.
	BootTime() string
	// BootID returns the unique boot ID populated by the kernel. This is
	// expected to be empty for integration and simulation tests.
	BootID() string
}

func NewSystem added in v0.4.0

func NewSystem(exec executer.Executer, readWriter fileio.ReadWriter, dataDir string) System

NewSystem creates a new system client.

type Systemd

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

func NewSystemd

func NewSystemd(exec executer.Executer) *Systemd

func (*Systemd) DaemonReload

func (s *Systemd) DaemonReload(ctx context.Context) error

func (*Systemd) Disable

func (s *Systemd) Disable(ctx context.Context, name string) error

func (*Systemd) Enable

func (s *Systemd) Enable(ctx context.Context, name string) error

func (*Systemd) ListUnitsByMatchPattern added in v0.4.0

func (s *Systemd) ListUnitsByMatchPattern(ctx context.Context, matchPatterns []string) (string, error)

func (*Systemd) Reboot added in v0.4.0

func (s *Systemd) Reboot(ctx context.Context) error

func (*Systemd) Reload

func (s *Systemd) Reload(ctx context.Context, name string) error

func (*Systemd) Restart

func (s *Systemd) Restart(ctx context.Context, name string) error

func (*Systemd) Start

func (s *Systemd) Start(ctx context.Context, name string) error

func (*Systemd) Stop

func (s *Systemd) Stop(ctx context.Context, name string) error

Jump to

Keyboard shortcuts

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