Skip to content
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

v0.6.0 refactor #848

Merged
merged 41 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2164416
core: begin migration to ubuntu
abiosoft Nov 8, 2023
36a8a05
core: update cloud image link
abiosoft Nov 9, 2023
b20de69
k3s: update version
abiosoft Nov 9, 2023
58c12f3
core: fix boot for ubuntu
abiosoft Nov 9, 2023
3faadde
vm: add ability to set custom hostname
abiosoft Nov 9, 2023
3ea6b85
core: checkpoint: remove qemu wrapper
abiosoft Nov 9, 2023
eb55f2b
core: checkpoint: remove qemu wrapper
abiosoft Nov 10, 2023
05131cd
cli: minor bug fix for terminal output
abiosoft Nov 10, 2023
73bd9d9
cli: fix broken terminal output for deb download
abiosoft Nov 10, 2023
0cd2dae
cli: improve terminal output for deb download
abiosoft Nov 10, 2023
241c9fc
vm: fix docker permission on initial create
abiosoft Nov 10, 2023
24bc4db
net: remove gvproxy, migrate to user-v2
abiosoft Nov 10, 2023
a4ac594
docker: fix host-gateway address
abiosoft Nov 10, 2023
47e2f3d
vm: avoid re-installing packages
abiosoft Nov 10, 2023
618954f
k3s: fix broken coredns
abiosoft Nov 10, 2023
289d3ea
core: improve downloader
abiosoft Nov 11, 2023
5fa0b25
vm: add binfmt for cross-platform containers
abiosoft Nov 11, 2023
6133484
containerd: fix for ubuntu
abiosoft Nov 11, 2023
36645cb
containerd: fix broken working directory detection
abiosoft Nov 11, 2023
63e4bb7
chore: remove obsolete env var
abiosoft Nov 11, 2023
b72257e
chore: minor refactor for binfmt
abiosoft Nov 11, 2023
2a62e7a
cli: fix ip address for colima list
abiosoft Nov 11, 2023
9ea83e7
docker: add daemon support for proxy env vars
abiosoft Nov 11, 2023
780ab4b
vm: add more utilities
abiosoft Nov 11, 2023
0105bbb
ci: remove obsolete ubuntu layer
abiosoft Nov 11, 2023
c1742b6
ci: move to gh from hub
abiosoft Nov 11, 2023
06e39bb
core: use custom directory for Lima
abiosoft Nov 11, 2023
e44df6a
chore: minor factor, remove obsolete variable
abiosoft Nov 11, 2023
107ce5a
docker: workaround initial user permission issue
abiosoft Nov 11, 2023
f3e897e
chore: remove obsolete code
abiosoft Nov 11, 2023
142d830
vm: fix binfmt cache
abiosoft Nov 11, 2023
f2dbdcf
core: enforce Lima version requirement
abiosoft Nov 11, 2023
c564330
docker: workaround permission issue
abiosoft Nov 11, 2023
8904b66
vm: enable inotify by default
abiosoft Nov 12, 2023
a90d23d
core: enable binfmt only on host arch
abiosoft Nov 12, 2023
21a59ab
docs: prepare for v0.6.0
abiosoft Nov 12, 2023
52585d4
nix: update Go version in shell
abiosoft Nov 12, 2023
5df231d
nix: update build
abiosoft Nov 12, 2023
f0dc62a
build: add integration test script
abiosoft Nov 12, 2023
d804e3f
ci: remove aarch64, defer until proper m1 support
abiosoft Nov 12, 2023
58d1158
build: fix colima path in integration test script
abiosoft Nov 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
- "**/*.nix"
- "**/*.lock"

permissions: write-all

jobs:
build-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -120,13 +122,12 @@ jobs:
run: >
tag="${GITHUB_REF##*/}"

hub release create
-a _output/binaries/colima-Darwin-x86_64
-a _output/binaries/colima-Darwin-x86_64.sha256sum
-a _output/binaries/colima-Darwin-arm64
-a _output/binaries/colima-Darwin-arm64.sha256sum
-a _output/binaries/colima-Linux-x86_64
-a _output/binaries/colima-Linux-x86_64.sha256sum
-a _output/binaries/colima-Linux-aarch64
-a _output/binaries/colima-Linux-aarch64.sha256sum
-m "${tag}" --draft "${tag}"
gh release create "${tag}" --draft --title "${tag}"
_output/binaries/colima-Darwin-x86_64
_output/binaries/colima-Darwin-x86_64.sha256sum
_output/binaries/colima-Darwin-arm64
_output/binaries/colima-Darwin-arm64.sha256sum
_output/binaries/colima-Linux-x86_64
_output/binaries/colima-Linux-x86_64.sha256sum
_output/binaries/colima-Linux-aarch64
_output/binaries/colima-Linux-aarch64.sha256sum
109 changes: 4 additions & 105 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}

- name: Start Colima
run: colima start --runtime docker --layer
run: colima start --runtime docker

- name: Delay
run: sleep 10
Expand All @@ -128,62 +128,11 @@ jobs:
run: docker ps && docker info

- name: Validate DNS
run: colima ssh --layer=false -- nslookup host.docker.internal
run: colima ssh -- nslookup host.docker.internal

- name: Build Image
run: docker build integration

- name: Validate Layer
run: colima ssh --layer -- cat /etc/os-release

- name: Stop
run: colima stop

- name: Teardown
run: colima delete -f

docker-aarch64:
runs-on: macos-13
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Install CLI deps
run: |
brew install kubectl docker coreutils lima

- name: Build and Install
run: make && sudo make install

- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}

- name: Start Colima
run: colima start --runtime docker --arch aarch64 --layer

- name: Delay
run: sleep 20

- name: Validate Docker
run: docker ps && docker info

- name: Build Image
run: docker build integration

- name: Validate DNS
run: colima ssh --layer=false -- nslookup host.docker.internal

- name: Validate Layer
run: colima ssh --layer -- cat /etc/os-release

- name: Stop
run: colima stop

Expand Down Expand Up @@ -215,7 +164,7 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}

- name: Start Colima
run: colima start --runtime containerd --layer
run: colima start --runtime containerd

- name: Delay
run: sleep 10
Expand All @@ -224,64 +173,14 @@ jobs:
run: colima nerdctl ps && colima nerdctl info

- name: Validate DNS
run: colima ssh --layer=false -- nslookup host.docker.internal
run: colima ssh -- nslookup host.docker.internal

- name: Build Image
run: colima nerdctl -- build integration

- name: Validate Layer
run: colima ssh --layer -- cat /etc/os-release

- name: Stop
run: colima stop

- name: Teardown
run: colima delete -f

containerd-aarch64:
runs-on: macos-13
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Install CLI deps
run: |
brew install kubectl docker coreutils lima

- name: Build and Install
run: make && sudo make install

- name: tmate debugging session
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
github-token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}

- name: Start Colima
run: colima start --runtime containerd --arch aarch64 --layer

- name: Validate Containerd
run: colima nerdctl ps && colima nerdctl info

- name: Validate DNS
run: colima ssh --layer=false -- nslookup host.docker.internal

- name: Build Image
run: colima nerdctl -- build integration

- name: Delay
run: sleep 10

- name: Validate Layer
run: colima ssh --layer -- cat /etc/os-release

- name: Stop
run: colima stop

- name: Teardown
run: colima delete -f
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ nix-derivation-shell:
$(eval DERIVATION=$(shell nix-build))
echo $(DERIVATION) | grep ^/nix
nix-shell -p $(DERIVATION)

.PHONY: integration
integration: build
GOARCH=$(GOARCH) COLIMA_BINARY=$(OUTPUT_DIR)/$(OUTPUT_BIN) scripts/integration.sh
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ brew install --HEAD colima

### Upgrading

If upgrading from v0.4.6 or lower, it is required to start afresh by deleting existing instance.
If upgrading from v0.5.6 or lower, it is required to start afresh by deleting existing instance.

