Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Commit 9cf4508

Browse files
Formatting
1 parent 22ece62 commit 9cf4508

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

parse.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ type Heredoc struct {
1919
// Represents a single line (layer) in a Dockerfile.
2020
// For example `FROM ubuntu:xenial`
2121
type Command struct {
22-
Cmd string // lowercased command name (ex: `from`)
23-
SubCmd string // for ONBUILD only this holds the sub-command
24-
Json bool // whether the value is written in json form
25-
Original string // The original source line
26-
StartLine int // The original source line number which starts this command
27-
EndLine int // The original source line number which ends this command
28-
Flags []string // Any flags such as `--from=...` for `COPY`.
29-
Value []string // The contents of the command (ex: `ubuntu:xenial`)
22+
Cmd string // lowercased command name (ex: `from`)
23+
SubCmd string // for ONBUILD only this holds the sub-command
24+
Json bool // whether the value is written in json form
25+
Original string // The original source line
26+
StartLine int // The original source line number which starts this command
27+
EndLine int // The original source line number which ends this command
28+
Flags []string // Any flags such as `--from=...` for `COPY`.
29+
Value []string // The contents of the command (ex: `ubuntu:xenial`)
3030
Heredocs []Heredoc // Extra heredoc content attachments
3131
}
3232

@@ -96,9 +96,9 @@ func ParseReader(file io.Reader) ([]Command, error) {
9696
for _, heredoc := range child.Heredocs {
9797
cmd.Original = cmd.Original + heredoc.Content + heredoc.Name + "\n"
9898
cmd.Value = append(cmd.Value, heredoc.Content)
99-
cmd.Heredocs = append(cmd.Heredocs, Heredoc{Name: heredoc.Name,
100-
FileDescriptor: heredoc.FileDescriptor,
101-
Content: heredoc.Content})
99+
cmd.Heredocs = append(cmd.Heredocs, Heredoc{Name: heredoc.Name,
100+
FileDescriptor: heredoc.FileDescriptor,
101+
Content: heredoc.Content})
102102
}
103103
}
104104

parse_test.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,12 @@ EOF
134134
EndLine: 5,
135135
Flags: []string{},
136136
Value: []string{"source $HOME/.bashrc && echo $HOME\necho \"Hello\" >> /hello\necho \"World!\" >> /hello\n"},
137-
Heredocs: []Heredoc{Heredoc{Name: "EOF",
138-
FileDescriptor: 0,
139-
Content: "source $HOME/.bashrc && echo $HOME\necho \"Hello\" >> /hello\necho \"World!\" >> /hello\n"},
140-
},
137+
Heredocs: []Heredoc{
138+
Heredoc{
139+
Name: "EOF",
140+
FileDescriptor: 0,
141+
Content: "source $HOME/.bashrc && echo $HOME\necho \"Hello\" >> /hello\necho \"World!\" >> /hello\n"},
142+
},
141143
},
142144
}
143145
assert.Equal(t, expected, cmds)
@@ -160,13 +162,16 @@ FILE2
160162
EndLine: 5,
161163
Flags: []string{},
162164
Value: []string{"content 1\n", "content 2\n"},
163-
Heredocs: []Heredoc{Heredoc{Name: "FILE1",
164-
FileDescriptor: 0,
165-
Content: "content 1\n"},
166-
Heredoc{Name: "FILE2",
167-
FileDescriptor: 0,
168-
Content: "content 2\n"},
169-
},
165+
Heredocs: []Heredoc{
166+
Heredoc{
167+
Name: "FILE1",
168+
FileDescriptor: 0,
169+
Content: "content 1\n"},
170+
Heredoc{
171+
Name: "FILE2",
172+
FileDescriptor: 0,
173+
Content: "content 2\n"},
174+
},
170175
},
171176
}
172177
assert.Equal(t, expected, cmds)

0 commit comments

Comments
 (0)