Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions pkg/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ func getOutOfClusterContextsClients(opts KubeConfigOptions) ([]*ContextClient, e
}

clientConfig, err := GetClientConfig(
opts.Context,
"",
opts.ConfigPath,
configData,
opts.ConfigPathMergeList,
Expand All @@ -356,7 +356,7 @@ func getOutOfClusterContextsClients(opts KubeConfigOptions) ([]*ContextClient, e

for contextName, context := range rc.Contexts {
clientConfig, err := GetClientConfig(
opts.Context,
contextName,
opts.ConfigPath,
configData,
opts.ConfigPathMergeList,
Expand Down Expand Up @@ -477,16 +477,29 @@ func restMapper(cachedDiscoveryClient *discovery.CachedDiscoveryInterface) meta.
}

func getTokenContextClient(opts KubeConfigOptions) (*ContextClient, error) {
if opts.BearerToken == "" || opts.APIServerURL == "" {
return nil, fmt.Errorf("cannot create client: missing token or API server URL")
if opts.BearerToken == "" {
return nil, fmt.Errorf("missing bearer token")
}
if opts.APIServerURL == "" {
return nil, fmt.Errorf("missing API server URL")
}

var caData []byte
var err error

if opts.CADataBase64 != "" {
caData, err = base64.StdEncoding.DecodeString(opts.CADataBase64)
if err != nil {
return nil, fmt.Errorf("invalid CADataBase64: %w", err)
}
}

cfg := &rest.Config{
Host: opts.APIServerURL,
BearerToken: opts.BearerToken,
TLSClientConfig: rest.TLSClientConfig{
Insecure: opts.Insecure,
CAData: []byte(opts.CADataBase64),
CAData: caData,
},
}

Expand Down
Loading