Comments (6)
That's pretty good. I'd combine those string arguments to a struct, but that's just me:
RegisterThirdPartyResource(ThirdPartyResourceType, interface{})
and
type ThirdPartyResourceType struct {
ApiGroup string
ApiVersion string
Plural string
}
from k8s.
I think register isn't going to work. Mostly because things like Delete
doesn't take a struct argument so there's nothing to reflect and map.
Current working on something like:
func (t *ThirdPartyResources) Create(ctx context.Context, apiGroup, apiVersion, resource string, req, resp interface{}) error {
url := t.c.urlFor(apiGroup, apiVersion, t.c.namespaceFor(ctx, true), resource, "")
return t.c.create(ctx, jsonCodec, url, req, resp)
}
func (t *ThirdPartyResources) Get(ctx context.Context, apiGroup, apiVersion, resource, name string, resp interface{}) error {
url := t.c.urlFor(apiGroup, apiVersion, t.c.namespaceFor(ctx, true), resource, name)
return t.c.get(ctx, jsonCodec, url, resp)
}
func (t *ThirdPartyResources) Delete(ctx context.Context, apiGroup, apiVersion, resource, name string) error {
url := t.c.urlFor(apiGroup, apiVersion, t.c.namespaceFor(ctx, true), resource, name)
return t.c.delete(ctx, jsonCodec, url)
}
func (t *ThirdPartyResources) List(ctx context.Context, apiGroup, apiVersion, resource string, resp interface{}) error {
url := t.c.urlFor(apiGroup, apiVersion, t.c.namespaceFor(ctx, true), resource, "")
return t.c.get(ctx, jsonCodec, url, resp)
}
You then define request and response objects in wrapper methods that give your own code type checking.
from k8s.
Initial implementation https://godoc.org/github.com/ericchiang/k8s#Client.ThirdPartyResources
from k8s.
@ericchiang Very nice, can you add a line of example GoDoc for what apiGroup, apiVersion & resource mean (even if I can guess)?
from k8s.
π yeah
from k8s.
docs add here: https://godoc.org/github.com/ericchiang/k8s#ThirdPartyResources
from k8s.
Related Issues (20)
- New release with Delete-Options HOT 2
- A way to load resources directly from file yaml manifest HOT 6
- How to watch the status of nodes in a cluster? HOT 1
- Is it Possible to Connect with ServiceAccount instead of KubeConfig HOT 1
- Access Service Endpoints HOT 1
- Why type ObjectMeta is different? HOT 1
- Set βnameβ path parameter for endpoint watch HOT 3
- Is it possible to do pod eviction? HOT 6
- Support client-go credential plugins HOT 1
- Watcher for CRD timeout in 90sec with EOF HOT 3
- Creating Event by api/v1beta HOT 2
- Failure 406 only the following media types are accepted: application/json, application/yaml HOT 2
- Document or fix io.EOF from watch API HOT 1
- Server Side Apply HOT 12
- Update protobuf dependency HOT 1
- Add support for k8s jobs HOT 1
- Update Release
- Add support for DeletionPropagation HOT 2
- Watcher on Service resource not catching annotation updates HOT 2
- Run controller manager in integration test setup
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k8s.