gl-vsts-tasks-file-patch icon indicating copy to clipboard operation
gl-vsts-tasks-file-patch copied to clipboard

Change Variable with forward slash

Open codehepta opened this issue 3 years ago • 0 comments

Are you reporting a bug or a feature request ?

  • [] Bug
  • [*] Feature request

Description

I am using Patch YAML and with Slick Syntax. My Patch content is : = /spec/template/metadata/labels/app.kubernetes.io/version => "v2022.ZZ" The Problem here is my yaml is something like :

...
metadata:
      labels:
        app.kubernetes.io/name: something
        app.kubernetes.io/instance: something
        app.kubernetes.io/component: backend
        environment: production
        app: appname
        app.kubernetes.io/version: "v2022.XX"
...

I tried two slashes and doesnt work. Is there a way to use / in variable or it is a feature request?

Here is my pipeline output Starting: Patch files deployment.yaml

Task : Patch YAML Files Description : Patch YAML files using JSON patch syntax Version : 4.0.1007 Author : Geek Learning Help : More Information (Version 4.0.1007)

##[warning]Invalid patch at index 0 = /spec/template/metadata/labels/app.kubernetes.io/version => "v2022.ZZ" OPERATION_PATH_UNRESOLVABLE Cannot perform the operation at a path that does not exist name: OPERATION_PATH_UNRESOLVABLE

Expected behavior

Describe the expected behavior

Reproduction

Insert reproduction steps here

MANDATORY FOR BUGS: Insert debug trace. If you don't provide it it makes it hard to understand what you are facing. 
To get a meaningful Trace don't forget to set System.Debug variable to true when queuing.

In order to allow us to quickly reproduce you issue please include a link to a reproduction repository

System information

VSTS or TFS:

  • [ ] VSTS
  • [ *] TFS

Agent:

  • [ *] Hosted
  • [ ] Custom

OS:

  • [ *] Windows
  • [ ] Mac
  • [ ] Linux

I tried my patch with https://json-schema-validator.herokuapp.com/jsonpatch.jsp and according to Json Pointer i changed my content as : = /spec/template/metadata/labels/app.kubernetes.io~1version => "v2022.ZZ" this patch is working in test but not working in AzureDevops here is the output: = /spec/template/metadata/labels/app.kubernetes.io~1version => "something" OPERATION_PATH_UNRESOLVABLE Cannot perform the operation at a path that does not exist name: OPERATION_PATH_UNRESOLVABLE index: 0 operation: { "op": "replace", "path": "/spec/template/metadata/labels/app.kubernetes.io~1version", "value": "something" }

https://github.com/json-patch/json-patch-tests/issues/42

codehepta avatar Sep 27 '22 11:09 codehepta