Hi Michael,

Michael Albinus <[email protected]> writes:

> Eshel Yaron <[email protected]> writes:
>
>> Hmm, but this does not specify the first host, and that  is the what
>> actually determines the login-program in our case, not the kube-hostname
>> that we're connecting to.
>> We want "/ssh:[email protected]|kubedv2:kubed-hostname:/some/file" to use
>> a different kubectl (on example.com) than the one we use (locally) for
>> "/kubedv2:kube-hostname:/some/file" or via another first hop, and we
>> want Tramp to use that different kubectl for all kubedv2 connection that
>> follow a "/ssh:[email protected]" hop, not just to a specific kube-hostname.
>> Hope that makes it clearer.
>
> I see. What about extending tramp-connection-properties to use also a
> function as property value? Something like
>
> (add-to-list 'tramp-connection-properties
>              (list "^/kubedv2:kube-hostname:" "login-program" 
> #'my-kubectl-function))
>
> The regexp is always applied to the hop name, that is it is applied in
> both "/ssh:[email protected]|kubedv2:kubed-hostname:/some/file" and
> "/kubedv2:kube-hostname:/some/file" cases. my-kubectl-function could
> return a proper string based on some calculations over default-directory
> or whatever, don't know.

Yeah, I think something like that could work.  The important thing is
that my-kubectl-function needs access to the "previous" hop, the one on
which we will be executing the login-program.  Also, since we're
choosing login-program based on the previous hop, not based on which
kube-hostname we connect to, we'll probably use this without specifying
any kube-hostname, so something like this:

  (add-to-list 'tramp-connection-properties
               (list "^/kubedv2:" "login-program" #'my-kubectl-function))


Best,

Eshel

Reply via email to