-
-
Notifications
You must be signed in to change notification settings - Fork 26
Persistent vm naming #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jasperf
wants to merge
9
commits into
roots:master
Choose a base branch
from
jasperf:persistent-vm-naming
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Persistent vm naming #524
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
92d43b7
Persistent VM Naming
jasperf cde5567
Tests Addition
jasperf 8eac282
test fixes
jasperf 3d49591
use the proper instance name resolution method
jasperf 5d9e5f1
vm start test update
jasperf e175651
main.go documentation
jasperf 56fbe3e
vm start test patch
jasperf c31fe7f
.DS_Store addition to .gitignore
jasperf de02b9b
handle case where a VM already exists but no instance file available
jasperf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
trellis-cli | ||
dist | ||
tmp | ||
.DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Package cmd contains all command-line interface commands for Trellis CLI. | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
|
||
"github.com/mitchellh/cli" | ||
"github.com/roots/trellis-cli/pkg/lima" | ||
"github.com/roots/trellis-cli/pkg/vm" | ||
"github.com/roots/trellis-cli/trellis" | ||
) | ||
|
||
// This file provides centralized declarations of functions as variables | ||
// to enable mocking in tests and prevent duplicate implementations. | ||
// Previously, these functions were defined in multiple places, causing | ||
// "redeclared in this block" errors during compilation. | ||
Comment on lines
+14
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we avoid all these changes for now? This is a whole new pattern that I'm not sure about yet I'm okay if this limits the testability temporarily |
||
|
||
// Declare these as variables so they can be overridden in tests | ||
var ( | ||
// newVmManager creates a VM manager instance based on configuration. | ||
// Using a function variable allows for mocking in tests and centralizes VM manager creation logic. | ||
// This approach eliminates duplicate implementations that previously existed across files. | ||
newVmManager = func(t *trellis.Trellis, ui cli.Ui) (vm.Manager, error) { | ||
// Select appropriate VM manager based on configuration | ||
switch t.CliConfig.Vm.Manager { | ||
case "auto": | ||
switch runtime.GOOS { | ||
case "darwin": | ||
return lima.NewManager(t, ui) | ||
default: | ||
return nil, fmt.Errorf("no VM managers are supported on %s yet", runtime.GOOS) | ||
} | ||
case "lima": | ||
return lima.NewManager(t, ui) | ||
case "mock": | ||
return vm.NewMockManager(t, ui) | ||
} | ||
|
||
return nil, fmt.Errorf("vm manager not found") | ||
} | ||
|
||
// NewProvisionCommand creates a new ProvisionCommand instance. | ||
// This was moved here from provision.go to follow the same pattern | ||
// of using function variables for testability. | ||
NewProvisionCommand = func(ui cli.Ui, trellis *trellis.Trellis) *ProvisionCommand { | ||
return &ProvisionCommand{UI: ui, Trellis: trellis} | ||
} | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should only exist on user's personal global gitignore and not here