Documentation ¶
Overview ¶
taken from https://github.com/congop/go-virtualbox/blob/master/cmd_arg.go
Index ¶
- Constants
- func DecodeJsonFile[T any](usecaseCtx string, ctx context.Context, jsonFilepath string) (*T, error)
- func ImageRm(ctx context.Context, req ImageDeleteRequest) error
- func ImgId(name, version, platform, imgType string) (string, error)
- func IsRepoTypeHttp(repoType string) bool
- func IsRepoTypeS3(repoType string) bool
- func StringNotEmpty(str string) bool
- type AuthHttpBasic
- type AwsCredentials
- type CmdArgOpaqueStr
- type CmdArgStr
- type CmdArgs
- type CmdImgPull
- type CmdImgRm
- type CmdMultiArgStr
- type CmdVmLs
- type CmdVmRm
- type CmdVmRun
- type CmdVmStart
- type CmdVmStop
- type ExecOutcome
- type HttpRepo
- type ICmdArg
- type ImageDeleteRequest
- type ImageTagMetaData
- type LsCmdRes
- type LsRequest
- type LsResult
- type ParsedImgId
- type Platform
- type PlatformSw
- type PullRequest
- type PullResult
- type Reference
- type Repos
- type RequestSayaCtx
- type S3Repo
- type SayaCmd
- func (sayaCmd SayaCmd) Exec(ctx context.Context) (ExecOutcome, error)
- func (sayaCmd *SayaCmd) WithCfgFile(cfg string)
- func (sayaCmd *SayaCmd) WithForgeLocation(forgeLocation string)
- func (sayaCmd *SayaCmd) WithLicenseKey(lk opaque.String)
- func (sayaCmd *SayaCmd) WithLogLevel(logLevel string)
- func (sayaCmd *SayaCmd) WithRequestSayaCtx(req RequestSayaCtx)
- type SayaCmdLs
- type VmLsRequest
- type VmLsResult
- type VmLsResultCmd
- type VmRmRequest
- type VmRmResult
- type VmRunRequest
- type VmRunResult
- type VmRunResultCmd
- type VmRunResultCmdSsh
- type VmStartRequest
- type VmStartResult
- type VmStopRequest
- type VmStopResult
Constants ¶
const RepoTypeHttp = "http"
const RepoTypeS3 = "s3"
Variables ¶
This section is empty.
Functions ¶
func DecodeJsonFile ¶
func ImgId ¶
ImgId return an id which can be used to identify a tagged image in a repository. The format is <platform>:<name>:<version>:<imgType> where:
<platform> = os/arch[os-variant] ;
name = the name of the image
version = the version or tag of the image
imgType = the type of the image (e.g. ova, vmdk, img, qcow2, ...)
func IsRepoTypeHttp ¶
func IsRepoTypeS3 ¶
func StringNotEmpty ¶
Types ¶
type AuthHttpBasic ¶
type AwsCredentials ¶
type AwsCredentials struct { // AWS Access key ID AccessKeyID string //revive:disable-line:var-naming // AWS Secret Access Key SecretAccessKey string // AWS Session Token SessionToken string // Source of the credentials Source string // Time the credentials will expire. CanExpire bool Expires *time.Time }
func (*AwsCredentials) HasExpires ¶
func (cred *AwsCredentials) HasExpires() bool
func (*AwsCredentials) NormalizeToNil ¶
func (cred *AwsCredentials) NormalizeToNil() *AwsCredentials
type CmdArgOpaqueStr ¶
type CmdArgOpaqueStr struct { K string //Args key. e.g. --accelerated V *opaque.String // V value. nil if arg does not allow value specification. Note that empty string "" is a valid value, and different from nil. ToCmdArgParts func(K string, V opaque.String) []string // Del bool // if true deleted, the arg will not be part of the final command }
func (*CmdArgOpaqueStr) CmdArgs ¶
func (arg *CmdArgOpaqueStr) CmdArgs() []string
func (*CmdArgOpaqueStr) CmdArgsDisplay ¶
func (arg *CmdArgOpaqueStr) CmdArgsDisplay() []string
func (*CmdArgOpaqueStr) Key ¶
func (arg *CmdArgOpaqueStr) Key() string
func (*CmdArgOpaqueStr) ToDel ¶
func (arg *CmdArgOpaqueStr) ToDel() bool
type CmdArgStr ¶
type CmdArgStr struct { K string //Args key. e.g. --accelerated V *string // V value. nil if arg does not allow value specification. Note that empty string "" is a valid value, and different from nil. ToCmdArgParts func(K, V string) []string // Del bool // if true deleted, the arg will not be part of the final command }
CmdArgStr models a command arg, which can be a flag or not.
func NewCmdArgDeleted ¶
func NewCmdArgNoValue ¶
func (*CmdArgStr) CmdArgsDisplay ¶
type CmdArgs ¶
type CmdArgs struct {
// contains filtered or unexported fields
}
func (*CmdArgs) AppendCmdArgs ¶
func (*CmdArgs) AppendNoValue ¶
func (*CmdArgs) AppendOverride ¶
func (CmdArgs) Args ¶
Args returns an slice containing the args which can be use in a command execution context. Args with multiple occurrence are not supported we will be overriding values.
func (CmdArgs) ArgsDisplay ¶
type CmdImgPull ¶
type CmdImgPull struct {
SayaCmd
}
func NewCmdImgPull ¶
func NewCmdImgPull(sayaExe string) (*CmdImgPull, error)
NewCmdImgPull create a new image-pull base command to be completed with flags. The base command is <saya-exe> image pull
func (*CmdImgPull) WithRef ¶
func (cmd *CmdImgPull) WithRef(tagName string)
type CmdImgRm ¶
type CmdImgRm struct {
SayaCmd
}
func NewCmdImgRm ¶
func NewCmdImgRm(sayaExe string, reqSayaCtx RequestSayaCtx) (*CmdImgRm, error)
CmdImgDel create a new image rm base command to be completed with flags. The base command is <saya-exe> image rm
type CmdMultiArgStr ¶
type CmdMultiArgStr struct { K string //Args key. e.g. --accelerated V []string // V value. nil if arg does not allow value specification. Note that empty string "" is a valid value, and different from nil. ToCmdArgParts func(K, V string) []string // Del bool // if true deleted, the arg will not be part of the final command }
CmdMultiArgStr models a repeatable command arg
func (*CmdMultiArgStr) CmdArgs ¶
func (arg *CmdMultiArgStr) CmdArgs() []string
func (*CmdMultiArgStr) CmdArgsDisplay ¶
func (arg *CmdMultiArgStr) CmdArgsDisplay() []string
func (*CmdMultiArgStr) Key ¶
func (arg *CmdMultiArgStr) Key() string
func (*CmdMultiArgStr) ToDel ¶
func (arg *CmdMultiArgStr) ToDel() bool
type CmdVmLs ¶
type CmdVmLs struct {
SayaCmd
}
func NewCmdVmLs ¶
func NewCmdVmLs(id string, reqSayaCtx RequestSayaCtx) (*CmdVmLs, error)
NewCmdVmLs create a saya cmd to list VMs with the given ID. The base command is <saya-exe> vm ls <id-if-not-blank>
type CmdVmRun ¶
type CmdVmRun struct {
SayaCmd
}
func NewCmdVmRm ¶
func NewCmdVmRm(id string, reqSayaCtx RequestSayaCtx) (*CmdVmRun, error)
CmdVmRm creates a saya cmd to remove a VM given its ID. The base command is <saya-exe> vm rm <id>
func NewCmdVmRun ¶
func NewCmdVmRun(imgRef string, reqSayaCtx RequestSayaCtx) (*CmdVmRun, error)
CmdVmRun creates a saya cmd to run a VM. The base command is <saya-exe> vm run <img-reference>
type CmdVmStart ¶
type CmdVmStart struct {
SayaCmd
}
func NewCmdVmStart ¶
func NewCmdVmStart(id string, reqSayaCtx RequestSayaCtx) (*CmdVmStart, error)
CmdVmRun creates a saya cmd to start a VM given its ID. The base command is <saya-exe> vm start <id>
type CmdVmStop ¶
type CmdVmStop struct {
SayaCmd
}
func NewCmdVmStop ¶
func NewCmdVmStop(id string, reqSayaCtx RequestSayaCtx) (*CmdVmStop, error)
CmdVmStop creates a saya cmd to stop a VM given its ID. The base command is <saya-exe> vm stop <id>
type ExecOutcome ¶
type HttpRepo ¶
type HttpRepo struct { RepoUrl string BasePath string UploadStrategy string AuthHttpBasic AuthHttpBasic }
func (*HttpRepo) NormalizeToNil ¶
type ImageDeleteRequest ¶
type ImageDeleteRequest struct { Name string ImgType string Platform string RequestSayaCtx }
type ImageTagMetaData ¶
type ImageTagMetaData struct { Name string `yaml:"name" json:"name"` Version string `yaml:"version" json:"version"` Sha256 string `yaml:"sha256" json:"sha256"` Type string `yaml:"type" json:"type"` // the image type e.g. ova, vhd, vmdk, iso. img, ... Platform PlatformSw `yaml:"platform" json:"platform"` CreatedAt time.Time `yaml:"created_at" json:"created_at"` Labels map[string]string `yaml:"labels" json:"labels"` SrcType string `yaml:"src_type,omitempty" json:"src_type,omitempty"` // build | convert | tag | http | s3 }
func ImageTagMetaDataFromJsonFile ¶
func ImageTagMetaDataFromJsonFile(ctx context.Context, jsonFilepath string) (*ImageTagMetaData, error)
func ImageTagMetaDataListFromJsonFile ¶
func ImageTagMetaDataListFromJsonFile(ctx context.Context, jsonFilepath string) ([]ImageTagMetaData, error)
type LsCmdRes ¶
type LsCmdRes struct { Name string `json:"name"` Version string `json:"tag"` Sha256 string `json:"id"` Type string `json:"img_type"` // the image type e.g. ova, vhd, vmdk, iso. img, ... Platform string `json:"platform"` OsVariant string CreatedAt time.Time `json:"created_at"` Labels map[string]string `json:"labels"` SrcType string `json:"src_type,omitempty"` // build | convert | tag | http | s3 }
LsCmdRes model image in the forge returned as result of saya image ls command. e.g. [{"Created":"2023-07-03T08:45:36.599939836+02:00", "Id":"c87c9fac305744a229103177230db4192bdb6d4547c416ed32fc6bac9971befb", "ImgType":"qcow2","Name":"testeearm","OsVar":"alpine", "Platform":"linux/arm64","Size":1074135040,"Tag":"latest"}]
type LsResult ¶
type LsResult struct { Name string Version string Sha256 string Type string // the image type e.g. ova, vhd, vmdk, iso. img, ... Platform PlatformSw SrcType string }
func (LsResult) PlatformNameVersionTypeTaglike ¶
type ParsedImgId ¶
func ParseImgId ¶
func ParseImgId(str string) (*ParsedImgId, error)
type Platform ¶
type Platform struct { Os string `json:"os,omitempty"` Arch string `json:"arch,omitempty"` ArchVariant string `json:"arch_variant,omitempty"` }
func PlatformNormalized ¶
PlatformNormalized return a normalized form of the specified platform string. It defaults to the current host platform, if passed platform string is blank.
func (Platform) ArchWithVariant ¶
func (Platform) PlatformSegmentParts ¶
func (Platform) PlatformStr ¶
PlatformSegment returns a / separated str representation os[/arch[/arch-variant]].
e.g linux/amd64, linux/arm64, linux/arm/v7
type PlatformSw ¶
PlatformSw is a platform which knows the os variant. It is more software oriented because the os-variant hints at what kind of software natively belongs. e.g. apt for ubuntu but rpm for redhat
type PullRequest ¶
type PullRequest struct { Name string ImgType string Platform string Hash string RepoType string HttpRepo *HttpRepo S3Repo *S3Repo Exe string // saya executable command or path Config string // saya executable command or path Forge string // forge(local image store) location LicenseKey opaque.String // License key LogLevel string // log level error|warn|info|debug|trace }
type PullResult ¶
type PullResult struct { Name string Version string Sha256 string Type string // the image type e.g. ova, vhd, vmdk, iso. img, ... Platform PlatformSw SrcType string // type of the repo used to fetch the image; e.g. http, s3 }
func Pull ¶
func Pull(ctx context.Context, req PullRequest) (*PullResult, error)
type Reference ¶
type Reference struct { Original string // the original reference value, e.g. ubuntu:latest. Name string // name Version string // Normalized i.e. latest if None was given }
func ParseReference ¶
func (Reference) Normalized ¶
type Repos ¶
func (*Repos) AvailableRepoTypes ¶
func (*Repos) ExactlyOneRepoSpecified ¶
type RequestSayaCtx ¶
type S3Repo ¶
type S3Repo struct { Bucket string BaseKey string EpUrl string EpUrlS3 string Region string // aws region to send request to AuthAwsCreds *AwsCredentials UsePathStyle bool }
func (*S3Repo) NormalizeToNil ¶
type SayaCmd ¶
type SayaCmd struct { Args CmdArgs ArgsValidationErrors []error // contains filtered or unexported fields }
func (*SayaCmd) WithCfgFile ¶
func (*SayaCmd) WithForgeLocation ¶
func (*SayaCmd) WithLicenseKey ¶
func (*SayaCmd) WithLogLevel ¶
func (*SayaCmd) WithRequestSayaCtx ¶
func (sayaCmd *SayaCmd) WithRequestSayaCtx(req RequestSayaCtx)
type SayaCmdLs ¶
type SayaCmdLs struct {
SayaCmd
}
func NewCmdImgLs ¶
func NewCmdImgLs(sayaExe string, reqSayaCtx RequestSayaCtx) (*SayaCmdLs, error)
NewSayaCmdLs create a new image ls base command to be completed with flags. The base command is <saya-exe> image ls
type VmLsRequest ¶
type VmLsResult ¶
type VmLsResult struct { Id string Name string Arch string Os string OsVariant string BaseImg string // format: webserver:v1:ova ComputeType string State string }
func VmLs ¶
func VmLs(ctx context.Context, req VmLsRequest) ([]VmLsResult, error)
func (*VmLsResult) ImgId ¶
func (res *VmLsResult) ImgId() string
func (*VmLsResult) LabelNameAndId ¶
func (res *VmLsResult) LabelNameAndId() string
func (*VmLsResult) Platform ¶
func (res *VmLsResult) Platform() string
type VmLsResultCmd ¶
type VmLsResultCmd struct { Id string `json:"id"` Name string `json:"name"` Arch string `json:"arch"` Os string `json:"os"` OsVariant string `json:"os_variant"` BaseImg string `json:"base_img"` // format: webserver:v1:ova ComputeType string `json:"compute_type"` Status string `json:"status"` }
func (*VmLsResultCmd) ToVmLsResult ¶
func (resJson *VmLsResultCmd) ToVmLsResult() VmLsResult
type VmRmRequest ¶
type VmRmRequest struct { Id string Name string RequestSayaCtx }
type VmRmResult ¶
type VmRmResult struct {
Id string
}
func VmRm ¶
func VmRm(ctx context.Context, req VmRmRequest) (*VmRmResult, error)
type VmRunRequest ¶
type VmRunResult ¶
type VmRunResult struct { Id string Name string OsVariant string Ssh struct { Ip string Port uint16 User string CreatedPwdFile string CreatedIdentityFile string } }
func VmRun ¶
func VmRun(ctx context.Context, req VmRunRequest) (*VmRunResult, error)
type VmRunResultCmd ¶
type VmRunResultCmd struct { Id string `json:"id,omitempty"` Name string `json:"name,omitempty"` OsVariant string `json:"os_variant,omitempty"` Ssh *VmRunResultCmdSsh `json:"ssh,omitempty"` }
{"id":"81e4b6cf-ad66-409d-8a78-429b7499093e","name":"saya-2023-08-04T20-39-47Z-999d5a49cbbf","ssh":{"ip":"192.168.56.253","port":22,"user":"root"}}
func (*VmRunResultCmd) ToVmRunResultCmd ¶
func (cmdRes *VmRunResultCmd) ToVmRunResultCmd() VmRunResult
type VmRunResultCmdSsh ¶
type VmStartRequest ¶
type VmStartRequest struct { Id string RequestSayaCtx }
type VmStartResult ¶
type VmStartResult struct {
Id string
}
func VmStart ¶
func VmStart(ctx context.Context, req VmStartRequest) (*VmStartResult, error)
type VmStopRequest ¶
type VmStopRequest struct { Id string RequestSayaCtx }
type VmStopResult ¶
type VmStopResult struct {
Id string
}
func VmStop ¶
func VmStop(ctx context.Context, req VmStopRequest) (*VmStopResult, error)
Source Files ¶
- cmd_arg.go
- cmg_arg_multi_str.go
- img-delete.go
- img-id.go
- img-meta.go
- img-reference.go
- img_ls.go
- img_pull.go
- platform.go
- remoterepo.go
- request_base.go
- saya_cmd.go
- saya_cmd_img_ls.go
- saya_cmd_img_pull.go
- saya_cmd_img_rm.go
- saya_cmd_vm_ls.go
- saya_cmd_vm_rm.go
- saya_cmd_vm_run.go
- saya_cmd_vm_start.go
- saya_cmd_vm_stop.go
- vm_ls.go
- vm_rm.go
- vm_run.go
- vm_start.go
- vm_stop.go