MCPcopy Create free account
hub / github.com/nikivdev/go / parseInstruction

Function parseInstruction

try/dockerlayers/main.go:328–348  ·  view source on GitHub ↗
(raw rawInstruction)

Source from the content-addressed store, hash-verified

326}
327
328func parseInstruction(raw rawInstruction) (parsedInstruction, error) {
329 text := raw.text
330 trimmed := strings.TrimSpace(text)
331 if trimmed == "" {
332 return parsedInstruction{}, nil
333 }
334 idx := strings.IndexFunc(trimmed, unicode.IsSpace)
335 var keyword, args string
336 if idx == -1 {
337 keyword = trimmed
338 } else {
339 keyword = trimmed[:idx]
340 args = strings.TrimSpace(trimmed[idx:])
341 }
342 return parsedInstruction{
343 Line: raw.line,
344 Keyword: strings.ToUpper(keyword),
345 Args: args,
346 Raw: trimmed,
347 }, nil
348}
349
350func readInstructions(path string) ([]rawInstruction, error) {
351 file, err := os.Open(path)

Callers 1

analyzeDockerfileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected