Skip to content

Commit 076be2d

Browse files
committed
refactor: update file permissions on initial sync
1 parent 3b961f0 commit 076be2d

File tree

19 files changed

+1944
-1202
lines changed

19 files changed

+1944
-1202
lines changed

.github/workflows/e2e-tests.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ jobs:
2727
uses: actions/checkout@v2
2828

2929
# Creates KinD with using k8s versions from the matrix above
30-
- name: Set up kind with K8s version v1.21.1
30+
- name: Set up kind with K8s version v1.22.4
3131
uses: engineerd/[email protected]
3232
with:
33-
version: "v0.11.0"
34-
image: kindest/node:v1.21.1
33+
version: "v0.11.1"
34+
image: kindest/node:v1.22.4
3535
- name: Testing kind cluster set-up
3636
run: |
3737
kubectl cluster-info
@@ -44,6 +44,15 @@ jobs:
4444
with:
4545
go-version: 1.17
4646

47+
- name: Build devspacehelper
48+
run: |
49+
mkdir -p ~/.devspace/devspacehelper/latest
50+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-extldflags=-static" -o ~/.devspace/devspacehelper/latest/devspacehelper helper/main.go
51+
chmod +x ~/.devspace/devspacehelper/latest/devspacehelper
52+
env:
53+
GOPATH: /Users/runner/work/devspace/go
54+
4755
- name: e2e test
4856
working-directory: ./e2e
49-
run: go test -v -ginkgo.v
57+
run: |
58+
go test -v -ginkgo.v

e2e/framework/factory.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import (
44
"github.com/loft-sh/devspace/pkg/util/factory"
55
"github.com/loft-sh/devspace/pkg/util/log"
66
"github.com/loft-sh/devspace/pkg/util/survey"
7+
"github.com/sirupsen/logrus"
78
)
89

910
var _ factory.Factory = &DefaultFactory{}
1011

1112
func NewDefaultFactory() *DefaultFactory {
13+
logger := log.GetInstance()
14+
logger.SetLevel(logrus.DebugLevel)
1215
return &DefaultFactory{
1316
Factory: factory.DefaultFactory(),
1417
log: &DefaultLog{
15-
Logger: log.GetInstance(),
18+
Logger: logger,
1619
},
1720
}
1821
}

e2e/tests/sync/sync.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,68 @@ var _ = DevSpaceDescribe("sync", func() {
3636
framework.ExpectNoError(err)
3737
})
3838

39+
ginkgo.It("devspace sync should override permissions on initial sync", func() {
40+
tempDir, err := framework.CopyToTempDir("tests/sync/testdata/permissions")
41+
framework.ExpectNoError(err)
42+
defer framework.CleanupTempDir(initialDir, tempDir)
43+
44+
ns, err := kubeClient.CreateNamespace("sync")
45+
framework.ExpectNoError(err)
46+
defer func() {
47+
err := kubeClient.DeleteNamespace(ns)
48+
framework.ExpectNoError(err)
49+
}()
50+
51+
// create a new dev command
52+
deployCmd := &cmd.DeployCmd{
53+
GlobalFlags: &flags.GlobalFlags{
54+
NoWarn: true,
55+
Namespace: ns,
56+
},
57+
}
58+
59+
// run the command
60+
err = deployCmd.Run(f)
61+
framework.ExpectNoError(err)
62+
63+
// wait until busybox pod is reachable
64+
_, err = kubeClient.ExecByImageSelector("busybox", ns, []string{"sh", "-c", "mkdir /test_sync && echo -n 'echo \"Hello World!\"' > /test_sync/test.sh"})
65+
framework.ExpectNoError(err)
66+
67+
// run single sync
68+
syncCmd := &cmd.SyncCmd{
69+
GlobalFlags: &flags.GlobalFlags{
70+
NoWarn: true,
71+
Namespace: ns,
72+
Debug: true,
73+
},
74+
ContainerPath: "/test_sync",
75+
NoWatch: true,
76+
ImageSelector: "busybox",
77+
}
78+
79+
// run the command
80+
err = syncCmd.Run(f)
81+
framework.ExpectNoError(err)
82+
83+
// check if script is executable
84+
_, err = kubeClient.ExecByImageSelector("busybox", ns, []string{"sh", "-c", "/test_sync/test.sh"})
85+
framework.ExpectError(err)
86+
87+
// make script executable
88+
err = os.Chmod("test.sh", 0755)
89+
framework.ExpectNoError(err)
90+
91+
// rerun sync command
92+
err = syncCmd.Run(f)
93+
framework.ExpectNoError(err)
94+
95+
// make sure we got the right result this time
96+
out, err := kubeClient.ExecByImageSelector("busybox", ns, []string{"sh", "-c", "/test_sync/test.sh"})
97+
framework.ExpectNoError(err)
98+
framework.ExpectEqual(string(out), "Hello World!\n")
99+
})
100+
39101
ginkgo.It("devspace sync should work with and without config", func() {
40102
tempDir, err := framework.CopyToTempDir("tests/sync/testdata/no-config")
41103
framework.ExpectNoError(err)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: v1beta11
2+
deployments:
3+
- name: test
4+
helm:
5+
componentChart: true
6+
values:
7+
containers:
8+
- image: busybox
9+
command: ["sleep", "999999999999"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo "Hello World!"

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/evanphx/json-patch v4.12.0+incompatible
1515
github.com/evanphx/json-patch/v5 v5.1.0
1616
github.com/ghodss/yaml v1.0.0
17-
github.com/golang/protobuf v1.5.2
17+
github.com/golang/protobuf v1.5.2 // indirect
1818
github.com/google/uuid v1.1.2
1919
github.com/gorilla/websocket v1.4.2
2020
github.com/inconshreveable/go-update v0.0.0-20160112193335-8152e7eb6ccf // indirect
@@ -45,6 +45,7 @@ require (
4545
github.com/vmware-labs/yaml-jsonpath v0.3.2
4646
golang.org/x/net v0.0.0-20210825183410-e898025ed96a
4747
google.golang.org/grpc v1.40.0
48+
google.golang.org/protobuf v1.27.1
4849
gopkg.in/natefinch/lumberjack.v2 v2.0.0
4950
gopkg.in/src-d/enry.v1 v1.6.4
5051
gopkg.in/src-d/go-git.v4 v4.13.1

0 commit comments

Comments
 (0)