Change all fmt.Errorfs to use %w
This commit is contained in:
+1
-1
@@ -79,7 +79,7 @@ func GetConfig() (config.Config[Config], error) {
|
||||
|
||||
_, err := configData.Get()
|
||||
if err != nil {
|
||||
return configData, fmt.Errorf("Could not read config file: %v", err)
|
||||
return configData, fmt.Errorf("Could not read config file: %w", err)
|
||||
}
|
||||
|
||||
return configData, nil
|
||||
|
||||
@@ -40,7 +40,7 @@ func ExecutePipeline(pe PipelineExecution, pipelineConf config.PipelineConf) err
|
||||
|
||||
err = os.MkdirAll(jobFolder, 0755)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create working directory for job %v: %v", pe.Name, err)
|
||||
return fmt.Errorf("could not create working directory for job %v: %w", pe.Name, err)
|
||||
}
|
||||
|
||||
log.Infof("Cloning source from URL %v", pe.Job.URL)
|
||||
@@ -49,12 +49,12 @@ func ExecutePipeline(pe PipelineExecution, pipelineConf config.PipelineConf) err
|
||||
output, err := cloneCmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Debugf("%s", output)
|
||||
return fmt.Errorf("could not clone source: %v", err)
|
||||
return fmt.Errorf("could not clone source: %w", err)
|
||||
}
|
||||
|
||||
cli, err := client.NewClientWithOpts(client.FromEnv)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not create docker client: %v", err)
|
||||
return fmt.Errorf("Could not create docker client: %w", err)
|
||||
}
|
||||
log.Info("Source cloned successfully")
|
||||
|
||||
@@ -65,18 +65,18 @@ func ExecutePipeline(pe PipelineExecution, pipelineConf config.PipelineConf) err
|
||||
log.Infof("Pulling image %v", imageName)
|
||||
pullOutput, err := cli.ImagePull(ctx, imageName, types.ImagePullOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not pull image %v: %v", imageName, err)
|
||||
return fmt.Errorf("could not pull image %v: %w", imageName, err)
|
||||
}
|
||||
|
||||
buf, err := io.ReadAll(pullOutput)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not read from io.ReadCloser:, %v", err)
|
||||
return fmt.Errorf("could not read from io.ReadCloser:, %w", err)
|
||||
}
|
||||
log.Infof("%s", buf)
|
||||
|
||||
err = pullOutput.Close()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not close io.ReadCloser: %v", err)
|
||||
return fmt.Errorf("could not close io.ReadCloser: %w", err)
|
||||
}
|
||||
log.Info("Image pulled sucessfully")
|
||||
|
||||
@@ -123,19 +123,19 @@ func ExecutePipeline(pe PipelineExecution, pipelineConf config.PipelineConf) err
|
||||
nil, nil, "",
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create container: %v", err)
|
||||
return fmt.Errorf("could not create container: %w", err)
|
||||
}
|
||||
|
||||
log.Info("Launching container")
|
||||
|
||||
if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
|
||||
return fmt.Errorf("could not start container: %v", err)
|
||||
return fmt.Errorf("could not start container: %w", err)
|
||||
}
|
||||
statusCh, errCh := cli.ContainerWait(ctx, resp.ID, container.WaitConditionNotRunning)
|
||||
select {
|
||||
case err := <-errCh:
|
||||
if err != nil {
|
||||
return fmt.Errorf("container returned error: %v", err)
|
||||
return fmt.Errorf("container returned error: %w", err)
|
||||
}
|
||||
case retCode := <-statusCh:
|
||||
log.Debugf("Container finished running with return code: %v", retCode)
|
||||
@@ -143,7 +143,7 @@ func ExecutePipeline(pe PipelineExecution, pipelineConf config.PipelineConf) err
|
||||
|
||||
out, err := cli.ContainerLogs(ctx, resp.ID, types.ContainerLogsOptions{ShowStdout: true, ShowStderr: true})
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not get container logs: %v", err)
|
||||
return fmt.Errorf("could not get container logs: %w", err)
|
||||
}
|
||||
|
||||
var stdOut bytes.Buffer
|
||||
|
||||
Reference in New Issue
Block a user