geeklearningio/gl-vsts-tasks-file-patch

YAML patch replaces words with array of last value

Closed this issue · 6 comments

Patch content:

= server => "$(TargetDatabaseServer.Name)"
= database => "$(Solvas.DatabaseName)$(UniqueAppend)"
= user => "$(DefaultLogin)"
= password => "$(DefaultPassword)"

YAML before applying patch:

# Database connection.
# When Slacker is executed, it will attempt to connect to this database.

# Replace the following with your connection information.
# Note that at this point Slacker only works with SQL Server authentication.

# Local Server
server: local_dev
database: Internal_DEV
user: someone
password: something

YAML after applying patch:

'0': s
'1': o
'2': m
'3': e
'4': t
'5': h
'6': i
'7': n
'8': g

Sorry to hear that, can you provide the debug log ?

2017-03-15T01:31:02.2359958Z ##[section]Starting: Update database.yml connection
2017-03-15T01:31:02.2659958Z ==============================================================================
2017-03-15T01:31:02.2659958Z Task         : Patch YAML Files
2017-03-15T01:31:02.2659958Z Description  : Patch YAML files using JSON patch syntax
2017-03-15T01:31:02.2659958Z Version      : 1.2.1999
2017-03-15T01:31:02.2659958Z Author       : Geek Learning
2017-03-15T01:31:02.2669958Z Help         : [More Information](https://github.com/geeklearningio/gl-vsts-tasks-file-patch/wiki/Patch-YAML-Files) (Version 1.2.1999)
2017-03-15T01:31:02.2669958Z ==============================================================================
2017-03-15T01:31:02.6029958Z ##[debug]agent.workFolder=I:\Agent\_work
2017-03-15T01:31:02.6029958Z ##[debug]loading inputs and endpoints
2017-03-15T01:31:02.6029958Z ##[debug]loading ENDPOINT_AUTH_$/
2017-03-15T01:31:02.6049958Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_$/_ACCESSTOKEN
2017-03-15T01:31:02.6059958Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2017-03-15T01:31:02.6059958Z ##[debug]loading ENDPOINT_AUTH_SCHEME_$/
2017-03-15T01:31:02.6059958Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2017-03-15T01:31:02.6069958Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2017-03-15T01:31:02.6069958Z ##[debug]loading INPUT_OUTPUTPATCHFILE
2017-03-15T01:31:02.6079958Z ##[debug]loading INPUT_SYNTAXTYPE
2017-03-15T01:31:02.6079958Z ##[debug]loading INPUT_YAMLPATCHCONTENT
2017-03-15T01:31:02.6079958Z ##[debug]loading INPUT_YAMLTARGETFILTERS
2017-03-15T01:31:02.6089958Z ##[debug]loading INPUT_YAMLWORKINGDIR
2017-03-15T01:31:02.6089958Z ##[debug]loading SECRET_SERVICEACCOUNTPASSWORD
2017-03-15T01:31:02.6099958Z ##[debug]loading SECRET_SQLPASSWORD
2017-03-15T01:31:02.6099958Z ##[debug]loaded 13
2017-03-15T01:31:02.7979958Z ##[debug]YamlWorkingDir=I:\Agent\_work\3\s\Spec
2017-03-15T01:31:02.7989958Z ##[debug]YamlPatchContent== server => "someplace"
2017-03-15T01:31:02.7989958Z = database => "Internal_160_84893_build9526"
2017-03-15T01:31:02.7989958Z = user => "someone"
2017-03-15T01:31:02.7989958Z = password => "something"
2017-03-15T01:31:02.7989958Z ##[debug]YamlTargetFilters=**\database.yml
2017-03-15T01:31:02.7999958Z ##[debug]OutputPatchFile=false
2017-03-15T01:31:02.7999958Z ##[debug]SyntaxType=slick
2017-03-15T01:31:02.9769958Z ##[debug]find I:\Agent\_work\3\s\Spec
2017-03-15T01:31:02.9769958Z ##[debug]1249 matches.
2017-03-15T01:31:03.0089958Z I:\Agent\_work\3\s\Spec\App.Db.Slacker\database.yml successfully patched.
2017-03-15T01:31:03.0119958Z I:\Agent\_work\3\s\Spec\Beachcomber.Db.Slacker\database.yml successfully patched.
2017-03-15T01:31:03.0119958Z ##[debug]task result: Succeeded
2017-03-15T01:31:03.0139958Z ##[debug]Processed: ##vso[task.complete result=Succeeded;]Files Patched
2017-03-15T01:31:03.0189958Z ##[section]Finishing: Update database.yml connection

Your patch is actually invalid as the path expressions does not include the required leading/.

Correct Patch is:

= /server => "$(TargetDatabaseServer.Name)"
= /database => "$(Solvas.DatabaseName)$(UniqueAppend)"
= /user => "$(DefaultLogin)"
= /password => "$(DefaultPassword)"

Which should definitely validate this and failed with an explicit message though.

Adding the slash fixes the result except it's wiping out all the preceding comments.

addressed in a1af9d9