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
- func Result(c *Client, manifestWriter io.Writer, errorWriter io.Writer) error
- func WriteResult(role interface{}, writer io.Writer) error
- type Client
- func (c *Client) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c *Client) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (c *Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (c *Client) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
- func (c *Client) List(ctx context.Context, obj client.ObjectList, opts ...client.ListOption) error
- func (c *Client) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (c *Client) RESTMapper() meta.RESTMapper
- func (c *Client) Scheme() *runtime.Scheme
- func (c *Client) Status() client.StatusWriter
- func (c *Client) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type ClientOption
- type StatusWriter
Constants ¶
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 ¶
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 ¶
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) DeleteAllOf ¶
func (c *Client) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf 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) Status ¶
func (c *Client) Status() client.StatusWriter
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.