Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KubeConfigMerger object poorly structured when KUBECONFIG is a list of files. #2239

Open
ralberrto opened this issue May 25, 2024 · 2 comments
Assignees
Labels
kind/documentation Categorizes issue or PR as related to documentation.

Comments

@ralberrto
Copy link

ralberrto commented May 25, 2024

I'm new around here and I was exploring the configuration flow/data structures and I ran into the realization that when I have the following set of config files:

KUBECONFIG=~/.kube/config-1:~/.kube/config-2:~/.kube/config-3

A KubeConfigMerger is constructed as follows (I went for a JSON representaiton of the object):

{
  "KubeConfigMerger.config": {
    "ConfigNode": {
      "name": "path-1",
      "path": "path-1",
      "value": {
        "clusters": [
          {
            "ConfigNode": {
              "name": "path-1/{\"cluster\": {\"server\": \"server-1\"}, \"name\": \"cluster-name-1\"}\n",
              "path": "path-1",
              "value": {
                "cluster": {
                  "server": "server-1"
                },
                "name": "cluster-name-1"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-2/{\"cluster\": {\"server\": \"server-2\"}, \"name\": \"cluster-name-2\"}\n",
              "path": "path-2",
              "value": {
                "cluster": {
                  "server": "server-2"
                },
                "name": "cluster-name-2"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-3/{\"cluster\": {\"server\": \"server-3\"}, \"name\": \"cluster-name-3\"}\n",
              "path": "path-3",
              "value": {
                "cluster": {
                  "server": "server-3"
                },
                "name": "cluster-name-3"
              }
            }
          }
        ],
        "contexts": [
          {
            "ConfigNode": {
              "name": "path-1/{\"context\": {\"cluster\": \"server-1\", \"namespace\": \"namespace-1\", \"user\": \"user-1\"}, \"name\": \"context-name-1\"}\n",
              "path": "path-1",
              "value": {
                "context": {
                  "cluster": "server-1",
                  "namespace": "server-1",
                  "user": "user-1"
                },
                "name": "context-name-1"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-2/{\"context\": {\"cluster\": \"server-2\", \"namespace\": \"namespace-2\", \"user\": \"user-2\"}, \"name\": \"context-name-2\"}\n",
              "path": "path-2",
              "value": {
                "context": {
                  "cluster": "server-2",
                  "namespace": "server-2",
                  "user": "user-2"
                },
                "name": "context-name-2"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-3/{\"context\": {\"cluster\": \"server-3\", \"namespace\": \"namespace-3\", \"user\": \"user-3\"}, \"name\": \"context-name-3\"}\n",
              "path": "path-3",
              "value": {
                "context": {
                  "cluster": "server-3",
                  "namespace": "server-3",
                  "user": "user-3"
                },
                "name": "context-name-3"
              }
            }
          }
        ],
        "users": [
          {
            "ConfigNode": {
              "name": "path-1/{\"user\": {\"token\": \"token-1\"}, \"name\": \"user-name-1\"}\n",
              "path": "path-1",
              "value": {
                "user": {
                  "token": "token-1"
                },
                "name": "user-name-1"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-2/{\"user\": {\"token\": \"token-2\"}, \"name\": \"user-name-2\"}\n",
              "path": "path-2",
              "value": {
                "user": {
                  "token": "token-2"
                },
                "name": "user-name-2"
              }
            }
          },
          {
            "ConfigNode": {
              "name": "path-3/{\"user\": {\"token\": \"token-3\"}, \"name\": \"user-name-3\"}\n",
              "path": "path-3",
              "value": {
                "user": {
                  "token": "token-3"
                },
                "name": "user-name-3"
              }
            }
          }
        ],
        "current_context": "current-context"
      }
    }
  }
}

So now the question is: Is the main ConfigNode whose atributes path and name take the name of the first file structured as intended?

@ralberrto ralberrto added the kind/documentation Categorizes issue or PR as related to documentation. label May 25, 2024
@ralberrto
Copy link
Author

ralberrto commented May 25, 2024

I can see that the KubeConfigMerger.config is consumed by KubeConfigLoader as a ConfigNode, so I'm guessing those two attributes are just a consequence of the ConfigNode requiring them and are probably set there to not much purpose?

@yliaog
Copy link
Contributor

yliaog commented Jun 5, 2024

/assign @ralberrto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

No branches or pull requests

2 participants