Content-Length: 344264 | pFad | https://github.com/tilt-dev/tilt-apiserver/pull/76

6C Enable generic sub-resources by karolz-ms · Pull Request #76 · tilt-dev/tilt-apiserver · GitHub
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

Enable generic sub-resources #76

Merged
merged 2 commits into from
Feb 21, 2024

Conversation

karolz-ms
Copy link
Contributor

This change enables defining a resource type that has arbitrary ("generic") sub-resource. I used it to prototype a "log" sub-resource for a couple of kinds used by .NET Aspire orchestrator a.k.a. DCP (which is built on top of Tilt API server). The way they work via a custom storage implementation that exposes a stream of data.

@nicks and I talked briefly about this kind of enhancement to Tilt API server last year, but not since, so I understand this might come as a bit of a surprise. I am open to any suggestions for how to improve this PR, or enable the scenario differently.

Signed-off-by: Karol Zadora-Przylecki <karolz@microsoft.com>
@@ -101,7 +102,7 @@ func (c completedConfig) New() (*TiltServer, error) {
}

// Add new APIs through inserting into APIs
apiGroups, err := buildAPIGroupInfos(c.ExtraConfig.Scheme, c.ExtraConfig.Codecs, c.ExtraConfig.APIs, c.GenericConfig.RESTOptionsGetter)
apiGroups, err := buildAPIGroupInfos(c.ExtraConfig.Scheme, c.ExtraConfig.Codecs, c.ExtraConfig.APIs, c.GenericConfig.RESTOptionsGetter, c.ExtraConfig.ParameterCodec)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom ParameterCodec allows to define kind- and sub-resource-specific parameters for REST requests.

Name() string
// TODO: fill the details for this interface.
GetStorageProvider(parentObj Object, rootPath string, fs filesystem.FS, parentWatchSet *filesystem.WatchSet, parentSP apiserver.StorageProvider) apiserver.StorageProvider
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow for custom storage implementation via GetStorageProvider method, I moved and made public a few types from the filepath package to filesystem package.

I initially started with an implementation that was using the FS and WatchSet types, but ended up relying on parent storage pretty much exclusively, so I am happy to revert that part if necessary. I decided to leave it in this PR because I thought other sub-resource types might need access to these interfaces more than mine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm....how is your implementation using fs and parentWatchSet?

The Kubernetes apiserver APIs for resources are usually more high-level than this, and don't usually require specific details about how the underlying objects are stored... but maybe i'm missing something here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. When I looked at the PR just after I submitted it, I thought it probably makes more sense to solely rely on the parent storage. Let me rework this PR and verify that my subresources still work, but I think they will. This will also eliminate the need to change the filepath/filesystem types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The change is much simpler/smaller now and still allows me to do everything I need for DCP.

pkg/storage/filesystem/version.go Outdated Show resolved Hide resolved
pkg/storage/filepath/jsonfile.go Show resolved Hide resolved
Name() string
// TODO: fill the details for this interface.
GetStorageProvider(parentObj Object, rootPath string, fs filesystem.FS, parentWatchSet *filesystem.WatchSet, parentSP apiserver.StorageProvider) apiserver.StorageProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmmm....how is your implementation using fs and parentWatchSet?

The Kubernetes apiserver APIs for resources are usually more high-level than this, and don't usually require specific details about how the underlying objects are stored... but maybe i'm missing something here...

Signed-off-by: Karol Zadora-Przylecki <karolz@microsoft.com>
@karolz-ms
Copy link
Contributor Author

@nicks I was able to simplify the proposed change quite a bit by not passing FS/WatchSet to subresource storage factory method. Please take another look--much appreciated!

@nicks nicks merged commit 2d8295c into tilt-dev:main Feb 21, 2024
1 check passed
@karolz-ms
Copy link
Contributor Author

Thank you! 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/tilt-dev/tilt-apiserver/pull/76

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy