Skip to content

Commit ff810ee

Browse files
committed
2 parents 32a970d + 806db99 commit ff810ee

File tree

19 files changed

+297
-109
lines changed

19 files changed

+297
-109
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ version: ...
2323
**Local Environment:**
2424
- DevSpace Version: [use `devspace --version`]
2525
- Operating System: windows | linux | mac
26-
26+
- ARCH of the OS: AMD64 | ARM64 | i386
2727
**Kubernetes Cluster:**
2828
- Cloud Provider: google | aws | azure | other
2929
- Kubernetes Version: [use `kubectl version`]

.github/workflows/e2e-tests.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: E2E tests
2+
3+
on:
4+
release:
5+
types: [created]
6+
pull_request:
7+
branches:
8+
- master
9+
paths:
10+
- "Dockerfile"
11+
- "**.go"
12+
- "!**_test.go" # exclude test files to ignore unit test changes
13+
- "e2e/**_test.go" # include test files in e2e again
14+
- ".github/workflows/e2e-tests.yaml"
15+
16+
env:
17+
GO111MODULE: on
18+
GOFLAGS: -mod=vendor
19+
20+
jobs:
21+
test-e2e:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26+
- name: Checkout repo
27+
uses: actions/checkout@v2
28+
29+
# Creates KinD with using k8s versions from the matrix above
30+
- name: Set up kind with K8s version v1.21.1
31+
uses: engineerd/[email protected]
32+
with:
33+
version: "v0.11.0"
34+
image: kindest/node:v1.21.1
35+
- name: Testing kind cluster set-up
36+
run: |
37+
kubectl cluster-info
38+
kubectl get pods -n kube-system
39+
echo "current-context:" $(kubectl config current-context)
40+
echo "environment-kubeconfig:" ${KUBECONFIG}
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v2
44+
with:
45+
go-version: 1.17
46+
47+
- name: e2e test
48+
working-directory: ./e2e
49+
run: go test -v -ginkgo.v

.github/workflows/lint.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on:
4+
release:
5+
types: [created]
6+
pull_request:
7+
branches:
8+
- master
9+
paths:
10+
- "**.go"
11+
- ".github/workflows/lint.yaml"
12+
- ".golangci.yml"
13+
14+
jobs:
15+
golangci:
16+
name: lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: golangci-lint
21+
uses: golangci/golangci-lint-action@v2
22+
with:
23+
version: v1.29
24+
args:
25+
-v
26+
--config=.golangci.yml
27+
--max-same-issues=50

.github/workflows/pr-checks.yml

Lines changed: 0 additions & 92 deletions
This file was deleted.

.github/workflows/unit-tests.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Unit test
2+
3+
on:
4+
release:
5+
types: [created]
6+
pull_request:
7+
branches:
8+
- master
9+
paths:
10+
- "**.go"
11+
- "!e2e/**" # exclude files from e2e tests
12+
- ".github/workflows/unit-tests.yaml"
13+
14+
env:
15+
GO111MODULE: on
16+
GOFLAGS: -mod=vendor
17+
18+
jobs:
19+
test-unit:
20+
strategy:
21+
matrix:
22+
os: [macos-latest, ubuntu-latest]
23+
24+
name: unit-test-${{ matrix.os }}
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- name: Set up Go
29+
uses: actions/setup-go@v1
30+
with:
31+
go-version: 1.17
32+
33+
- name: Check out code into the Go module directory
34+
uses: actions/checkout@v1
35+
36+
- name: Test
37+
run: ./hack/coverage.bash
38+
39+
test-unit-windows:
40+
runs-on: windows-latest
41+
name: unit-test-windows-latest
42+
43+
steps:
44+
- name: Set up Go
45+
uses: actions/setup-go@v1
46+
with:
47+
go-version: 1.17
48+
49+
- name: Check out code into the Go module directory
50+
uses: actions/checkout@v1
51+
52+
- name: Test
53+
run: ./hack/coverage.bash
54+
shell: bash

