Skip to content
This repository was archived by the owner on Apr 10, 2026. It is now read-only.
This repository was archived by the owner on Apr 10, 2026. It is now read-only.

Allow fetchEnvs to pull data from json strings #125

@alewitt2

Description

@alewitt2

Is your feature request related to a problem? Please describe.
currently there is no way to get data from inside a json string defined in a cm. you can specify type: json, but that only parses the json and leaves its keys as a second class citizen.

Describe the solution you'd like
give a way to pull a single key or all the keys from a json into the top level of the returned fetchEnvs obj.

Describe alternatives you've considered
use fetchEnvs to get the json, then do post processing on the returned object to flatten accordingly

Additional context


example configmap

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-info
  namespace: kube-system
data:
  cluster-config: |
    {
      "cluster_id": "1234",
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }

a normal example of using .env in razee

env
  - name: cluster-config # name of the key the fetched data will be assigned to
    valueFrom:
      configMapKeyRef:
        key: cluster-config # key within configmap
        name: cluster-info # configmap name
        namespace: kube-system # configmap namespace
        type: json # tells fetchEnvs to parse the fetched key

with a result of

{
  "cluster-config":
    {
      "cluster_id": "1234",
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }
}

example configmap

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-info
  namespace: kube-system
data:
  cluster-config: |
    {
      "cluster_id": "1234",
      "cluster_metadata": {
          "created": "sometimelastweek"
        },
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }

example of using .env and being able to specify the path to a lower level json key

env:
  - name: cluster_created # name of key retrieved data will be assigned to
    valueFrom:
      configMapKeyRef:
        key: cluster-config # key within configmap
        name: cluster-info # configmap name
        namespace: kube-system # configmap namespace
        type: json # tells fetchEnvs to parse the fetched key
        pathStr: 'cluster_metadata.created' # must have type defined

with a result of

{
  "cluster_created": "sometimelastweek"
}

example configmap with . in key name

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-info
  namespace: kube-system
data:
  cluster-config: |
    {
      "cluster_id": "1234",
      "cluster.metadata": {
          "created": "sometimelastweek"
        },
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }

example of using .env and being able to specify the path to a lower level json key

env:
  - name: cluster_created # name of key retrieved data will be assigned to
    valueFrom:
      configMapKeyRef:
        key: cluster-config# key within configmap
        name: cluster-info # configmap name
        namespace: kube-system # configmap namespace
        type: json # tells fetchEnvs to parse the fetched key
        path: ['cluster.metadata', 'created'] # must have type defined

with a result of

{
  "cluster_created": "sometimelastweek"
}

example configmap

apiVersion: v1
kind: ConfigMap
metadata:
  name: cluster-info
  namespace: kube-system
data:
  cluster-config: |
    {
      "cluster_id": "1234",
      "cluster_metadata": {
          "created": "sometimelastweek"
        },
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }

example of using .env and being able to specify the path to get all json items

env:
  - name: cluster_created # not used when path all `.` is defined
    valueFrom:
      configMapKeyRef:
        key: cluster-config # key within configmap
        name: cluster-info # configmap name
        namespace: kube-system # configmap namespace
        type: json # tells fetchEnvs to parse the fetched key
        pathStr: '.' # must have type defined

with a result of

    {
      "cluster_id": "1234",
      "cluster_metadata": {
          "created": "sometimelastweek"
        },
      "cluster_name": "dev-mexico",
      "cluster_type": "dev"
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions