Documentation
¶
Index ¶
- Constants
- Variables
- func CheckBridgeFirewall(bridgeName string) string
- func ConnectLxd(ctx context.Context) (lxd.InstanceServer, error)
- func DeviceConfigKey(name string) string
- func DeviceName(parts ...string) string
- func DeviceTypeConfigKey(name string) string
- func ErrorLxdBackend(err error) error
- func FakeImageServer(server string) func()
- func FakeStartCommand(script string) func()
- func InstanceName(name string, project_id string) string
- func IsImportSdkConflict(err error) bool
- func IsImportSdkOperation(op api.Operation, name string) (bool, error)
- func IsInstanceConflict(err error, name string) bool
- func IsInstanceOperation(op api.Operation, lxdProject, name string) (bool, error)
- func LxdProfile(conn lxd.InstanceServer, pid, wp, profile string) (*api.Profile, string, error)
- func LxdToSdkProfile(profile string, devs map[string]map[string]string, config map[string]string) (workshop.SdkProfile, error)
- func NewNetworkManager() workshop.NetworkManager
- func Profile(conn lxd.InstanceServer, pid, wp, profile string) (workshop.SdkProfile, error)
- func ProfileName(pid, workshop, sdk string) string
- type Backend
- func (s *Backend) AddWorkshopMount(ctx context.Context, name string, mount workshop.Mount) error
- func (s *Backend) CreateOrLoadProject(ctx context.Context, path string) (*workshop.Project, bool, error)
- func (s *Backend) DeleteSdk(ctx context.Context, setup sdk.Setup) error
- func (b *Backend) DownloadBase(ctx context.Context, image workshop.BaseImage, report *progress.Reporter) error
- func (s *Backend) Exec(ctx context.Context, name string, args *workshop.Execution) (workshop.ExecContext, error)
- func (s *Backend) FormatRevision() sdk.Revision
- func (b *Backend) GetBase(ctx context.Context, base string) (workshop.BaseImage, error)
- func (s *Backend) HashSnapshot(snapshot workshop.Snapshot) (string, error)
- func (s *Backend) ImportSdk(ctx context.Context, meta sdk.Meta, tarball *os.File) error
- func (s *Backend) InstallSdk(ctx context.Context, name string, setup sdk.Setup) error
- func (s *Backend) LaunchOrRebuildWorkshop(ctx context.Context, file *workshop.File, snapshot workshop.Snapshot) error
- func (s *Backend) LxdClient(ctx context.Context) (lxd.InstanceServer, error)
- func (s *Backend) ProjectWorkshops(ctx context.Context) ([]*workshop.Workshop, error)
- func (s *Backend) Projects(ctx context.Context) (map[string][]workshop.Project, error)
- func (s *Backend) RemoveSnapshot(ctx context.Context, snapshot workshop.Snapshot) error
- func (s *Backend) RemoveWorkshop(ctx context.Context, name string) (err error)
- func (s *Backend) RemoveWorkshopMount(ctx context.Context, name, mount string) error
- func (s *Backend) RemoveWorkshopStash(ctx context.Context, name string) error
- func (s *Backend) Sdk(ctx context.Context, setup sdk.Setup) (workshop.SdkVolume, error)
- func (s *Backend) Sdks(ctx context.Context) ([]workshop.SdkVolume, error)
- func (s *Backend) Snapshot(ctx context.Context, snapshot workshop.Snapshot) (*workshop.SnapshotInfo, error)
- func (s *Backend) StartWorkshop(ctx context.Context, name string) error
- func (s *Backend) StashWorkshop(ctx context.Context, name string) error
- func (s *Backend) StopWorkshop(ctx context.Context, name string, force bool) error
- func (s *Backend) TakeSnapshot(ctx context.Context, name string, snapshot workshop.Snapshot) error
- func (s *Backend) UninstallSdk(ctx context.Context, name, sk string) error
- func (s *Backend) UnstashWorkshop(ctx context.Context, name string) error
- func (s *Backend) Workshop(ctx context.Context, name string) (*workshop.Workshop, error)
- func (s *Backend) WorkshopFs(ctx context.Context, name string) (fsutil.Fs, error)
Constants ¶
const ( // NetworkBridgeName is the name of the LXD bridge network used by // workshops, exported for use by other packages (e.g. firewall checks). NetworkBridgeName = networkName )
Variables ¶
var (
ConnectSimpleStreams = lxd.ConnectSimpleStreams
)
Functions ¶
func CheckBridgeFirewall ¶
CheckBridgeFirewall detects whether firewall rules block forwarding on the workshop bridge. It returns a non-empty warning message with a proposed resolution if an issue is detected, or an empty string if everything looks fine.
Detection is cause-agnostic: it checks whether the FORWARD chain policy is DROP/REJECT and whether any rules ACCEPT traffic for the bridge. The remediation advice is cause-aware: it suggests Docker-specific, UFW-specific, or generic commands depending on what is found.
Uses `nft -j` (JSON output) for structured, robust parsing.
See: https://documentation.ubuntu.com/lxd/latest/howto/network_bridge_firewalld/
func ConnectLxd ¶
func ConnectLxd(ctx context.Context) (lxd.InstanceServer, error)
func DeviceConfigKey ¶
func DeviceName ¶
func DeviceTypeConfigKey ¶
func ErrorLxdBackend ¶
func FakeImageServer ¶
func FakeImageServer(server string) func()
func FakeStartCommand ¶
func FakeStartCommand(script string) func()
func InstanceName ¶
func IsImportSdkConflict ¶
Export this so the LXD candidate tests pick up error message changes.
func IsImportSdkOperation ¶
Export this so the LXD candidate tests pick up format changes.
func IsInstanceConflict ¶
func IsInstanceOperation ¶
func LxdProfile ¶
func LxdToSdkProfile ¶
func NewNetworkManager ¶ added in v0.9.2
func NewNetworkManager() workshop.NetworkManager
func Profile ¶
func Profile(conn lxd.InstanceServer, pid, wp, profile string) (workshop.SdkProfile, error)
func ProfileName ¶
Types ¶
type Backend ¶
type Backend struct {
}
func New ¶
New constructs the LXD backend and attempts to prepare the required LXD storage pool and network. It always returns a usable backend; if LXD is not yet ready the error is reported by the system check (see init), which puts the daemon into degraded mode and retries until LXD becomes available.
func (*Backend) AddWorkshopMount ¶
func (*Backend) CreateOrLoadProject ¶
func (*Backend) DownloadBase ¶
func (*Backend) FormatRevision ¶
Hard coded number which represents the current "snapshot format," i.e. the contents of the rootfs after installing a certain sequence of SDKs. This can be influenced by a number of factors, including: - Default workshop config (e.g. cloud-config) - Default workshop devices (e.g. apt cache) - SDK config and devices (e.g. volume mounts) - Direct modifications (e.g. mkdir /var/lib/workshop/run) If something like this changes, bump the revision number so that workshops constructed using the next release of Workshop are updated on refresh.
Some care needs to be taken with workshops using the old format. If a launch or refresh is in progress, it should either continue in a manner consistent with the old format, or fail if that isn't possible for some reason. For example, after changing the format of installed SDKs, the install-sdk task should either use a format consistent with the target workshop, or fail for workshops stuck on the old format.
Another issue is the restore command. In most cases this simply rebuilds from the last snapshot, but if that snapshot doesn't exist then it will replay some of the install-sdk and setup-base tasks. These can be handled in the same way as in-progress launches and refreshes.