Fix linter
This commit is contained in:
parent
f3d73b97ad
commit
1d5c64d8ca
10 changed files with 15 additions and 15 deletions
|
@ -29,7 +29,7 @@ func (h *HeartbeatHandler) doHeartbeat(w http.ResponseWriter, r *http.Request) e
|
||||||
}
|
}
|
||||||
|
|
||||||
var req HeartbeatRequest
|
var req HeartbeatRequest
|
||||||
if err := json.Unmarshal(reqJSON, &req); err != nil {
|
if err = json.Unmarshal(reqJSON, &req); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ type testCache struct {
|
||||||
tmpDir string
|
tmpDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testCache) cleanup() error {
|
func (c *testCache) cleanup() {
|
||||||
return os.RemoveAll(c.tmpDir)
|
_ = os.RemoveAll(c.tmpDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestCache(t *testing.T) *testCache {
|
func newTestCache(t *testing.T) *testCache {
|
||||||
|
|
|
@ -16,7 +16,7 @@ func Download(ctx context.Context, endpoint string, c *Cache, artifactID build.I
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer abort()
|
defer func() { _ = abort() }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint+"/artifact?id="+artifactID.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint+"/artifact?id="+artifactID.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (c *Client) Build(ctx context.Context, graph build.Graph, lsn BuildListener
|
||||||
}
|
}
|
||||||
|
|
||||||
c.l.Debug("build started", zap.String("build_id", started.ID.String()))
|
c.l.Debug("build started", zap.String("build_id", started.ID.String()))
|
||||||
if err := c.uploadSources(ctx, &graph, started); err != nil {
|
if err = c.uploadSources(ctx, &graph, started); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (c *Client) Download(ctx context.Context, localCache *Cache, id build.ID) e
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer abort()
|
defer func() { _ = abort() }()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/file?id="+id.String(), nil)
|
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/file?id="+id.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,7 +31,7 @@ func newEnv(t *testing.T) *env {
|
||||||
cache := newCache(t)
|
cache := newCache(t)
|
||||||
defer func() {
|
defer func() {
|
||||||
if cache != nil {
|
if cache != nil {
|
||||||
_ = cache.cleanup()
|
cache.cleanup()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func newEnv(t *testing.T) *env {
|
||||||
|
|
||||||
func (e *env) stop() {
|
func (e *env) stop() {
|
||||||
e.server.Close()
|
e.server.Close()
|
||||||
_ = e.cache.cleanup()
|
e.cache.cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileUpload(t *testing.T) {
|
func TestFileUpload(t *testing.T) {
|
||||||
|
@ -99,11 +99,11 @@ func TestFileUpload(t *testing.T) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(G)
|
wg.Add(G)
|
||||||
|
|
||||||
|
id := build.ID{0x03, byte(i)}
|
||||||
for j := 0; j < G; j++ {
|
for j := 0; j < G; j++ {
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
id := build.ID{0x03, byte(j)}
|
|
||||||
assert.NoError(t, env.client.Upload(ctx, id, tmpFilePath))
|
assert.NoError(t, env.client.Upload(ctx, id, tmpFilePath))
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func TestFileDownload(t *testing.T) {
|
||||||
|
|
||||||
w, abort, err := env.cache.Write(id)
|
w, abort, err := env.cache.Write(id)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer abort()
|
defer func() { _ = abort() }()
|
||||||
|
|
||||||
_, err = w.Write([]byte("foobar"))
|
_, err = w.Write([]byte("foobar"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -27,8 +27,8 @@ func newCache(t *testing.T) *testCache {
|
||||||
return &testCache{Cache: c, tmpDir: tmpDir}
|
return &testCache{Cache: c, tmpDir: tmpDir}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testCache) cleanup() error {
|
func (c *testCache) cleanup() {
|
||||||
return os.Remove(c.tmpDir)
|
_ = os.Remove(c.tmpDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFileCache(t *testing.T) {
|
func TestFileCache(t *testing.T) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (h *Handler) doPut(w http.ResponseWriter, r *http.Request, id build.ID) err
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer abort()
|
defer func() { _ = abort() }()
|
||||||
|
|
||||||
if _, err = io.Copy(w, r.Body); err != nil {
|
if _, err = io.Copy(w, r.Body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -12,7 +12,7 @@ func (w *Worker) pullFiles(ctx context.Context, files map[build.ID]string) error
|
||||||
for id := range files {
|
for id := range files {
|
||||||
_, unlock, err := w.fileCache.Get(id)
|
_, unlock, err := w.fileCache.Get(id)
|
||||||
if errors.Is(err, filecache.ErrNotFound) {
|
if errors.Is(err, filecache.ErrNotFound) {
|
||||||
if err := w.fileClient.Download(ctx, w.fileCache, id); err != nil {
|
if err = w.fileClient.Download(ctx, w.fileCache, id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
|
@ -165,7 +165,7 @@ func (w *Worker) runJob(ctx context.Context, spec *api.JobSpec) (*api.JobResult,
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := w.pullFiles(ctx, spec.SourceFiles); err != nil {
|
if err = w.pullFiles(ctx, spec.SourceFiles); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue