Skip to content

Commit

Permalink
v0.6.0 refactor (#848)
Browse files Browse the repository at this point in the history
* core: begin migration to ubuntu

* core: update cloud image link

* k3s: update version

* core: fix boot for ubuntu

* vm: add ability to set custom hostname

* core: checkpoint: remove qemu wrapper

* core: checkpoint: remove qemu wrapper

* cli: minor bug fix for terminal output

* cli: fix broken terminal output for deb download

* cli: improve terminal output for deb download

* vm: fix docker permission on initial create

* net: remove gvproxy, migrate to user-v2

* docker: fix host-gateway address

* vm: avoid re-installing packages

* k3s: fix broken coredns

* core: improve downloader

* vm: add binfmt for cross-platform containers

* containerd: fix for ubuntu

* containerd: fix broken working directory detection

* chore: remove obsolete env var

* chore: minor refactor for binfmt

* cli: fix ip address for colima list

* docker: add daemon support for proxy env vars

* vm: add more utilities

* ci: remove obsolete ubuntu layer

* ci: move to gh from hub

* core: use custom directory for Lima

* chore: minor factor, remove obsolete variable

* docker: workaround initial user permission issue

* chore: remove obsolete code

* vm: fix binfmt cache

* core: enforce Lima version requirement

* docker: workaround permission issue

* vm: enable inotify by default

* core: enable binfmt only on host arch

* docs: prepare for v0.6.0

* nix: update Go version in shell

* nix: update build

* build: add integration test script

* ci: remove aarch64, defer until proper m1 support

* build: fix colima path in integration test script
  • Loading branch information
abiosoft authored Nov 12, 2023
1 parent b7809a6 commit f36ff1e
Show file tree
Hide file tree
Showing 47 changed files with 694 additions and 2,119 deletions.
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

0 comments on commit f36ff1e

Please sign in to comment.