diff --git a/internal/command/create/vm.go b/internal/command/create/vm.go index 9b4af41..e857e34 100644 --- a/internal/command/create/vm.go +++ b/internal/command/create/vm.go @@ -3,12 +3,14 @@ package create import ( "errors" "fmt" + "os" + "strings" + + "github.com/cirruslabs/orchard/internal/imageconstant" "github.com/cirruslabs/orchard/internal/simplename" "github.com/cirruslabs/orchard/pkg/client" v1 "github.com/cirruslabs/orchard/pkg/resource/v1" "github.com/spf13/cobra" - "os" - "strings" ) var ErrVMFailed = errors.New("failed to create VM") @@ -38,7 +40,7 @@ func newCreateVMCommand() *cobra.Command { Args: cobra.ExactArgs(1), } - command.Flags().StringVar(&image, "image", "ghcr.io/cirruslabs/macos-sonoma-base:latest", "image to use") + command.Flags().StringVar(&image, "image", imageconstant.DefaultMacosImage, "image to use") command.Flags().Uint64Var(&cpu, "cpu", 4, "number of CPUs to use") command.Flags().Uint64Var(&memory, "memory", 8*1024, "megabytes of memory to use") command.Flags().Uint64Var(&diskSize, "disk-size", 0, "resize the VMs disk to the specified size in GB "+ diff --git a/internal/controller/api_workers.go b/internal/controller/api_workers.go index c30e746..e7480d1 100644 --- a/internal/controller/api_workers.go +++ b/internal/controller/api_workers.go @@ -2,13 +2,14 @@ package controller import ( "errors" + "net/http" + "time" + storepkg "github.com/cirruslabs/orchard/internal/controller/store" "github.com/cirruslabs/orchard/internal/responder" "github.com/cirruslabs/orchard/internal/simplename" v1 "github.com/cirruslabs/orchard/pkg/resource/v1" "github.com/gin-gonic/gin" - "net/http" - "time" ) func (controller *Controller) createWorker(ctx *gin.Context) responder.Responder { diff --git a/internal/imageconstant/imageconstant.go b/internal/imageconstant/imageconstant.go new file mode 100644 index 0000000..ea5872f --- /dev/null +++ b/internal/imageconstant/imageconstant.go @@ -0,0 +1,3 @@ +package imageconstant + +const DefaultMacosImage = "ghcr.io/cirruslabs/macos-sequoia-base:latest" diff --git a/internal/tests/integration_test.go b/internal/tests/integration_test.go index 152447f..5b62e42 100644 --- a/internal/tests/integration_test.go +++ b/internal/tests/integration_test.go @@ -3,7 +3,16 @@ package tests_test import ( "context" "fmt" + "net" + "os" + "path/filepath" + "strconv" + "strings" + "testing" + "time" + "github.com/cirruslabs/orchard/internal/controller" + "github.com/cirruslabs/orchard/internal/imageconstant" "github.com/cirruslabs/orchard/internal/tests/devcontroller" "github.com/cirruslabs/orchard/internal/tests/wait" "github.com/cirruslabs/orchard/internal/worker/ondiskname" @@ -15,13 +24,6 @@ import ( "go.uber.org/zap" "golang.org/x/crypto/ssh" "golang.org/x/exp/slices" - "net" - "os" - "path/filepath" - "strconv" - "strings" - "testing" - "time" ) func TestSingleVM(t *testing.T) { @@ -36,7 +38,7 @@ func TestSingleVM(t *testing.T) { Meta: v1.Meta{ Name: "test-vm", }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -109,7 +111,7 @@ func TestFailedStartupScript(t *testing.T) { Meta: v1.Meta{ Name: "test-vm", }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -147,7 +149,7 @@ func TestPortForwarding(t *testing.T) { Meta: v1.Meta{ Name: "test-vm", }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -226,7 +228,7 @@ func TestSchedulerHealthCheckingNonExistentWorker(t *testing.T) { Meta: v1.Meta{ Name: dummyVMName, }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -303,7 +305,7 @@ func TestSchedulerHealthCheckingOfflineWorker(t *testing.T) { Meta: v1.Meta{ Name: dummyVMName, }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -343,7 +345,7 @@ func TestVMGarbageCollection(t *testing.T) { // Create on-disk Tart VM that looks like it's managed by Orchard vmName := ondiskname.New("test", uuid.New().String(), 0).String() _, _, err = tart.Tart(ctx, logger.Sugar(), "clone", - "ghcr.io/cirruslabs/macos-sonoma-base:latest", vmName) + imageconstant.DefaultMacosImage, vmName) require.NoError(t, err) // Make sure that this VM exists @@ -379,7 +381,7 @@ func TestHostDirs(t *testing.T) { Meta: v1.Meta{ Name: vmName, }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, @@ -441,7 +443,7 @@ func TestHostDirsInvalidPolicy(t *testing.T) { Meta: v1.Meta{ Name: vmName, }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, diff --git a/internal/tests/ip_endpoint_test.go b/internal/tests/ip_endpoint_test.go index 9d4f5d8..f3f27a7 100644 --- a/internal/tests/ip_endpoint_test.go +++ b/internal/tests/ip_endpoint_test.go @@ -2,14 +2,16 @@ package tests_test import ( "context" + "net" + "testing" + "time" + + "github.com/cirruslabs/orchard/internal/imageconstant" "github.com/cirruslabs/orchard/internal/tests/devcontroller" "github.com/cirruslabs/orchard/internal/tests/wait" v1 "github.com/cirruslabs/orchard/pkg/resource/v1" "github.com/stretchr/testify/require" "golang.org/x/crypto/ssh" - "net" - "testing" - "time" ) func TestIPEndpoint(t *testing.T) { @@ -21,7 +23,7 @@ func TestIPEndpoint(t *testing.T) { Meta: v1.Meta{ Name: "test-vm", }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, diff --git a/internal/tests/sshserver_test.go b/internal/tests/sshserver_test.go index 41c3a01..234da6e 100644 --- a/internal/tests/sshserver_test.go +++ b/internal/tests/sshserver_test.go @@ -4,7 +4,12 @@ import ( "context" "crypto/subtle" "fmt" + "net" + "testing" + "time" + "github.com/cirruslabs/orchard/internal/controller" + "github.com/cirruslabs/orchard/internal/imageconstant" "github.com/cirruslabs/orchard/internal/tests/devcontroller" "github.com/cirruslabs/orchard/internal/tests/wait" v1 "github.com/cirruslabs/orchard/pkg/resource/v1" @@ -12,9 +17,6 @@ import ( "github.com/stretchr/testify/require" "golang.org/x/crypto/ed25519" "golang.org/x/crypto/ssh" - "net" - "testing" - "time" ) func TestSSHServer(t *testing.T) { @@ -41,7 +43,7 @@ func TestSSHServer(t *testing.T) { Meta: v1.Meta{ Name: "test-vm", }, - Image: "ghcr.io/cirruslabs/macos-sonoma-base:latest", + Image: imageconstant.DefaultMacosImage, CPU: 4, Memory: 8 * 1024, Headless: true, diff --git a/internal/worker/ondiskname/ondiskname_test.go b/internal/worker/ondiskname/ondiskname_test.go index 2635133..a804a88 100644 --- a/internal/worker/ondiskname/ondiskname_test.go +++ b/internal/worker/ondiskname/ondiskname_test.go @@ -2,10 +2,12 @@ package ondiskname_test import ( "fmt" + "testing" + + "github.com/cirruslabs/orchard/internal/imageconstant" "github.com/cirruslabs/orchard/internal/worker/ondiskname" "github.com/google/uuid" "github.com/stretchr/testify/require" - "testing" ) func TestOnDiskNameFromStaticString(t *testing.T) { @@ -33,6 +35,6 @@ func TestOnDiskNameNonUUID(t *testing.T) { } func TestOnDiskNameNonOrchard(t *testing.T) { - _, err := ondiskname.Parse("ghcr.io/cirruslabs/macos-sonoma-base:latest") + _, err := ondiskname.Parse(imageconstant.DefaultMacosImage) require.Error(t, err) }