#Hide an API from SDKs

1 messages · Page 1 of 1 (latest)

silent basin
#

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.

dreamy crown
#

the idea is that user should be allowed to call cacheVolume only. The cacheVolume api internally calls cache api with a namespaced key.

silent basin
#

But that can be an internal function, without being exposed to the API, right?

dreamy crown
#

My understanding is that I have to go through select to be able to return dagql.Instance[*core.CacheVolume] instead of *core.CacheVolume.

silent basin
#

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?

dreamy crown
#

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.

silent basin
#

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.

dreamy crown
#

apologies, my terminology in dagql is still not up to the mark.

silent basin
#

Ok, let me catch up for a moment.

silent basin
#

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.

dreamy crown
#

thank you for the pointers. I will check this out.