(id, newLastLine string, task *task.Task)
| 168 | } |
| 169 | |
| 170 | func setLog(id, newLastLine string, task *task.Task) error { |
| 171 | data, err := os.ReadFile(task.Task.LogFile) |
| 172 | if err != nil { |
| 173 | return fmt.Errorf("failed to read file: %v", err) |
| 174 | } |
| 175 | lines := strings.Split(string(data), "\n") |
| 176 | exist := false |
| 177 | for index, line := range lines { |
| 178 | if strings.Contains(line, id) { |
| 179 | timeStr := time.Now().Format("2006/01/02 15:04:05") |
| 180 | lines[index] = timeStr + " " + newLastLine |
| 181 | exist = true |
| 182 | break |
| 183 | } else { |
| 184 | lines[index] = strings.TrimSpace(lines[index]) |
| 185 | } |
| 186 | } |
| 187 | if !exist { |
| 188 | task.Log(newLastLine) |
| 189 | return nil |
| 190 | } |
| 191 | output := strings.Join(lines, "\n") |
| 192 | _ = os.WriteFile(task.Task.LogFile, []byte(output), os.ModePerm) |
| 193 | return nil |
| 194 | } |
| 195 | |
| 196 | func (c Client) PullImageWithProcessAndOptions(task *task.Task, imageName string, options image.PullOptions) error { |
| 197 | out, err := c.cli.ImagePull(context.Background(), imageName, options) |
no test coverage detected