```sh
colima delete # delete existing instance
Expand Down Expand Up @@ -158,7 +158,6 @@ Check [here](docs/FAQ.md) for Frequently Asked Questions.
## Help Wanted

- Documentation (wiki pages)
- Project Logo

## License

Expand Down
61 changes: 5 additions & 56 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
"path/filepath"
"strings"

"github.com/abiosoft/colima/cli"
"github.com/abiosoft/colima/config"
"github.com/abiosoft/colima/config/configmanager"
"github.com/abiosoft/colima/environment"
"github.com/abiosoft/colima/environment/container/docker"
"github.com/abiosoft/colima/environment/container/kubernetes"
"github.com/abiosoft/colima/environment/container/ubuntu"
"github.com/abiosoft/colima/environment/host"
"github.com/abiosoft/colima/environment/vm/lima"
"github.com/abiosoft/colima/environment/vm/lima/limautil"
Expand All @@ -30,7 +28,7 @@ type App interface {
Start(config.Config) error
Stop(force bool) error
Delete() error
SSH(layer bool, args ...string) error
SSH(args ...string) error
Status(extended bool) error
Version() error
Runtime() (string, error)
Expand Down Expand Up @@ -83,14 +81,6 @@ func (c colimaApp) Start(conf config.Config) error {
}
containers = append(containers, env)
}
// ubuntu layer should come last
if conf.Layer {
env, err := c.containerEnvironment(ubuntu.Name)
if err != nil {
return err
}
containers = append(containers, env)
}

// the order for start is:
// vm start -> container runtime provision -> container runtime start
Expand Down Expand Up @@ -222,7 +212,7 @@ func (c colimaApp) Delete() error {
return nil
}

func (c colimaApp) SSH(layer bool, args ...string) error {
func (c colimaApp) SSH(args ...string) error {
ctx := context.Background()
if !c.guest.Running(ctx) {
return fmt.Errorf("%s not running", config.CurrentProfile().DisplayName)
Expand Down Expand Up @@ -270,34 +260,8 @@ func (c colimaApp) SSH(layer bool, args ...string) error {
}
}

if !layer {
return c.guest.SSH(workDir, args...)
}

conf, err := limautil.InstanceConfig()
if err != nil {
return err
}
if !conf.Layer {
return c.guest.SSH(workDir, args...)
}

resp, err := limautil.ShowSSH(config.CurrentProfile().ID, layer)
if err != nil {
return fmt.Errorf("error getting ssh config: %w", err)
}
if !resp.Layer {
return c.guest.RunInteractive(args...)
}

if len(args) > 0 {
args = append([]string{"-q", "-t", config.CurrentProfile().ID, "--"}, args...)
} else if workDir != "" {
args = []string{"-q", "-t", config.CurrentProfile().ID, "--", "cd " + workDir + " 2> /dev/null; \"$SHELL\" --login"}
}

args = append([]string{"-F", resp.File.Colima}, args...)
return cli.CommandInteractive("ssh", args...).Run()
guest := lima.New(host.New())
return guest.SSH(workDir, args...)
}

func (c colimaApp) Status(extended bool) error {
Expand Down Expand Up @@ -341,8 +305,6 @@ func (c colimaApp) Status(extended bool) error {

// additional details
if extended {
log.Println("networkDriver:", conf.Network.Driver)

if inst, err := limautil.Instance(); err == nil {
log.Println("cpu:", inst.CPU)
log.Println("mem:", units.BytesSize(float64(inst.Memory)))
Expand Down Expand Up @@ -370,8 +332,6 @@ func (c colimaApp) Version() error {
case kubernetes.Name:
kube = cont
continue
case ubuntu.Name:
continue
}

fmt.Println()
Expand Down Expand Up @@ -436,11 +396,6 @@ func (c colimaApp) currentContainerEnvironments(ctx context.Context) ([]environm
containers = append(containers, k)
}

// detect and add ubuntu layer
if u, err := c.containerEnvironment(ubuntu.Name); err == nil && u.Running(ctx) {
containers = append(containers, u)
}

return containers, nil
}

Expand Down Expand Up @@ -481,13 +436,7 @@ func generateSSHConfig(modifySSHConfig bool) error {
}

profile := config.Profile(i.Name)
conf, err := i.Config()
if err != nil {
log.Trace(fmt.Errorf("error retrieving profile config for '%s': %w", i.Name, err))
continue
}

resp, err := limautil.ShowSSH(profile.ID, conf.Layer)
resp, err := limautil.ShowSSH(profile.ID)
if err != nil {
log.Trace(fmt.Errorf("error retrieving SSH config for '%s': %w", i.Name, err))
continue
Expand Down
3 changes: 3 additions & 0 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ type ActiveCommandChain struct {
log *log.Entry
}

// Logger returns the logger for the command chain.
func (a *ActiveCommandChain) Logger() *log.Entry { return a.log }

// Add adds a new function to the runner.
func (a *ActiveCommandChain) Add(f func() error) {
a.funcs = append(a.funcs, cFunc{f: f})
Expand Down
Loading
Loading