Hi Michael,

Michael Albinus <[email protected]> writes:

> Eshel Yaron <[email protected]> writes:
>
>>> 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))
>
> OK. Appended is a patch which ought to implement this functionality. The
> function is called with the current connection vec, i.e. in your example
>
> (my-kubectl-function '(tramp-file-name "kubedv2" nil nil "kubed-hostname" nil 
> "/some/file" "ssh:[email protected]|"))
>
> Everything untested. Does it make sense to you?

Thanks!  It makes sense and I think we could make it work.
My only concern is this: IIUC, tramp-connection-properties is meant for
users to override tramp-methods parameters that were defined by the
method author, but here we'd be (ab)using tramp-connection-properties
as part of the method definition.  (The mismatch is also apparent in the
fact that we use a regexp that only looks at the method name.)  In that
sense, ISTM that a similar generalization of tramp-methods would be a
little nicer.  But again, in practice, I think it could get the job done.
WDYT?


Eshel

Reply via email to