From 2ac897aa0dcda012f4fc038c84849d9429d421dc Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Fri, 25 Mar 2022 14:42:25 -0500 Subject: Machine refactor - part 1 the way machine was written was very adjunct and as such is in dire need of refactoring to better structures and structure methods where appropriate. the weekest part is specifically around all the files that machine requires and how some are just dynamically built on the fly. this pr defines a new machinefile type which allows us to work with the file and also takes into account the use of symlinks which are going to be needed on macos due to its relatively short file length restriction. also, added unit tests for new methods as well as anywhere else I saw a need. Signed-off-by: Brent Baude --- cmd/podman/machine/init.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmd/podman') diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go index 8fb17cf54..518e7490f 100644 --- a/cmd/podman/machine/init.go +++ b/cmd/podman/machine/init.go @@ -31,6 +31,10 @@ var ( now bool ) +// maxMachineNameSize is set to thirty to limit huge machine names primarily +// because macos has a much smaller file size limit. +const maxMachineNameSize = 30 + func init() { registry.Commands = append(registry.Commands, registry.CliCommand{ Command: initCmd, @@ -111,10 +115,12 @@ func initMachine(cmd *cobra.Command, args []string) error { vm machine.VM err error ) - provider := getSystemDefaultProvider() initOpts.Name = defaultMachineName if len(args) > 0 { + if len(args[0]) > maxMachineNameSize { + return errors.New("machine name must be 30 characters or less") + } initOpts.Name = args[0] } if _, err := provider.LoadVMByName(initOpts.Name); err == nil { -- cgit v1.2.3-54-g00ecf