Skip to content

Not applied patch if path contains Uppercase #329

Closed
@idubnori

Description

@idubnori

Repro code, Cause and Workaround

using System;
using k8s;
using k8s.Models;
using Microsoft.AspNetCore.JsonPatch;

namespace patch
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
            IKubernetes client = new Kubernetes(config);
            Console.WriteLine("Starting Request!");

            var patch = new JsonPatchDocument<V1HorizontalPodAutoscaler>();
            patch.Replace(h => h.Spec.MinReplicas, 10);

            // Root cause, Path does not honor JsonProperty. so, it would be /spec/minreplicas
            Console.WriteLine(patch.Operations[0].path);
            // Workaround
            patch.Operations[0].path = "/spec/minReplicas";

            var name = "<target-hpa>";
            var result = client.PatchNamespacedHorizontalPodAutoscaler(new V1Patch(patch), name, "default");

            Console.WriteLine(result.Spec.MinReplicas);
        }
    }
}
  • Latest Microsoft.AspNetCore.JsonPatch had been resolved this issue.
  • Will PR later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions