Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beaver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
beaver
Commits
37f5d4e77864
Commit
37f5d4e77864
authored
2 years ago
by
Florent Aide
Browse files
Options
Downloads
Patches
Plain Diff
fix the hydrate bug on ---
parent
f376b5af1490
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#45297
passed
2 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runner/config.go
+24
-1
24 additions, 1 deletion
runner/config.go
runner/config_test.go
+1
-1
1 addition, 1 deletion
runner/config_test.go
with
25 additions
and
2 deletions
runner/config.go
+
24
−
1
View file @
37f5d4e7
package
runner
import
(
"bufio"
"bytes"
"crypto/sha256"
"fmt"
...
...
@@ -539,4 +540,25 @@
return
err
}
func
documentSplitter
(
input
io
.
Reader
)
[][]
byte
{
var
output
[][]
byte
var
tmpOut
[]
byte
scanner
:=
bufio
.
NewScanner
(
input
)
scanner
.
Split
(
bufio
.
ScanLines
)
for
scanner
.
Scan
()
{
text
:=
scanner
.
Bytes
()
// if sep is found first flush our buffer
if
string
(
text
)
==
"---"
{
// flush buffer
output
=
append
(
output
,
tmpOut
)
// initialize new buffer
tmpOut
=
[]
byte
{}
}
tmpOut
=
append
(
tmpOut
,
text
...
)
tmpOut
=
append
(
tmpOut
,
[]
byte
(
"
\n
"
)
...
)
}
output
=
append
(
output
,
tmpOut
)
return
output
}
func
Hydrate
(
input
[]
byte
,
output
io
.
Writer
,
variables
map
[
string
]
interface
{})
error
{
...
...
@@ -542,5 +564,6 @@
func
Hydrate
(
input
[]
byte
,
output
io
.
Writer
,
variables
map
[
string
]
interface
{})
error
{
documents
:=
bytes
.
Split
(
input
,
[]
byte
(
"---
\n
"
))
// documents := bytes.Split(input, []byte("---\n"))
documents
:=
documentSplitter
(
bytes
.
NewReader
(
input
))
// yaml lib ignore leading '---'
// see: https://github.com/go-yaml/yaml/issues/749
// which is an issue for ytt value files
...
...
This diff is collapsed.
Click to expand it.
runner/config_test.go
+
1
−
1
View file @
37f5d4e7
...
...
@@ -99,7 +99,7 @@
expected
:=
`
---
foo: 33
bar: |
-
bar: |
[section1]
value1 = 1
# ----------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment