...

Source file src/k8s.io/client-go/dynamic/interface.go

Documentation: k8s.io/client-go/dynamic

     1  /*
     2  Copyright 2016 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    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  // APIPathResolverFunc knows how to convert a groupVersion to its API path. The Kind field is optional.
    53  // TODO find a better place to move this for existing callers
    54  type APIPathResolverFunc func(kind schema.GroupVersionKind) string
    55  
    56  // LegacyAPIPathResolverFunc can resolve paths properly with the legacy API.
    57  // TODO find a better place to move this for existing callers
    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