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

Machine ID: Render kubernetes template without exec plugin when using non-directory destination #43401

Merged
16 changes: 8 additions & 8 deletions lib/tbot/config/template_kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ func (t *templateKubernetes) render(
kubernetesClusterName: t.clusterName,
}

destinationDir, isDirectoryDest := destination.(*DestinationDirectory)
if !t.disableExecPlugin {
if !isDirectoryDest {
log.WarnContext(ctx, "Kubernetes template will be rendered without exec plugin because destination is not a directory. Explicitly set `disable_exec_plugin: true` in the output to suppress this message")
strideynet marked this conversation as resolved.
Show resolved Hide resolved
t.disableExecPlugin = true
}
}

var cfg *clientcmdapi.Config
if t.disableExecPlugin {
// If they've disabled the exec plugin, we just write the credentials
Expand All @@ -216,14 +224,6 @@ func (t *templateKubernetes) render(
// We only support directory mode for this since the exec plugin needs
// to know the path to read the credentials from, and this is
// unpredictable with other types of destination.
strideynet marked this conversation as resolved.
Show resolved Hide resolved
destinationDir, ok := destination.(*DestinationDirectory)
if !ok {
return trace.BadParameter(
"Destination %s must be a directory in exec plugin mode",
destination,
)
}

executablePath, err := t.executablePathGetter()
if err != nil {
return trace.Wrap(err)
Expand Down
Loading