summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2022-03-25 14:42:25 -0500
committerBrent Baude <bbaude@redhat.com>2022-03-28 09:12:08 -0500
commit2ac897aa0dcda012f4fc038c84849d9429d421dc (patch)
treeac5e7906001e45d682c60b6644f612b60ec7040c /cmd
parent54f808e4dd10de0d3ceec7cadac776b119a293b1 (diff)
downloadpodman-2ac897aa0dcda012f4fc038c84849d9429d421dc.tar.gz
podman-2ac897aa0dcda012f4fc038c84849d9429d421dc.tar.bz2
podman-2ac897aa0dcda012f4fc038c84849d9429d421dc.zip
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 <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/machine/init.go8
1 files changed, 7 insertions, 1 deletions
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 {