{"action":"opened","issue":{"url":"https://api.github.com/repos/pivotal-cf/yaml-patch/issues/2","repository_url":"https://api.github.com/repos/pivotal-cf/yaml-patch","labels_url":"https://api.github.com/repos/pivotal-cf/yaml-patch/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/pivotal-cf/yaml-patch/issues/2/comments","events_url":"https://api.github.com/repos/pivotal-cf/yaml-patch/issues/2/events","html_url":"https://github.com/pivotal-cf/yaml-patch/issues/2","id":301488609,"number":2,"title":"Result file reorders original yaml file alphabetically for remove/replace operations","user":{"login":"hajinsu9","id":36965216,"avatar_url":"https://avatars3.githubusercontent.com/u/36965216?v=4","gravatar_id":"","url":"https://api.github.com/users/hajinsu9","html_url":"https://github.com/hajinsu9","followers_url":"https://api.github.com/users/hajinsu9/followers","following_url":"https://api.github.com/users/hajinsu9/following{/other_user}","gists_url":"https://api.github.com/users/hajinsu9/gists{/gist_id}","starred_url":"https://api.github.com/users/hajinsu9/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hajinsu9/subscriptions","organizations_url":"https://api.github.com/users/hajinsu9/orgs","repos_url":"https://api.github.com/users/hajinsu9/repos","events_url":"https://api.github.com/users/hajinsu9/events{/privacy}","received_events_url":"https://api.github.com/users/hajinsu9/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-01T17:18:47Z","updated_at":"2018-03-01T17:18:47Z","closed_at":null,"author_association":"NONE","body":"When using the remove/replace operations the result file is reorganized alphabetically. This causes issues because in the pipeline file the order is important.\r\n\r\n**Source YAML file**\r\n```\r\n---\r\njobs:\r\n- name: my-job\r\n  plan:\r\n  - get: my-resource\r\n  - task: first-task\r\n    file: task1.yml\r\n  - task: second-task\r\n    file: task2.yml\r\n```\r\n\r\n**Operations File**\r\n```\r\n- op: replace\r\n  path: /jobs/name=my-job/plan/task=second-task\r\n  value:\r\n    task: abc\r\n    file: abc\r\n```\r\n\r\n**Expected Result YAML file**\r\n```\r\njobs:\r\n- name: my-job\r\n  plan:\r\n  - get: my-resource\r\n  - task: first-task\r\n    file: task1.yml\r\n  - task: abc\r\n    file: abc\r\n```\r\n\r\n**Actual Result YAML file**\r\n```\r\njobs:\r\n- name: my-job\r\n  plan:\r\n  - get: my-resource\r\n  - file: task1.yml\r\n    task: first-task\r\n  - file: abc\r\n    task: abc\r\n```\r\n# Steps to Reproduce\r\nCopy and paste below code into a file and run using `go run FILENAME.go` in terminal\r\n## Code\r\n```\r\npackage main\r\nimport (\r\n  \"fmt\"\r\n  \"log\"\r\n  yamlpatch \"github.com/pivotal-cf/yaml-patch\"\r\n)\r\nfunc main() {\r\n  doc := []byte(`---\r\n  jobs:\r\n  - name: my-job\r\n    plan:\r\n    - get: my-resource\r\n    - task: first-task\r\n      file: task1.yml\r\n    - task: second-task\r\n      file: task2.yml\r\n  `)\r\n\r\n  ops := []byte(`---\r\n  - op: replace\r\n    path: /jobs/name=my-job/plan/task=second-task\r\n    value:\r\n      task: abc\r\n      file: abc\r\n  `)\r\n\r\n  patch, err := yamlpatch.DecodePatch(ops)\r\n  if err != nil {\r\n    log.Fatalf(\"decoding patch failed: %s\", err)\r\n  }\r\n\r\n  bs, err := patch.Apply(doc)\r\n  if err != nil {\r\n    log.Fatalf(\"applying patch failed: %s\", err)\r\n  }\r\n  fmt.Println(string(bs))\r\n}\r\n```\r\n\r\n"}}
{"actor":{"display_login":"hajinsu9"}}