#Hide an API from SDKs
1 messages · Page 1 of 1 (latest)
Yeah, there's more in that situation, I think Query.secret for example. You're saying you want to hide from the SDKs, but not if using the API directly?
You can have internal methods that don't go through the API, that's why I'm asking why it needs to be exposed in the API.
the idea is that user should be allowed to call cacheVolume only. The cacheVolume api internally calls cache api with a namespaced key.
But that can be an internal function, without being exposed to the API, right?
My understanding is that I have to go through select to be able to return dagql.Instance[*core.CacheVolume] instead of *core.CacheVolume.
I'm not too familiar with dagql, but it doesn't make sense to me to have to expose something in the API just to fit a type. If that's the case we should fix a way to get the type that you need without exposing to the public. Isn't there a way to get it already? Have someone guided you on this?
in one of the past tickets someone mentioned that if I have to return the dagql.Instance, then I've to go through a select operation.
There's a bit to unpack here. If you need dagql.Instance[*core.CacheVolume] then that's Query.cacheVolume, right? It's already exposed and available.
apologies, my terminology in dagql is still not up to the mark.
here is a msg from Erik when he was helping me with this if it helps give some additional context to you: #1292894931089621047 message
Ok, let me catch up for a moment.
Ok, here's the thing. I've asked in that thread if we can do this without exposing something internal on the API. I think that should be the first option. If not, for hiding in the SDKs, yes there's a way to do that, but there's two parts to that.
For modules, it's in here: https://github.com/dagger/dagger/blob/1c86fe421551fc1d197c3b564d506bb08e9340a6/core/moddeps.go#L22-L33. However, it would still be available when using Dagger without modules (i.e., using the published client library packages).
For APIs that aren't meant to run outside of modules I think we just validate that within the call, like this one: https://github.com/dagger/dagger/blob/14e9ffd425c90d6e24b7ee8c822bc9f0ff0da573/engine/server/session.go#L1168-L1170.
You need to make sure that cache volumes are still usable outside of modules, where there's no modsource and no need to namespace.
thank you for the pointers. I will check this out.