|
5 | 5 | package supervisor
|
6 | 6 |
|
7 | 7 | import (
|
| 8 | + "bytes" |
8 | 9 | "context"
|
9 | 10 | "crypto/rand"
|
10 | 11 | "crypto/rsa"
|
@@ -1490,14 +1491,15 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst
|
1490 | 1491 | fn := "/workspace/.gitpod/content.json"
|
1491 | 1492 | fnReady := "/workspace/.gitpod/ready"
|
1492 | 1493 |
|
1493 |
| - contentFile, err := os.Open(fn) |
1494 |
| - if err != nil { |
1495 |
| - if !os.IsNotExist(err) { |
1496 |
| - log.WithError(err).Error("cannot open init descriptor") |
1497 |
| - return |
1498 |
| - } |
1499 |
| - |
1500 |
| - log.Infof("%s does not exist, going to wait for %s", fn, fnReady) |
| 1494 | + contentFile, err := os.ReadFile(fn) |
| 1495 | + if os.IsNotExist(err) { |
| 1496 | + contentFile = []byte(cfg.ContentInitializer) |
| 1497 | + } else if err != nil { |
| 1498 | + log.WithError(err).Error("cannot open init descriptor") |
| 1499 | + return |
| 1500 | + } |
| 1501 | + if len(contentFile) == 0 { |
| 1502 | + log.Infof("no content initializer provided, waiting for %s", fnReady) |
1501 | 1503 |
|
1502 | 1504 | // If there is no content descriptor the content must have come from somewhere (i.e. a layer or ws-daemon).
|
1503 | 1505 | // Let's wait for that to happen.
|
@@ -1529,11 +1531,9 @@ func startContentInit(ctx context.Context, cfg *Config, wg *sync.WaitGroup, cst
|
1529 | 1531 | return
|
1530 | 1532 | }
|
1531 | 1533 |
|
1532 |
| - defer contentFile.Close() |
1533 |
| - |
1534 | 1534 | log.Info("supervisor: running content service executor with content descriptor")
|
1535 | 1535 | var src csapi.WorkspaceInitSource
|
1536 |
| - src, err = executor.Execute(ctx, "/workspace", contentFile, true) |
| 1536 | + src, err = executor.Execute(ctx, "/workspace", bytes.NewReader(contentFile), true) |
1537 | 1537 | if err != nil {
|
1538 | 1538 | return
|
1539 | 1539 | }
|
|
0 commit comments