Skip to content

Commit 1afbe15

Browse files
committed
Undo local file mounting
1 parent 587883d commit 1afbe15

File tree

7 files changed

+16
-60
lines changed

7 files changed

+16
-60
lines changed

cmd/src/campaigns_common.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,12 @@ func campaignsExecute(ctx context.Context, out *output.Output, svc *campaigns.Se
174174
}
175175

176176
opts := campaigns.ExecutorOpts{
177-
Cache: svc.NewExecutionCache(flags.cacheDir),
178-
Creator: svc.NewWorkspaceCreator(flags.cacheDir, flags.cleanArchives),
179-
ClearCache: flags.clearCache,
180-
KeepLogs: flags.keepLogs,
181-
Timeout: flags.timeout,
182-
TempDir: flags.tempDir,
183-
SpecFilePath: flags.file,
177+
Cache: svc.NewExecutionCache(flags.cacheDir),
178+
Creator: svc.NewWorkspaceCreator(flags.cacheDir, flags.cleanArchives),
179+
ClearCache: flags.clearCache,
180+
KeepLogs: flags.keepLogs,
181+
Timeout: flags.timeout,
182+
TempDir: flags.tempDir,
184183
}
185184
if flags.parallelism <= 0 {
186185
opts.Parallelism = runtime.GOMAXPROCS(0)
@@ -237,15 +236,12 @@ func campaignsExecute(ctx context.Context, out *output.Output, svc *campaigns.Se
237236
campaignsCompletePending(pending, "Resolved repositories")
238237
}
239238

240-
// p := newCampaignProgressPrinter(out, opts.Parallelism)
241-
// specs, err := svc.ExecuteCampaignSpec(ctx, repos, executor, campaignSpec, p.PrintStatuses)
242-
specs, err := svc.ExecuteCampaignSpec(ctx, repos, executor, campaignSpec, func(ts []*campaigns.TaskStatus) {
243-
fmt.Printf("len(ts)=%d\n", len(ts))
244-
})
239+
p := newCampaignProgressPrinter(out, opts.Parallelism)
240+
specs, err := svc.ExecuteCampaignSpec(ctx, repos, executor, campaignSpec, p.PrintStatuses)
245241
if err != nil {
246242
return "", "", err
247243
}
248-
// p.Complete()
244+
p.Complete()
249245

250246
if logFiles := executor.LogFiles(); len(logFiles) > 0 && flags.keepLogs {
251247
func() {

internal/campaigns/campaign_spec.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ type Step struct {
7171
image string
7272
}
7373

74-
type StepLocalFileMount struct {
75-
FromFile string `json:"fromFile,omitempty"`
76-
}
77-
7874
func ParseCampaignSpec(data []byte) (*CampaignSpec, error) {
7975
var spec CampaignSpec
8076
if err := yaml.UnmarshalValidate(schema.CampaignSpecJSON, data, &spec); err != nil {

internal/campaigns/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) {
248248
defer cancel()
249249

250250
// Actually execute the steps.
251-
diff, err := runSteps(runCtx, x.SpecFilePath, x.creator, task.Repository, task.Steps, log, x.tempDir, func(currentlyExecuting string) {
251+
diff, err := runSteps(runCtx, x.creator, task.Repository, task.Steps, log, x.tempDir, func(currentlyExecuting string) {
252252
status.CurrentlyExecuting = currentlyExecuting
253253
x.updateTaskStatus(task, status)
254254
})

internal/campaigns/run_steps.go

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"io/ioutil"
1010
"os"
1111
"os/exec"
12-
"path/filepath"
1312
"strings"
1413
"text/template"
1514
"time"
@@ -19,7 +18,7 @@ import (
1918
"github.com/sourcegraph/src-cli/internal/campaigns/graphql"
2019
)
2120

22-
func runSteps(ctx context.Context, specFilePath string, wc *WorkspaceCreator, repo *graphql.Repository, steps []Step, logger *TaskLogger, tempDir string, reportProgress func(string)) ([]byte, error) {
21+
func runSteps(ctx context.Context, wc *WorkspaceCreator, repo *graphql.Repository, steps []Step, logger *TaskLogger, tempDir string, reportProgress func(string)) ([]byte, error) {
2322
reportProgress("Downloading archive")
2423

2524
volumeDir, err := wc.Create(ctx, repo)
@@ -102,7 +101,7 @@ func runSteps(ctx context.Context, specFilePath string, wc *WorkspaceCreator, re
102101
stepContext.PreviousStep = results[i-1]
103102
}
104103

105-
files, err := parseStepFiles(specFilePath, step.Files, &stepContext)
104+
files, err := parseStepFiles(step.Files, &stepContext)
106105
if err != nil {
107106
return nil, errors.Wrap(err, "parsing step files")
108107
}
@@ -330,37 +329,13 @@ func parseStepRun(run string, stepCtx *StepContext) (*template.Template, error)
330329
return template.New("step-run").Delims("${{", "}}").Funcs(stepCtx.ToFuncMap()).Parse(run)
331330
}
332331

333-
func parseStepFiles(specFilePath string, files map[string]interface{}, stepCtx *StepContext) (map[string]string, error) {
332+
func parseStepFiles(files map[string]interface{}, stepCtx *StepContext) (map[string]string, error) {
334333
containerFiles := make(map[string]string, len(files))
335334

336335
fnMap := stepCtx.ToFuncMap()
337336

338-
if specFilePath == "-" {
339-
specFilePath = ""
340-
}
341-
basePath := filepath.Dir(specFilePath)
342-
343337
for fileName, fileRaw := range files {
344-
// If the file exists relative to the campaign spec, we read it and
345-
// mount it.
346-
fmt.Printf("fileraw=%T\n", fileRaw)
347-
if local, ok := fileRaw.(StepLocalFileMount); ok {
348-
fmt.Printf("local=%s\n", local)
349-
localFileName := filepath.Join(basePath, local.FromFile)
350-
ok, err := fileExists(localFileName)
351-
if err != nil {
352-
return containerFiles, err
353-
}
354-
if ok {
355-
content, err := ioutil.ReadFile(localFileName)
356-
if err != nil {
357-
return containerFiles, err
358-
}
359-
containerFiles[fileName] = string(content)
360-
continue
361-
}
362-
}
363-
// Otherwise, we treat the file contents as a template and render it
338+
// We treat the file contents as a template and render it
364339
// into a buffer that we then mount into the code host.
365340
var out bytes.Buffer
366341

internal/campaigns/service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ type ExecutorOpts struct {
198198
VerboseLogger bool
199199
TempDir string
200200
CacheDir string
201-
SpecFilePath string
202201
}
203202

204203
func (svc *Service) NewExecutor(opts ExecutorOpts) Executor {

schema/campaign_spec.schema.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@
8585
"files": {
8686
"type": "object",
8787
"description": "Files that should be mounted into or be created inside the Docker container.",
88-
"additionalProperties": {
89-
"oneOf": [
90-
{"type": "string"},
91-
{"type":"object", "additionalProperties": false, "properties": {"fromFile": {"type":"string"}}}
92-
]
93-
}
88+
"additionalProperties": {"type": "string"}
9489
}
9590
}
9691
}

schema/campaign_spec_stringdata.go

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)