client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package client provides an implementation of the controller-runtime's generic client with RBAC recording action recording. It wraps an actual client, records the API call object and verb, and forwards the call to the actual embedded client. The package also provides tooling to convert the recorded RBAC metadata into RBAC Role

Index

Constants

View Source
const (
	APIVersion      = "rbac.authorization.k8s.io/v1"
	RoleKind        = "Role"
	ClusterRoleKind = "ClusterRole"

	DefaultRoleName        = "generated-rbac-role"
	DefaultClusterRoleName = "generated-rbac-cluster-role"

	VerbGet    = "get"
	VerbList   = "list"
	VerbCreate = "create"
	VerbDelete = "delete"
	VerbUpdate = "update"
	VerbPatch  = "patch"
)

Variables

This section is empty.

Functions

func Result

func Result(c *Client, manifestWriter io.Writer, errorWriter io.Writer) error

Result marshals and writes the observed RBAC rules into a given Writer. It also writes any observed error into a given error writer.

func WriteResult

func WriteResult(role interface{}, writer io.Writer) error

WriteResult writes a given result into a given writer.

Types

type Client

type Client struct {
	client.Client
	Role        *rbacv1.Role
	ClusterRole *rbacv1.ClusterRole
	Log         logr.Logger
	// contains filtered or unexported fields
}

Client embeds a controller-runtime generic Client. It implements the Client interface to be able to observe and register the API calls, and pass the call to the actual Client. The observed API calls are used to create a list of RBAC permissions that were used.

func NewClient

func NewClient(c client.Client, opts ...ClientOption) *Client

NewClient returns a new RBAC Client from a given Client.

func (*Client) Create

func (c *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

Create implements client.Client.

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

Delete implements client.Client

func (*Client) DeleteAllOf

func (c *Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

DeleteAllOf implements client.Client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error

Get implements client.Client.

func (*Client) List

func (c *Client) List(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) error

List implements client.Client.

func (*Client) Patch

func (c *Client) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

Patch implements client.Client.

func (*Client) RESTMapper

func (c *Client) RESTMapper() meta.RESTMapper

RESTMapper returns the scheme this client is using.

func (*Client) Scheme

func (c *Client) Scheme() *runtime.Scheme

Scheme returns the scheme this client is using.

func (*Client) Status

func (c *Client) Status() client.StatusWriter

func (*Client) Update

func (c *Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

Update implements client.Client.

type ClientOption

type ClientOption func(*Client)

ClientOption is used to configure Client.

func WithClusterRoleName

func WithClusterRoleName(name string) ClientOption

WithClusterRoleName sets the generated cluster role name.

func WithLogger

func WithLogger(log logr.Logger) ClientOption

WithLogger sets the Logger in Client.

func WithRoleName

func WithRoleName(name string) ClientOption

WithRoleName sets the generated role name.

type StatusWriter

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

StatusWriter implements the StatusWriter interface. Similar to Client, it embeds a Client, observes API calls and passes the APIi call to the actual client.

func (*StatusWriter) Patch

func (sc *StatusWriter) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

Patch implements client.StatusWriter.

func (*StatusWriter) Update

func (sc *StatusWriter) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

Update implements client.StatusWriter.

Jump to

Keyboard shortcuts

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