v1

package
v1.1.97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFakeClient

func NewFakeClient(is ...apiv1.Interface) (*fakeClientBase, error)

NewFakeClient -

Types

type BadRequestError

type BadRequestError struct {
	Errors
}

BadRequestError -

func (BadRequestError) Error

func (nf BadRequestError) Error() string

Error -

type Base

type Base interface {
	ForKind(apiv1.GroupVersionKind) (Unscoped, error)
}

Base -

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

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) Delete

func (c *Client) Delete(ri *apiv1.ResourceInstance) error

func (*Client) DeleteCtx

func (c *Client) DeleteCtx(ctx context.Context, ri *apiv1.ResourceInstance) error

DeleteCtx deletes a single resource

func (*Client) Get

func (c *Client) Get(name string) (*apiv1.ResourceInstance, error)

func (*Client) GetCtx

func (c *Client) GetCtx(ctx context.Context, name string) (*apiv1.ResourceInstance, error)

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

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

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

func (*Client) WithScope

func (c *Client) WithScope(scope string) Scoped

WithScope creates a request within the given scope. ex: env/$name/services

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 ClientCtx

type ClientCtx struct {
	Client
}

func (*ClientCtx) WithScope

func (c *ClientCtx) WithScope(scope string) ScopedCtx

type ConflictError

type ConflictError struct {
	Errors
}

ConflictError -

func (ConflictError) Error

func (nf ConflictError) Error() string

Error -

type CreateOption

type CreateOption func(*createOptions)

func CUserID

func CUserID(userID string) CreateOption

type Errors

type Errors []apiv1.Error

Errors -

func (Errors) Error

func (e Errors) Error() string

Error -

type EventHandler

type EventHandler interface {
	Handle(*apiv1.Event)
}

EventHandler -

type EventHandlerFunc

type EventHandlerFunc func(*apiv1.Event)

EventHandlerFunc -

func (EventHandlerFunc) Handle

func (ehf EventHandlerFunc) Handle(ev *apiv1.Event)

Handle -

type FakeVisitor

type FakeVisitor struct {
	// contains filtered or unexported fields
}

func (FakeVisitor) Intersection

func (s FakeVisitor) Intersection(other set) set

Intersection -

func (FakeVisitor) Union

func (s FakeVisitor) Union(other set) set

Union -

func (*FakeVisitor) Visit

func (fv *FakeVisitor) Visit(node QueryNode)

Visit -

type ForbiddenError

type ForbiddenError struct {
	Errors
}

ForbiddenError -

func (ForbiddenError) Error

func (nf ForbiddenError) Error() string

Error -

type InternalServerError

type InternalServerError struct {
	Errors
}

InternalServerError -

func (InternalServerError) Error

func (nf InternalServerError) Error() string

Error -

type ListOptions

type ListOptions func(*listOptions)

ListOptions -

func WithQuery

func WithQuery(n QueryNode) ListOptions

WithQuery applies a query on the list operation

type Logger

type Logger interface {
	Log(kv ...interface{}) error
}

type MergeFunc

type MergeFunc func(fetched apiv1.Interface, new apiv1.Interface) (apiv1.Interface, error)

type NotFoundError

type NotFoundError struct {
	Errors
}

NotFoundError -

func (NotFoundError) Error

func (nf NotFoundError) Error() string

Error -

type Options

type Options func(*ClientBase)

Options

func BasicAuth

func BasicAuth(user, password, tenantID, instanceID string) Options

BasicAuth auth with user/pass

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 UserAgent

func UserAgent(ua string) Options

func WithLogger

func WithLogger(log Logger) Options

type QueryNode

type QueryNode interface {
	Accept(Visitor)
}

QueryNode represents a query

func AllAttr

func AllAttr(attrs map[string]string) QueryNode

AllAttr creates a query that matches resources with all of the attributes

func AllTags

func AllTags(values ...string) QueryNode

func And

func And(first, second QueryNode, rest ...QueryNode) QueryNode

And creates a query that ands two or more subqueries

func AnyAttr

func AnyAttr(attrs map[string]string) QueryNode

AnyAttr creates a query that matches resources with any of the attributes

func AttrIn

func AttrIn(key string, values ...string) QueryNode

AttrIn creates a query that matches resources with attribute key and any of values

func Names

func Names(names ...string) QueryNode

Names creates a query that matches any of the passed names

func Or

func Or(first, second QueryNode, rest ...QueryNode) QueryNode

Or creates a query that ors two or more subqueries

func Reference

func Reference(gvk apiv1.GroupVersionKind, name string) QueryNode

Reference create a query by reference to resource kind and name

func TagsIn

func TagsIn(values ...string) QueryNode

TagsIn creates a query that matches resources with any of the tag values

type QueryStringer

type QueryStringer struct {
	QueryNode
}

QueryStringer helps print a query

func (QueryStringer) String

func (qs QueryStringer) String() string

type UnauthorizedError

type UnauthorizedError struct {
	Errors
}

UnauthorizedError -

func (UnauthorizedError) Error

func (nf UnauthorizedError) Error() string

Error -

type UnexpectedError

type UnexpectedError struct {
	Errors
	// contains filtered or unexported fields
}

UnexpectedError -

func (UnexpectedError) Error

func (nf UnexpectedError) Error() string

Error -

type Unscoped

type Unscoped interface {
	Scoped
	WithScope(name string) Scoped
}

Unscoped -

type UnscopedCtx

type UnscopedCtx interface {
	ScopedCtx
	WithScope(name string) ScopedCtx
}

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

type Visitor

type Visitor interface {
	Visit(QueryNode)
}

Visitor visits a QueryNode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL