Skip to content

Commit b623c67

Browse files
committed
expose KubeConfigFromREST in envtest
Signed-off-by: Tiger Kaovilai <[email protected]>
1 parent 5dfe321 commit b623c67

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/envtest/server.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,12 @@ type Environment struct {
126126
// loading.
127127
Config *rest.Config
128128

129+
// KubeConfig provides []byte of a kubeconfig file to talk to the apiserver
130+
// It's automatically
131+
// populated if not set using the standard controller-runtime config
132+
// loading.
133+
KubeConfig []byte
134+
129135
// CRDInstallOptions are the options for installing CRDs.
130136
CRDInstallOptions CRDInstallOptions
131137

@@ -221,6 +227,10 @@ func (te *Environment) Start() (*rest.Config, error) {
221227
if err != nil {
222228
return nil, fmt.Errorf("unable to get configuration for existing cluster: %w", err)
223229
}
230+
te.KubeConfig, err = controlplane.KubeConfigFromREST(te.Config)
231+
if err != nil {
232+
return nil, fmt.Errorf("unable to convert configuration to kubeconfig: %w", err)
233+
}
224234
}
225235
} else {
226236
apiServer := te.ControlPlane.GetAPIServer()

0 commit comments

Comments
 (0)