executor

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Overview

Copyright (C) 2020-2022 Daniele Rondina <geaaru@funtoo.org> Credits goes also to Gogs authors, some code portions and re-implemented design are also coming from the Gogs project, which is using the go-macaron framework and was really source of ispiration. Kudos to them!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright (C) 2020-2023 Daniele Rondina <geaaru@funtoo.org> Credits goes also to Gogs authors, some code portions and re-implemented design are also coming from the Gogs project, which is using the go-macaron framework and was really source of ispiration. Kudos to them!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright (C) 2020 Daniele Rondina <geaaru@sabayonlinux.org> Credits goes also to Gogs authors, some code portions and re-implemented design are also coming from the Gogs project, which is using the go-macaron framework and was really source of ispiration. Kudos to them!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright (C) 2020 Daniele Rondina <geaaru@sabayonlinux.org> Credits goes also to Gogs authors, some code portions and re-implemented design are also coming from the Gogs project, which is using the go-macaron framework and was really source of ispiration. Kudos to them!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright (C) 2020 Daniele Rondina <geaaru@sabayonlinux.org> Credits goes also to Gogs authors, some code portions and re-implemented design are also coming from the Gogs project, which is using the go-macaron framework and was really source of ispiration. Kudos to them!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Copyright © 2020-2024 Daniele Rondina <geaaru@gmail.com> See AUTHORS and LICENSE for the license details and contributors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LxdCEmitter added in v0.5.0

type LxdCEmitter struct {
	HostWriterStdout io.WriteCloser
	HostWriterStderr io.WriteCloser
	LxdWriterStdout  io.WriteCloser
	LxdWriterStderr  io.WriteCloser
}

func NewLxdCEmitter added in v0.5.0

func NewLxdCEmitter() *LxdCEmitter

func (*LxdCEmitter) DebugLog added in v0.5.0

func (e *LxdCEmitter) DebugLog(color bool, args ...interface{})

func (*LxdCEmitter) Emits added in v0.5.0

func (e *LxdCEmitter) Emits(eType LxdCExecutorEvent, data map[string]interface{})

func (*LxdCEmitter) ErrorLog added in v0.5.0

func (e *LxdCEmitter) ErrorLog(color bool, args ...interface{})

func (*LxdCEmitter) GetHostWriterStderr added in v0.6.0

func (e *LxdCEmitter) GetHostWriterStderr() io.WriteCloser

func (*LxdCEmitter) GetHostWriterStdout added in v0.6.0

func (e *LxdCEmitter) GetHostWriterStdout() io.WriteCloser

func (*LxdCEmitter) GetLxdWriterStderr added in v0.6.0

func (e *LxdCEmitter) GetLxdWriterStderr() io.WriteCloser

func (*LxdCEmitter) GetLxdWriterStdout added in v0.6.0

func (e *LxdCEmitter) GetLxdWriterStdout() io.WriteCloser

func (*LxdCEmitter) InfoLog added in v0.5.0

func (e *LxdCEmitter) InfoLog(color bool, args ...interface{})

func (*LxdCEmitter) SetHostWriterStderr added in v0.6.0

func (e *LxdCEmitter) SetHostWriterStderr(w io.WriteCloser)

func (*LxdCEmitter) SetHostWriterStdout added in v0.6.0

func (e *LxdCEmitter) SetHostWriterStdout(w io.WriteCloser)

func (*LxdCEmitter) SetLxdWriterStderr added in v0.6.0

func (e *LxdCEmitter) SetLxdWriterStderr(w io.WriteCloser)

func (*LxdCEmitter) SetLxdWriterStdout added in v0.6.0

func (e *LxdCEmitter) SetLxdWriterStdout(w io.WriteCloser)

func (*LxdCEmitter) WarnLog added in v0.5.0

func (e *LxdCEmitter) WarnLog(color bool, args ...interface{})

type LxdCEmitterWriter added in v0.6.0

type LxdCEmitterWriter struct {
	Type string
}

func NewLxdCEmitterWriter added in v0.6.0

func NewLxdCEmitterWriter(t string) *LxdCEmitterWriter

func (*LxdCEmitterWriter) Close added in v0.6.0

func (e *LxdCEmitterWriter) Close() error

func (*LxdCEmitterWriter) Write added in v0.6.0

func (e *LxdCEmitterWriter) Write(p []byte) (int, error)

type LxdCExecutor

type LxdCExecutor struct {
	LxdClient         lxd.ContainerServer
	LxdConfig         *lxd_config.Config
	ConfigDir         string
	Endpoint          string
	Entrypoint        []string
	Ephemeral         bool
	ShowCmdsOutput    bool
	RuntimeCmdsOutput bool
	P2PMode           bool
	WaitSleep         int
	LocalDisable      bool
	LegacyApi         bool

	Emitter LxdCExecutorEmitter
}

