Documentation ¶
Index ¶
- func NewFakeClient(is ...apiv1.Interface) (*fakeClientBase, error)
- type BadRequestError
- type Base
- type BaseCtx
- type Client
- func (c *Client) Create(ri *apiv1.ResourceInstance, opts ...CreateOption) (*apiv1.ResourceInstance, error)
- func (c *Client) CreateCtx(ctx context.Context, ri *apiv1.ResourceInstance, opts ...CreateOption) (*apiv1.ResourceInstance, error)
- func (c *Client) Delete(ri *apiv1.ResourceInstance) error
- func (c *Client) DeleteCtx(ctx context.Context, ri *apiv1.ResourceInstance) error
- func (c *Client) Get(name string) (*apiv1.ResourceInstance, error)
- func (c *Client) GetCtx(ctx context.Context, name string) (*apiv1.ResourceInstance, error)
- func (c *Client) GetCtx2(ctx context.Context, toGet *apiv1.ResourceInstance) (*apiv1.ResourceInstance, error)
- func (c *Client) List(options ...ListOptions) ([]*apiv1.ResourceInstance, error)
- func (c *Client) ListCtx(ctx context.Context, options ...ListOptions) ([]*apiv1.ResourceInstance, error)
- func (c *Client) Update(ri *apiv1.ResourceInstance, opts ...UpdateOption) (*apiv1.ResourceInstance, error)
- func (c *Client) UpdateCtx(ctx context.Context, ri *apiv1.ResourceInstance, opts ...UpdateOption) (*apiv1.ResourceInstance, error)
- func (c *Client) WithScope(scope string) Scoped
- type ClientBase
- type ClientCtx
- type ConflictError
- type CreateOption
- type Errors
- type EventHandler
- type EventHandlerFunc
- type FakeVisitor
- type ForbiddenError
- type InternalServerError
- type ListOptions
- type Logger
- type MergeFunc
- type NotFoundError
- type Options
- type QueryNode
- func AllAttr(attrs map[string]string) QueryNode
- func AllTags(values ...string) QueryNode
- func And(first, second QueryNode, rest ...QueryNode) QueryNode
- func AnyAttr(attrs map[string]string) QueryNode
- func AttrIn(key string, values ...string) QueryNode
- func Names(names ...string) QueryNode
- func Or(first, second QueryNode, rest ...QueryNode) QueryNode
- func Reference(gvk apiv1.GroupVersionKind, name string) QueryNode
- func TagsIn(values ...string) QueryNode
- type QueryStringer
- type Scoped
- type ScopedCtx
- type UnauthorizedError
- type UnexpectedError
- type Unscoped
- type UnscopedCtx
- type UpdateOption
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFakeClient ¶
NewFakeClient -
Types ¶
type BaseCtx ¶
type BaseCtx interface {
ForKindCtx(apiv1.GroupVersionKind) (UnscopedCtx, error)
}
BaseCtx -
type Client ¶
type Client struct { *ClientBase // contains filtered or unexported fields }
Client for a resource with the given version, group & scope
func (*Client) Create ¶
func (c *Client) Create(ri *apiv1.ResourceInstance, opts ...CreateOption) (*apiv1.ResourceInstance, error)
Create creates a single resource
func (*Client) CreateCtx ¶
func (c *Client) CreateCtx(ctx context.Context, ri *apiv1.ResourceInstance, opts ...CreateOption) (*apiv1.ResourceInstance, error)
CreateCtx creates a single resource
func (*Client) GetCtx ¶
GetCtx returns a single resource. If client is unscoped then name can be "<scopeName>/<name>". If client is scoped then name can be "<name>" or "<scopeName>/<name>" but <scopeName> is ignored.
func (*Client) GetCtx2 ¶
func (c *Client) GetCtx2(ctx context.Context, toGet *apiv1.ResourceInstance) (*apiv1.ResourceInstance, error)
GetCtx2 returns a single resource.
func (*Client) List ¶
func (c *Client) List(options ...ListOptions) ([]*apiv1.ResourceInstance, error)
List -
func (*Client) ListCtx ¶
func (c *Client) ListCtx(ctx context.Context, options ...ListOptions) ([]*apiv1.ResourceInstance, error)
ListCtx returns a list of resources
func (*Client) Update ¶
func (c *Client) Update(ri *apiv1.ResourceInstance, opts ...UpdateOption) (*apiv1.ResourceInstance, error)
Update updates a single resource. If the merge option is passed it will first fetch the resource and then apply the merge function.
func (*Client) UpdateCtx ¶
func (c *Client) UpdateCtx(ctx context.Context, ri *apiv1.ResourceInstance, opts ...UpdateOption) (*apiv1.ResourceInstance, error)
UpdateCtx updates a single resource
type ClientBase ¶
type ClientBase struct {
// contains filtered or unexported fields
}
ClientBase for grouping a client, auth method and url together
func NewClient ¶
func NewClient(baseURL string, options ...Options) *ClientBase
NewClient creates a new HTTP client
func (*ClientBase) ForKind ¶
func (cb *ClientBase) ForKind(gvk apiv1.GroupVersionKind) (Unscoped, error)
ForKind registers a client with a given group/version
func (*ClientBase) ForKindCtx ¶
func (cb *ClientBase) ForKindCtx(gvk apiv1.GroupVersionKind) (UnscopedCtx, error)
ForKindCtx registers a client with a given group/version
type CreateOption ¶
type CreateOption func(*createOptions)
func CUserID ¶
func CUserID(userID string) CreateOption
type EventHandlerFunc ¶
EventHandlerFunc -
type FakeVisitor ¶
type FakeVisitor struct {
// contains filtered or unexported fields
}
type ListOptions ¶
type ListOptions func(*listOptions)
ListOptions -
func WithQuery ¶
func WithQuery(n QueryNode) ListOptions
WithQuery applies a query on the list operation
type Options ¶
type Options func(*ClientBase)
Options
func HTTPClient ¶
func HTTPClient(client requestDoer) Options
HTTPClient allows you to replace the default client for different use cases
func JWTAuth ¶
func JWTAuth(tenantID, privKey, pubKey, password, url, aud, clientID string, timeout time.Duration) Options
JWTAuth auth with token
func WithLogger ¶
type QueryNode ¶
type QueryNode interface {
Accept(Visitor)
}
QueryNode represents a query
type QueryStringer ¶
type QueryStringer struct {
QueryNode
}
QueryStringer helps print a query
func (QueryStringer) String ¶
func (qs QueryStringer) String() string
type Scoped ¶
type Scoped interface { Create(*apiv1.ResourceInstance, ...CreateOption) (*apiv1.ResourceInstance, error) Delete(*apiv1.ResourceInstance) error Get(string) (*apiv1.ResourceInstance, error) List(...ListOptions) ([]*apiv1.ResourceInstance, error) Update(*apiv1.ResourceInstance, ...UpdateOption) (*apiv1.ResourceInstance, error) }
type ScopedCtx ¶
type ScopedCtx interface { CreateCtx(context.Context, *apiv1.ResourceInstance, ...CreateOption) (*apiv1.ResourceInstance, error) DeleteCtx(context.Context, *apiv1.ResourceInstance) error GetCtx(context.Context, string) (*apiv1.ResourceInstance, error) ListCtx(context.Context, ...ListOptions) ([]*apiv1.ResourceInstance, error) UpdateCtx(context.Context, *apiv1.ResourceInstance, ...UpdateOption) (*apiv1.ResourceInstance, error) }
ScopedCtx -
type UnexpectedError ¶
type UnexpectedError struct { Errors // contains filtered or unexported fields }
UnexpectedError -
type UnscopedCtx ¶
UnscopedCtx -
type UpdateOption ¶
type UpdateOption func(*updateOptions)
func Merge ¶
func Merge(merge MergeFunc) UpdateOption
Merge option first fetches the resource and then applies the merge function and uses the result for the actual update fetched will be the old resource new will be the resource passed to the Update call If the resource doesn't exist it will fetched will be set to null If the merge function returns an error, the update operation will be cancelled
func UUserID ¶
func UUserID(userID string) UpdateOption