INNER CODE UNIT · Go

getSanitizedKubeconfigForKubeconfigPath

danielfoehrKn/kubeswitch · pkg/main.go:281

func getSanitizedKubeconfigForKubeconfigPath(kubeconfigStore storetypes.KubeconfigStore, path string, tags map[string]string) (string, error) {
	// during first run without index, the files are already read in the getContextsForKubeconfigPath and saved in-memory
	kubeconfig := readFromPathToKubeconfig(path)
	if len(kubeconfig) > 0 {
		return kubeconfig, nil
	}

	data, err := kubeconfigStore.GetKubeconfigForPath(path, tags)
	if err != nil {
		return "", fmt.Errorf("could not read kubeconfig with path '%s': %v", path, err)
	}

	config, err := util.ParseSanitizedKubeconfig(data)
	if err != nil {
		return "", fmt.Errorf("could not parse kubeconfig with path '%s': %v", path, err)
	}

	kubeconfigData, err := yaml.Marshal(config)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…