Skip to content

Commit fd10218

Browse files
committed
refactor: remove dev.sync[*].onDownload option
1 parent 0d21c33 commit fd10218

File tree

5 files changed

+2
-78
lines changed

5 files changed

+2
-78
lines changed

pkg/devspace/config/versions/latest/schema.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,7 @@ type SyncConfig struct {
818818
WaitInitialSync *bool `yaml:"waitInitialSync,omitempty" json:"waitInitialSync,omitempty"`
819819
BandwidthLimits *BandwidthLimits `yaml:"bandwidthLimits,omitempty" json:"bandwidthLimits,omitempty"`
820820

821-
OnUpload *SyncOnUpload `yaml:"onUpload,omitempty" json:"onUpload,omitempty"`
822-
OnDownload *SyncOnDownload `yaml:"onDownload,omitempty" json:"onDownload,omitempty"`
821+
OnUpload *SyncOnUpload `yaml:"onUpload,omitempty" json:"onUpload,omitempty"`
823822
}
824823

825824
type ContainerArchitecture string

pkg/devspace/config/versions/v1beta11/upgrade.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ func (c *Config) mergeDevConfig(log log.Logger) (map[string]*next.DevPod, error)
644644
DisableUpload: syncConfig.DisableUpload,
645645
Polling: syncConfig.Polling,
646646
WaitInitialSync: syncConfig.WaitInitialSync,
647-
OnUpload: nil,
648-
OnDownload: nil,
649647
}
650648
syncPath := "."
651649
if syncConfig.LocalSubPath != "" {
@@ -704,31 +702,7 @@ func (c *Config) mergeDevConfig(log log.Logger) (map[string]*next.DevPod, error)
704702
}
705703
}
706704
if syncConfig.OnDownload != nil {
707-
nextSyncConfig.OnDownload = &next.SyncOnDownload{}
708-
if syncConfig.OnDownload.ExecLocal != nil {
709-
nextSyncConfig.OnDownload.ExecLocal = &next.SyncExecCommand{
710-
Command: syncConfig.OnDownload.ExecLocal.Command,
711-
Args: syncConfig.OnDownload.ExecLocal.Args,
712-
}
713-
if syncConfig.OnDownload.ExecLocal.OnBatch != nil {
714-
nextSyncConfig.OnDownload.ExecLocal.OnBatch = &next.SyncCommand{
715-
Command: syncConfig.OnDownload.ExecLocal.OnBatch.Command,
716-
Args: syncConfig.OnDownload.ExecLocal.OnBatch.Args,
717-
}
718-
}
719-
if syncConfig.OnDownload.ExecLocal.OnDirCreate != nil {
720-
nextSyncConfig.OnDownload.ExecLocal.OnDirCreate = &next.SyncCommand{
721-
Command: syncConfig.OnDownload.ExecLocal.OnDirCreate.Command,
722-
Args: syncConfig.OnDownload.ExecLocal.OnDirCreate.Args,
723-
}
724-
}
725-
if syncConfig.OnDownload.ExecLocal.OnFileChange != nil {
726-
nextSyncConfig.OnDownload.ExecLocal.OnFileChange = &next.SyncCommand{
727-
Command: syncConfig.OnDownload.ExecLocal.OnFileChange.Command,
728-
Args: syncConfig.OnDownload.ExecLocal.OnFileChange.Args,
729-
}
730-
}
731-
}
705+
log.Warnf("dev.sync[*].onDownload is not supported anymore in DevSpace v6, please use dev.sync[*].onUpload.exec instead")
732706
}
733707

734708
devContainer.Sync = append(devContainer.Sync, nextSyncConfig)

pkg/devspace/services/sync/controller.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,6 @@ func (c *controller) initClient(ctx *devspacecontext.Context, pod *v1.Pod, arch,
369369
options.Exec = syncConfig.OnUpload.Exec
370370
}
371371

372-
// Add onDownload hooks
373-
if syncConfig.OnDownload != nil && syncConfig.OnDownload.ExecLocal != nil {
374-
fileCmd, fileArgs, dirCmd, dirArgs := getSyncCommands(syncConfig.OnDownload.ExecLocal)
375-
options.FileChangeCmd = fileCmd
376-
options.FileChangeArgs = fileArgs
377-
options.DirCreateCmd = dirCmd
378-
options.DirCreateArgs = dirArgs
379-
}
380-
381372
if len(syncConfig.ExcludePaths) > 0 {
382373
options.ExcludePaths = syncConfig.ExcludePaths
383374
}

pkg/devspace/sync/sync.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ type Options struct {
3737

3838
RestartContainer bool
3939

40-
FileChangeCmd string
41-
FileChangeArgs []string
42-
43-
DirCreateCmd string
44-
DirCreateArgs []string
45-
4640
UploadBatchCmd string
4741
UploadBatchArgs []string
4842

pkg/devspace/sync/tar.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sync
33
import (
44
"archive/tar"
55
"compress/gzip"
6-
"github.com/loft-sh/devspace/pkg/util/command"
76
"github.com/loft-sh/devspace/pkg/util/fsutil"
87
"io"
98
"io/ioutil"
@@ -154,23 +153,6 @@ func (u *Unarchiver) untarNext(destPath string, tarReader *tar.Reader) (bool, er
154153
// Set mod time correctly
155154
_ = os.Chtimes(outFileName, time.Now(), header.ModTime)
156155

157-
// Execute command if defined
158-
if u.syncConfig.Options.FileChangeCmd != "" {
159-
cmdArgs := make([]string, 0, len(u.syncConfig.Options.FileChangeArgs))
160-
for _, arg := range u.syncConfig.Options.FileChangeArgs {
161-
if arg == "{}" {
162-
cmdArgs = append(cmdArgs, outFileName)
163-
} else {
164-
cmdArgs = append(cmdArgs, arg)
165-
}
166-
}
167-
168-
out, err := command.CombinedOutput(u.syncConfig.ctx, u.syncConfig.LocalPath, u.syncConfig.Options.FileChangeCmd, cmdArgs...)
169-
if err != nil {
170-
return false, errors.Errorf("Error executing command '%s %s': %s => %v", u.syncConfig.Options.FileChangeCmd, strings.Join(cmdArgs, " "), string(out), err)
171-
}
172-
}
173-
174156
// Update fileMap so that upstream does not upload the file
175157
u.syncConfig.fileIndex.fileMap[relativePath] = &FileInformation{
176158
Name: relativePath,
@@ -201,22 +183,6 @@ func (u *Unarchiver) createAllFolders(name string, perm os.FileMode) error {
201183

202184
return errors.Errorf("Error creating %s: %v", dirToCreate, err)
203185
}
204-
205-
if u.syncConfig.Options.DirCreateCmd != "" {
206-
cmdArgs := make([]string, 0, len(u.syncConfig.Options.DirCreateArgs))
207-
for _, arg := range u.syncConfig.Options.DirCreateArgs {
208-
if arg == "{}" {
209-
cmdArgs = append(cmdArgs, dirToCreate)
210-
} else {
211-
cmdArgs = append(cmdArgs, arg)
212-
}
213-
}
214-
215-
out, err := command.CombinedOutput(u.syncConfig.ctx, u.syncConfig.LocalPath, u.syncConfig.Options.DirCreateCmd, cmdArgs...)
216-
if err != nil {
217-
return errors.Errorf("Error executing command '%s %s': %s => %v", u.syncConfig.Options.DirCreateCmd, strings.Join(cmdArgs, " "), string(out), err)
218-
}
219-
}
220186
}
221187

222188
return nil

0 commit comments

Comments
 (0)