cmd/init.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
65
"io/ioutil"
76
"net/http"
87
"os"
@@ -11,6 +10,8 @@ import (
1110
"strconv"
1211
"strings"
1312

13+
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
14+
1415
"github.com/loft-sh/devspace/pkg/devspace/compose"
1516
"github.com/loft-sh/devspace/pkg/devspace/hook"
1617

@@ -374,6 +375,7 @@ func (cmd *InitCmd) Run(f factory.Factory) error {
374375
"(?m)^( open:)": "\n # `dev.open` tells DevSpace to open certain URLs as soon as they return HTTP status 200\n # Since we configured port-forwarding, we can use a localhost address here to access our application\n$1",
375376
"(?m)^( - url:.+)": "$1\n",
376377
"(?m)^( sync:)": " # `dev.sync` configures a file sync between our Pods in k8s and your local project files\n$1",
378+
"(?m)^( (-| ) excludePaths:)": " # `excludePaths` option expects an array of strings with paths that should not be synchronized between the\n # local filesystem and the remote container filesystem. It uses the same syntax as `.gitignore`.\n$1",
377379
"(?m)^( terminal:)": "\n # `dev.terminal` tells DevSpace to open a terminal as a last step during `devspace dev`\n$1",
378380
"(?m)^( command:)": " # With this optional `command` we can tell DevSpace to run a script when opening the terminal\n # This is often useful to display help info for new users or perform initial tasks (e.g. installing dependencies)\n # DevSpace has generated an example ./devspace_start.sh file in your local project - Feel free to customize it!\n$1",
379381
"(?m)^( replacePods:)": "\n # Since our Helm charts and manifests deployments are often optimized for production,\n # DevSpace let's you swap out Pods dynamically to get a better dev environment\n$1",

cmd/sync.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/loft-sh/devspace/pkg/devspace/plugin"
1111
"github.com/loft-sh/devspace/pkg/devspace/upgrade"
1212
"github.com/loft-sh/devspace/pkg/util/message"
13-
"github.com/loft-sh/devspace/pkg/util/ptr"
1413
"k8s.io/apimachinery/pkg/labels"
1514

1615
"github.com/loft-sh/devspace/cmd/flags"
@@ -29,9 +28,12 @@ type SyncCmd struct {
2928
*flags.GlobalFlags
3029

3130
LabelSelector string
31+
ImageSelector string
3232
Container string
3333
Pod string
3434
Pick bool
35+
Wait bool
36+
Polling bool
3537

3638
Exclude []string
3739
ContainerPath string
@@ -82,6 +84,7 @@ devspace sync --container-path=/my-path
8284
syncCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to sync to")
8385
syncCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to sync to")
8486
syncCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
87+
syncCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})")
8588
syncCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod")
8689

8790
syncCmd.Flags().StringSliceVarP(&cmd.Exclude, "exclude", "e", []string{}, "Exclude directory from sync")
@@ -97,6 +100,9 @@ devspace sync --container-path=/my-path
97100
syncCmd.Flags().BoolVar(&cmd.UploadOnly, "upload-only", false, "If set DevSpace will only upload files")
98101
syncCmd.Flags().BoolVar(&cmd.DownloadOnly, "download-only", false, "If set DevSpace will only download files")
99102

103+
syncCmd.Flags().BoolVar(&cmd.Wait, "wait", true, "Wait for the pod(s) to start if they are not running")
104+
syncCmd.Flags().BoolVar(&cmd.Polling, "polling", false, "If polling should be used to detect file changes in the container")
105+
100106
return syncCmd
101107
}
102108

@@ -176,7 +182,16 @@ func (cmd *SyncCmd) Run(f factory.Factory) error {
176182

177183
// Build params
178184
options := targetselector.NewOptionsFromFlags(cmd.Container, cmd.LabelSelector, cmd.Namespace, cmd.Pod, cmd.Pick)
179-
options.Wait = ptr.Bool(false)
185+
// get image selector if specified
186+
imageSelector, err := getImageSelector(client, configLoader, configOptions, "", cmd.ImageSelector, logger)
187+
if err != nil {
188+
return err
189+
}
190+
191+
// set image selector
192+
options.ImageSelector = imageSelector
193+
options.Wait = &cmd.Wait
194+
180195
if cmd.DownloadOnly && cmd.UploadOnly {
181196
return errors.New("--upload-only cannot be used together with --download-only")
182197
}
@@ -266,7 +281,7 @@ func (cmd *SyncCmd) applyFlagsToSyncConfig(syncConfig *latest.SyncConfig) error
266281
if cmd.Container != "" {
267282
syncConfig.ContainerName = ""
268283
}
269-
if cmd.LabelSelector != "" || cmd.Pod != "" {
284+
if cmd.LabelSelector != "" || cmd.Pod != "" || cmd.ImageSelector != "" {
270285
syncConfig.LabelSelector = nil
271286
syncConfig.ImageSelector = ""
272287
}
@@ -288,5 +303,9 @@ func (cmd *SyncCmd) applyFlagsToSyncConfig(syncConfig *latest.SyncConfig) error
288303
syncConfig.InitialSync = latest.InitialSyncStrategy(cmd.InitialSync)
289304
}
290305

306+
if cmd.Polling {
307+
syncConfig.Polling = cmd.Polling
308+
}
309+
291310
return nil
292311
}

dist/npm/bin/devspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env sh
22

33
BINARY=$(command -v devspace)
4-
STAT=$(stat -L -f%z "$BINARY" 2>/dev/null || stat --printf="%s" "$BINARY" 2>/dev/null)
4+
STAT=$(stat -L -f%z "$BINARY" 2>/dev/null || stat -c"%s" "$BINARY" 2>/dev/null)
55

66
if [ ! -f "$BINARY" ] || [ "$STAT" -lt 10000 ]; then
77
echo "Finishing installation of DevSpace CLI"

dist/npm/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const ARCH_MAPPING = {
1414
x64: "amd64",
1515
x86_64: "amd64",
1616
arm: "arm",
17+
arm64: "arm64",
1718
aarch64: "arm"
1819
};
1920
const PLATFORM_MAPPING = {
@@ -223,6 +224,13 @@ let continueProcess = function(askRemoveGlobalFolder) {
223224
} catch(e) {}
224225

225226
let binaryPath = path.join(globalDir, binaryName);
227+
if (process.argv.length > 3 && fs.existsSync(normalizePath(process.argv[3]))) {
228+
let binaryDir = normalizePath(process.argv[3]);
229+
let possibleBinaryPath = path.join(binaryDir, binaryName)
230+
if (fs.existsSync(possibleBinaryPath)) {
231+
binaryPath = possibleBinaryPath;
232+
}
233+
}
226234

227235
try {
228236
fs.unlinkSync(binaryPath + downloadExtension);

docs/pages/commands/devspace_sync.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ devspace sync --container-path=/my-path
4444
--no-watch Synchronizes local and remote and then stops
4545
--pick Select a pod (default true)
4646
--pod string Pod to sync to
47+
--polling bool If polling should be used to detect file changes in the container
4748
--upload-only If set DevSpace will only upload files
4849
--verbose Shows every file that is synced
50+
--wait Wait for the pod(s) to start if they are not running
51+
4952
```
5053

5154

@@ -69,4 +72,3 @@ devspace sync --container-path=/my-path
6972
--var strings Variables to override during execution (e.g. --var=MYVAR=MYVALUE)
7073
--vars-secret string The secret to restore/save the variables from/to, if --restore-vars or --save-vars is enabled (default "devspace-vars")
7174
```
72-

0 commit comments

Comments
 (0)