...
1
16
17 package dynamic
18
19 import (
20 "context"
21
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
24 "k8s.io/apimachinery/pkg/runtime/schema"
25 "k8s.io/apimachinery/pkg/types"
26 "k8s.io/apimachinery/pkg/watch"
27 )
28
29 type Interface interface {
30 Resource(resource schema.GroupVersionResource) NamespaceableResourceInterface
31 }
32
33 type ResourceInterface interface {
34 Create(ctx context.Context, obj *unstructured.Unstructured, options metav1.CreateOptions, subresources ...string) (*unstructured.Unstructured, error)
35 Update(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error)
36 UpdateStatus(ctx context.Context, obj *unstructured.Unstructured, options metav1.UpdateOptions) (*unstructured.Unstructured, error)
37 Delete(ctx context.Context, name string, options metav1.DeleteOptions, subresources ...string) error
38 DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error
39 Get(ctx context.Context, name string, options metav1.GetOptions, subresources ...string) (*unstructured.Unstructured, error)
40 List(ctx context.Context, opts metav1.ListOptions) (*unstructured.UnstructuredList, error)
41 Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
42 Patch(ctx context.Context, name string, pt types.PatchType, data []byte, options metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error)
43 Apply(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions, subresources ...string) (*unstructured.Unstructured, error)
44 ApplyStatus(ctx context.Context, name string, obj *unstructured.Unstructured, options metav1.ApplyOptions) (*unstructured.Unstructured, error)
45 }
46
47 type NamespaceableResourceInterface interface {
48 Namespace(string) ResourceInterface
49 ResourceInterface
50 }
51
52
53
54 type APIPathResolverFunc func(kind schema.GroupVersionKind) string
55
56
57
58 func LegacyAPIPathResolverFunc(kind schema.GroupVersionKind) string {
59 if len(kind.Group) == 0 {
60 return "/api"
61 }
62 return "/apis"
63 }
64
View as plain text