yq icon indicating copy to clipboard operation
yq copied to clipboard

load_props can't read dotted key

Open steled opened this issue 2 years ago • 1 comments

Describe the bug I'm trying to use merge from properties to set a yaml value via load_props with a properties file. Unfortunately the yaml key is dotted and it seems that this is not working currently.

Note that any how to questions should be posted in the discussion board and not raised as an issue.

Version of yq: 4.34.1 Operating system: Ubuntu 22.04.2 LTS Installed via: binary release

Input Yaml

flatcar.yml:

apiVersion: cluster.k8s.io/v1alpha1
kind: MachineDeployment
metadata:
  annotations:
    k8c.io/operating-system-profile: test
  name: test
  namespace: kube-system

machines_flatcar.properties:

metadata.name = flatcar
metadata.annotations.k8c.io/operating-system-profile = flatcar

Command The command you ran:

yq '. *= load_props("machines_flatcar.properties:")' flatcar.yml

Actual behavior

apiVersion: cluster.k8s.io/v1alpha1
kind: MachineDeployment
metadata:
  annotations:
    k8c.io/operating-system-profile: test
  k8c:
      io/operating-system-profile: flatcar
  name: flatcar
  namespace: kube-system

Expected behavior

apiVersion: cluster.k8s.io/v1alpha1
kind: MachineDeployment
metadata:
  annotations:
    k8c.io/operating-system-profile: flatcar
  name: flatcar
  namespace: kube-system

steled avatar Aug 25 '23 07:08 steled

I think there is a general issue with reading keys with dots in properties file. It works with yaml:

echo "foo.bar: 1" | yq -p y '."foo.bar"'
1

Fails with properties:

echo "foo.bar=1" | yq -p p '."foo.bar"'
null

michalszelagsonos avatar Nov 06 '23 21:11 michalszelagsonos