MCPcopy Create free account
hub / github.com/devspace-sh/devspace / ConvertRestConfigToRawConfig

Function ConvertRestConfigToRawConfig

pkg/devspace/kubectl/util/util.go:108–146  ·  view source on GitHub ↗
(config *rest.Config, namespace string)

Source from the content-addressed store, hash-verified

106}
107
108func ConvertRestConfigToRawConfig(config *rest.Config, namespace string) (*clientcmdapi.Config, error) {
109 contextName := localContext
110 kubeConfig := clientcmdapi.NewConfig()
111 kubeConfig.Contexts = map[string]*clientcmdapi.Context{
112 contextName: {
113 Cluster: contextName,
114 AuthInfo: contextName,
115 Namespace: namespace,
116 },
117 }
118 kubeConfig.Clusters = map[string]*clientcmdapi.Cluster{
119 contextName: {
120 Server: config.Host,
121 InsecureSkipTLSVerify: config.Insecure,
122 CertificateAuthorityData: config.CAData,
123 CertificateAuthority: config.CAFile,
124 },
125 }
126 kubeConfig.AuthInfos = map[string]*clientcmdapi.AuthInfo{
127 contextName: {
128 Token: config.BearerToken,
129 TokenFile: config.BearerTokenFile,
130 Impersonate: config.Impersonate.UserName,
131 ImpersonateGroups: config.Impersonate.Groups,
132 ImpersonateUserExtra: config.Impersonate.Extra,
133 ClientCertificate: config.CertFile,
134 ClientCertificateData: config.CertData,
135 ClientKey: config.KeyFile,
136 ClientKeyData: config.KeyData,
137 Username: config.Username,
138 Password: config.Password,
139 AuthProvider: config.AuthProvider,
140 Exec: config.ExecProvider,
141 },
142 }
143 kubeConfig.CurrentContext = contextName
144 raw, err := clientcmd.NewDefaultClientConfig(*kubeConfig, &clientcmd.ConfigOverrides{}).RawConfig()
145 return &raw, err
146}

Callers 1

NewClientByContextFunction · 0.85

Calls 1

NewConfigMethod · 0.65

Tested by

no test coverage detected