Find duplicates in environment variables defined in YAML file

40 Views Asked by At

I have a kubernetes deployment YAML file, with defined environment variables including duplicated environment variables. My goal is detect them and print them, as I have hundreds of files which needs to parsed.

Example YAML:

kind: ReplicationController
apiVersion: v1
  spec:
    template:
      spec:
        containers:
          env:
            - name: PROFILE
              value: some_value
            - name: PROFILE
              value: some_value

The environment variable key is duplicated with a value, I want to detect it and print the duplicated key.

I tried using PyYAML library in Python but it does not detects at the environment variables level.

Any examples would be highly appreciated.

0

There are 0 best solutions below