func NewLxdCExecutor

func NewLxdCExecutor(endpoint, configdir string, entrypoint []string, ephemeral, showCmdsOutput, runtimeCmdsOutput bool) *LxdCExecutor

func NewLxdCExecutorWithEmitter added in v0.6.0

func NewLxdCExecutorWithEmitter(endpoint, configdir string,
	entrypoint []string, ephemeral, showCmdsOutput,
	runtimeCmdsOutput bool, emitter LxdCExecutorEmitter) *LxdCExecutor

func (*LxdCExecutor) AddAlias2Image

func (e *LxdCExecutor) AddAlias2Image(fingerprint string, alias lxd_api.ImageAlias,
	server lxd.ContainerServer) error

func (*LxdCExecutor) AddProfiles2Container added in v0.32.0

func (e *LxdCExecutor) AddProfiles2Container(name string, profiles []string) error

func (*LxdCExecutor) AddProfiles2Instance added in v0.33.0

func (e *LxdCExecutor) AddProfiles2Instance(name string, profiles []string) error

func (*LxdCExecutor) CopyContainerOnInstance added in v0.26.0

func (e *LxdCExecutor) CopyContainerOnInstance(
	containerName, newContainerName string) error

func (*LxdCExecutor) CopyImage

func (e *LxdCExecutor) CopyImage(imageFingerprint string, remote lxd.ImageServer, to lxd.ContainerServer) error

func (*LxdCExecutor) CreateACL added in v0.22.0

func (e *LxdCExecutor) CreateACL(acl *specs.LxdCAcl) error

func (*LxdCExecutor) CreateContainer

func (e *LxdCExecutor) CreateContainer(name, fingerprint, imageServer string, profiles []string) error

func (*LxdCExecutor) CreateContainerWithConfig added in v0.18.0

func (e *LxdCExecutor) CreateContainerWithConfig(name, fingerprint, imageServer string, profiles []string, configMap map[string]string) error

func (*LxdCExecutor) CreateImageFromContainer added in v0.7.0

func (l *LxdCExecutor) CreateImageFromContainer(containerName string, aliases []string, properties map[string]string, compressionAlgorithm string, public bool) (string, error)

func (*LxdCExecutor) CreateNetwork added in v0.7.0

func (e *LxdCExecutor) CreateNetwork(net specs.LxdCNetwork) error

func (*LxdCExecutor) CreateProfile

func (e *LxdCExecutor) CreateProfile(profile specs.LxdCProfile) error

func (*LxdCExecutor) CreateStorage added in v0.15.0

func (e *LxdCExecutor) CreateStorage(sto specs.LxdCStorage) error

func (*LxdCExecutor) DeleteContainer

func (e *LxdCExecutor) DeleteContainer(containerName string) error

func (*LxdCExecutor) DeleteContainerDir added in v0.7.0

func (e *LxdCExecutor) DeleteContainerDir(name, dir string) error

func (*LxdCExecutor) DeleteImageAliases

func (e *LxdCExecutor) DeleteImageAliases(image *lxd_api.Image, server lxd.ContainerServer) error

Delete all local alias defined on input Image to avoid conflict on pull.

func (*LxdCExecutor) DeleteImageAliases4Alias

func (e *LxdCExecutor) DeleteImageAliases4Alias(imageAlias string, server lxd.ContainerServer) error

Delete alias from image of a specific ContainerServer if available

func (*LxdCExecutor) DeleteImageByFingerprint added in v0.29.0

func (e *LxdCExecutor) DeleteImageByFingerprint(f string) error

func (*LxdCExecutor) DoAction2Container

func (e *LxdCExecutor) DoAction2Container(name, action string) error

func (*LxdCExecutor) DownloadImage

func (e *LxdCExecutor) DownloadImage(imageFingerprint string, remote lxd.ImageServer) error

func (*LxdCExecutor) FindImage

func (e *LxdCExecutor) FindImage(image, imageRemoteServer string) (string, lxd.ImageServer, string, error)

func (*LxdCExecutor) GetAclList added in v0.22.0

func (e *LxdCExecutor) GetAclList() ([]string, error)

func (*LxdCExecutor) GetContainer added in v0.32.0

func (e *LxdCExecutor) GetContainer(name string) (*lxd_api.Container, string, error)

Get the container data and the ETag

func (*LxdCExecutor) GetContainerList

func (e *LxdCExecutor) GetContainerList() ([]string, error)

func (*LxdCExecutor) GetEmitter added in v0.6.0

func (e *LxdCExecutor) GetEmitter() LxdCExecutorEmitter

func (*LxdCExecutor) GetImage

func (e *LxdCExecutor) GetImage(image string, remote lxd.ImageServer) (*lxd_api.Image, error)

Retrieve Image from alias or fingerprint to a specific remote.

func (*LxdCExecutor) GetInstance added in v0.33.0

func (e *LxdCExecutor) GetInstance(name string) (*lxd_api.Instance, string, error)

Get instance data and the ETag

func (*LxdCExecutor) GetLegacyApi added in v0.33.0

func (e *LxdCExecutor) GetLegacyApi() bool

func (*LxdCExecutor) GetLocalDisable added in v0.7.0

func (e *LxdCExecutor) GetLocalDisable() bool

func (*LxdCExecutor) GetNetworkList added in v0.7.0

func (e *LxdCExecutor) GetNetworkList() ([]string, error)

func (*LxdCExecutor) GetP2PMode added in v0.7.0

func (e *LxdCExecutor) GetP2PMode() bool

func (*LxdCExecutor) GetProfilesList

func (e *LxdCExecutor) GetProfilesList() ([]string, error)

func (*LxdCExecutor) GetStorageList added in v0.15.0

func (e *LxdCExecutor) GetStorageList() ([]string, error)

func (*LxdCExecutor) IsEphemeralContainer added in v0.7.0

func (e *LxdCExecutor) IsEphemeralContainer(containerName string) (bool, error)

func (*LxdCExecutor) IsPresentACL added in v0.22.0

func (e *LxdCExecutor) IsPresentACL(name string) (bool, error)

func (*LxdCExecutor) IsPresentContainer

func (e *LxdCExecutor) IsPresentContainer(containerName string) (bool, error)

func (*LxdCExecutor) IsPresentNetwork added in v0.7.0

func (e *LxdCExecutor) IsPresentNetwork(name string) (bool, error)

func (*LxdCExecutor) IsPresentProfile

func (e *LxdCExecutor) IsPresentProfile(profileName string) (bool, error)

func (*LxdCExecutor) IsPresentStorage added in v0.15.0

func (e *LxdCExecutor) IsPresentStorage(name string) (bool, error)

func (*LxdCExecutor) IsRunningContainer added in v0.14.0

func (e *LxdCExecutor) IsRunningContainer(name string) (bool, error)

func (*LxdCExecutor) LaunchContainer

func (e *LxdCExecutor) LaunchContainer(name, fingerprint string, profiles []string) error

func (*LxdCExecutor) LaunchContainerType added in v0.7.0

func (e *LxdCExecutor) LaunchContainerType(name, fingerprint string, profiles []string, configMap map[string]string, ephemeral bool) error

func (*LxdCExecutor) LaunchContainerWithConfig added in v0.18.0

func (e *LxdCExecutor) LaunchContainerWithConfig(name, fingerprint string, profiles []string, configMap map[string]string) error

func (*LxdCExecutor) PullImage

func (e *LxdCExecutor) PullImage(imageAlias, imageRemoteServer string) (string, error)

func (*LxdCExecutor) PurgeImages added in v0.29.0

func (e *LxdCExecutor) PurgeImages(opts *PurgeOpts) error

func (*LxdCExecutor) RecursiveMkdir

func (e *LxdCExecutor) RecursiveMkdir(nameContainer string, dir string, mode *os.FileMode, uid int64, gid int64) error

Based on code of lxc client tool https://github.com/canonical/lxd/blob/master/lxc/file.go

func (*LxdCExecutor) RecursivePullFile added in v0.7.0

func (l *LxdCExecutor) RecursivePullFile(nameContainer string, destPath string, localPath string, localAsTarget bool) error

Based on code of lxc client tool https://github.com/canonical/lxd/blob/master/lxc/file.go

func (*LxdCExecutor) RecursivePushFile

func (e *LxdCExecutor) RecursivePushFile(nameContainer, source, target string) error

Based on code of lxc client tool https://github.com/canonical/lxd/blob/master/lxc/file.go

func (*LxdCExecutor) RemoveProfilesFromContainer added in v0.32.0

func (e *LxdCExecutor) RemoveProfilesFromContainer(name string, profiles []string) error

func (*LxdCExecutor) RemoveProfilesFromInstance added in v0.33.0

func (e *LxdCExecutor) RemoveProfilesFromInstance(name string, profiles []string) error

func (*LxdCExecutor) RunCommand

func (e *LxdCExecutor) RunCommand(containerName, command string, envs map[string]string, entryPoint []string) (int, error)

func (*LxdCExecutor) RunCommandWithOutput

