Skip to content

Commit

Permalink
rename extra => additional
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Alvarez <alvajus@amazon.com>
  • Loading branch information
pendo324 committed Oct 25, 2022
1 parent d78bd2b commit 73ba30e
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 48 deletions.
8 changes: 4 additions & 4 deletions cmd/limactl/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func newHostagentCommand() *cobra.Command {
hostagentCommand.Flags().StringP("pidfile", "p", "", "write pid to file")
hostagentCommand.Flags().String("socket", "", "hostagent socket")
hostagentCommand.Flags().String("nerdctl-archive", "", "local file path (not URL) of nerdctl-full-VERSION-linux-GOARCH.tar.gz")
hostagentCommand.Flags().String("extra-archive", "", "local file path (not URL) of an arbitrary archive")
hostagentCommand.Flags().String("additional-archive", "", "local file path (not URL) of an arbitrary archive to add to CIDATA")
return hostagentCommand
}

Expand Down Expand Up @@ -71,12 +71,12 @@ func hostagentAction(cmd *cobra.Command, args []string) error {
if nerdctlArchive != "" {
opts = append(opts, hostagent.WithNerdctlArchive(nerdctlArchive))
}
extraArchive, err := cmd.Flags().GetString("extra-archive")
additionalArchive, err := cmd.Flags().GetString("additional-archive")
if err != nil {
return err
}
if extraArchive != "" {
opts = append(opts, hostagent.WithExtraArchive(extraArchive))
if additionalArchive != "" {
opts = append(opts, hostagent.WithAdditionalArchive(additionalArchive))
}
ha, err := hostagent.New(instName, stdout, sigintCh, opts...)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,15 @@ containerd:
# Also see "/var/log/cloud-init-output.log" in the guest.

# Adds an additional archive which matches the system architecture to the CIDATA image which is mounted on boot.
# The additional archive will be available on the CIDATA disk at /additional.tgz.
# Useful for provisioning scripts that run before mounts (like `mode: dependency`) in case they need any file resources.
# See pkg/cidata/cidata.TEMPLATE.d/boot/40-install-containerd.sh for an example of how to use an archive
# from a provisioning script.
# extraArchives:
# - location: "~/extra.amd64.tar.gz"
# additionalArchives:
# - location: "~/additional.amd64.tar.gz"
# arch: "x86_64"
# digest: "sha256:..."
# - location: "~/extra.aarch64.tar.gz"
# - location: "~/additional.aarch64.tar.gz"
# arch: "aarch64"
# digest: "sha256:..."

Expand Down
12 changes: 6 additions & 6 deletions pkg/cidata/cidata.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func setupEnv(y *limayaml.LimaYAML) (map[string]string, error) {
return env, nil
}

func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort, tcpDNSLocalPort int, nerdctlArchive, extraArchive string) error {
func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort, tcpDNSLocalPort int, nerdctlArchive, additionalArchive string) error {
if err := limayaml.Validate(*y, false); err != nil {
return err
}
Expand Down Expand Up @@ -287,16 +287,16 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
})
}

if extraArchive != "" {
extratgzR, err := os.Open(extraArchive)
if additionalArchive != "" {
additionaltgzR, err := os.Open(additionalArchive)
if err != nil {
return err
}
defer extratgzR.Close()
defer additionaltgzR.Close()
layout = append(layout, iso9660util.Entry{
// ISO9660 requires len(Path) <= 30
Path: "extra.tgz",
Reader: extratgzR,
Path: "additional.tgz",
Reader: additionaltgzR,
})
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/hostagent/hostagent.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type HostAgent struct {
}

type options struct {
nerdctlArchive string // local path, not URL
extraArchive string // local path, not URL
nerdctlArchive string // local path, not URL
additionalArchive string // local path, not URL
}

type Opt func(*options) error
Expand All @@ -70,9 +70,9 @@ func WithNerdctlArchive(s string) Opt {
}
}

func WithExtraArchive(s string) Opt {
func WithAdditionalArchive(s string) Opt {
return func(o *options) error {
o.extraArchive = s
o.additionalArchive = s
return nil
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func New(instName string, stdout io.Writer, sigintCh chan os.Signal, opts ...Opt
}
}

if err := cidata.GenerateISO9660(inst.Dir, instName, y, udpDNSLocalPort, tcpDNSLocalPort, o.nerdctlArchive, o.extraArchive); err != nil {
if err := cidata.GenerateISO9660(inst.Dir, instName, y, udpDNSLocalPort, tcpDNSLocalPort, o.nerdctlArchive, o.additionalArchive); err != nil {
return nil, err
}

Expand Down
50 changes: 25 additions & 25 deletions pkg/limayaml/limayaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ import (
)

type LimaYAML struct {
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
Images []Image `yaml:"images" json:"images"` // REQUIRED
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
Network NetworkDeprecated `yaml:"network,omitempty" json:"network,omitempty"` // DEPRECATED, use `networks` instead
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
UseHostResolver *bool `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
ExtraArchives []File `yaml:"extraArchives,omitempty" json:"extraArchives,omitempty"`
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
Images []Image `yaml:"images" json:"images"` // REQUIRED
CPUType map[Arch]string `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
Message string `yaml:"message,omitempty" json:"message,omitempty"`
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
Network NetworkDeprecated `yaml:"network,omitempty" json:"network,omitempty"` // DEPRECATED, use `networks` instead
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
DNS []net.IP `yaml:"dns,omitempty" json:"dns,omitempty"`
HostResolver HostResolver `yaml:"hostResolver,omitempty" json:"hostResolver,omitempty"`
UseHostResolver *bool `yaml:"useHostResolver,omitempty" json:"useHostResolver,omitempty"` // DEPRECATED, use `HostResolver.Enabled` instead
PropagateProxyEnv *bool `yaml:"propagateProxyEnv,omitempty" json:"propagateProxyEnv,omitempty"`
CACertificates CACertificates `yaml:"caCerts,omitempty" json:"caCerts,omitempty"`
AdditionalArchives []File `yaml:"additionalArchives,omitempty" json:"additionalArchives,omitempty"`
}

type Arch = string
Expand Down
10 changes: 5 additions & 5 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func Start(ctx context.Context, inst *store.Instance) error {
if nerdctlArchiveCache != "" {
args = append(args, "--nerdctl-archive", nerdctlArchiveCache)
}
if len(y.ExtraArchives) > 0 {
location, errs := downloadAndCacheArchiveForArch(y.ExtraArchives, *y.Arch, "extrArchive")
if len(y.AdditionalArchives) > 0 {
location, errs := downloadAndCacheArchiveForArch(y.AdditionalArchives, *y.Arch, "additionalArchive")
if location == "" {
return fmt.Errorf("failed to download the extraArchive archive, attempted %d candidates, errors=%v",
len(y.ExtraArchives), errs)
return fmt.Errorf("failed to download the additionalArchive archive, attempted %d candidates, errors=%v",
len(y.AdditionalArchives), errs)
}
args = append(args, "--extra-archive", location)
args = append(args, "--additional-archive", location)
}

args = append(args, inst.Name)
Expand Down

0 comments on commit 73ba30e

Please sign in to comment.