func (e *LxdCExecutor) RunCommandWithOutput(containerName, command string, envs map[string]string, outBuffer, errBuffer io.WriteCloser, entryPoint []string) (int, error)

func (*LxdCExecutor) RunCommandWithOutput4Var

func (e *LxdCExecutor) RunCommandWithOutput4Var(containerName, command, outVar, errVar string, envs *map[string]string, entryPoint []string) (int, error)

func (*LxdCExecutor) RunHostCommand

func (e *LxdCExecutor) RunHostCommand(command string, envs map[string]string, entryPoint []string) (int, error)

func (*LxdCExecutor) RunHostCommandWithOutput

func (e *LxdCExecutor) RunHostCommandWithOutput(command string, envs map[string]string, outBuffer, errBuffer io.WriteCloser, entryPoint []string) (int, error)

func (*LxdCExecutor) RunHostCommandWithOutput4Var

func (e *LxdCExecutor) RunHostCommandWithOutput4Var(command, outVar, errVar string, envs *map[string]string, entryPoint []string) (int, error)

func (*LxdCExecutor) SetEmitter added in v0.6.0

func (e *LxdCExecutor) SetEmitter(emitter LxdCExecutorEmitter)

func (*LxdCExecutor) SetLegacyApi added in v0.33.0

func (e *LxdCExecutor) SetLegacyApi(a bool)

func (*LxdCExecutor) SetLocalDisable added in v0.7.0

func (e *LxdCExecutor) SetLocalDisable(v bool)

func (*LxdCExecutor) SetP2PMode added in v0.7.0

func (e *LxdCExecutor) SetP2PMode(m bool)

func (*LxdCExecutor) Setup

func (e *LxdCExecutor) Setup() error

func (*LxdCExecutor) StartContainer added in v0.7.0

func (e *LxdCExecutor) StartContainer(name string) error

func (*LxdCExecutor) StopContainer added in v0.7.0

func (e *LxdCExecutor) StopContainer(name string) error

func (*LxdCExecutor) SyncNetworkForwarders added in v0.23.0

func (e *LxdCExecutor) SyncNetworkForwarders(net *specs.LxdCNetwork) error

func (*LxdCExecutor) UpdateACL added in v0.22.0

func (e *LxdCExecutor) UpdateACL(acl *specs.LxdCAcl) error

func (*LxdCExecutor) UpdateContainer added in v0.32.0

func (e *LxdCExecutor) UpdateContainer(name string, cdata *lxd_api.ContainerPut, etag string) error

func (*LxdCExecutor) UpdateInstance added in v0.33.0

func (e *LxdCExecutor) UpdateInstance(
	name string, idata *lxd_api.InstancePut,
	etag string) error

func (*LxdCExecutor) UpdateNetwork added in v0.7.0

func (e *LxdCExecutor) UpdateNetwork(net specs.LxdCNetwork) error

func (*LxdCExecutor) UpdateProfile added in v0.8.0

func (e *LxdCExecutor) UpdateProfile(profile specs.LxdCProfile) error

func (*LxdCExecutor) UpdateStorage added in v0.15.0

func (e *LxdCExecutor) UpdateStorage(sto specs.LxdCStorage) error

func (*LxdCExecutor) WaitIpOfContainer added in v0.27.0

func (e *LxdCExecutor) WaitIpOfContainer(containerName string, timeout int64) error

func (*LxdCExecutor) WaitOperation added in v0.7.0

func (e *LxdCExecutor) WaitOperation(rawOp interface{}, p *lxd_cli.ProgressRenderer) error

type LxdCExecutorEmitter added in v0.5.0

type LxdCExecutorEmitter interface {
	Emits(eType LxdCExecutorEvent, data map[string]interface{})

	DebugLog(color bool, args ...interface{})
	InfoLog(color bool, args ...interface{})
	WarnLog(color bool, args ...interface{})
	ErrorLog(color bool, args ...interface{})
}

type LxdCExecutorEvent added in v0.5.0

type LxdCExecutorEvent string
const (
	LxdClientSetupDone     LxdCExecutorEvent = "client-setup"
	LxdContainerCreated    LxdCExecutorEvent = "container-created"
	LxdContainerUpdated    LxdCExecutorEvent = "container-updated"
	LxdContainerStarted    LxdCExecutorEvent = "container-started"
	LxdContainerStopped    LxdCExecutorEvent = "container-stopped"
	LxdContainerIpAssigned LxdCExecutorEvent = "container-ip"
)

type PurgeOpts added in v0.29.0

type PurgeOpts struct {
	All         bool
	Fingerprint string
	Matches     []string
	NoAliases   bool
}

Jump to

Keyboard shortcuts

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