rbac

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorProcessRoleRule      = errors.New("error processing role rule")
	ErrorProcessRoleRuleField = errors.New("error processing role rule field")
)
View Source
var ErrInvalidVerb = errors.New("verb is invalid")

Functions

func DefaultResourceVerbs

func DefaultResourceVerbs() []string

DefaultResourceVerbs is a helper function to define the default verbs that are allowed for resources that are managed by the scaffolded controller.

func GenerateCode

func GenerateCode(files *manifests.Manifests, options *options.RBACOptions) (string, error)

GenerateCode will return the stdout form of rbac objects, given a set of input manifest, in go struct format.

func GenerateMarkers

func GenerateMarkers(files *manifests.Manifests, options *options.RBACOptions) (string, error)

GenerateMarkers will return the stdout form of rbac objects as kubebuilder markers.

func GenerateYAML

func GenerateYAML(files *manifests.Manifests, options *options.RBACOptions) (string, error)

GenerateYAML will return the stdout form of rbac objects, given a set of input manifest, in YAML format.

func ValidResourceVerbs added in v0.3.0

func ValidResourceVerbs() []string

ValidResourceVerbs is a helper function to define any valid resource verbs. These may differ from the default verbs so we simply append any additional potential verbs that may be used.

Types

type RoleRule

type RoleRule struct {
	Groups       RoleRuleField
	Resources    RoleRuleField
	ResourceName RoleRuleField
	Verbs        RoleRuleField
	URLs         RoleRuleField
}

RoleRule contains the info needed to create the kubebuilder:rbac markers in the controller when a resource that is of a role or clusterrole type is found. This is because the underlying controller needs the same permissions for the role or clusterrole that it is attempting to manage.

type RoleRuleField

type RoleRuleField []string

type Rule

type Rule struct {
	Group        string
	Resource     string
	ResourceName string
	URLs         []string
	Verbs        []string
}

Rule contains the info needed to create the kubebuilder:rbac markers in the controller.

func (*Rule) ToMarker

func (rule *Rule) ToMarker() string

ToMarker will return a specific marker in string format.

type Rules

type Rules []Rule

func ForResource

func ForResource(manifest *unstructured.Unstructured, verbs ...string) (*Rules, error)

ForResource will return a set of rules for a particular kubernetes resource. This includes a rule for the resource itself, in addition to adding particular rules for whatever roles and cluster roles are requesting. This is because the controller needs to have permissions to manage the children that roles and cluster roles are requesting.

func ForResources

func ForResources(manifests []*unstructured.Unstructured, verbs ...string) (*Rules, error)

ForResources will return a set of rules for particular kubernetes resources. See ForResource for more information as this is the same methodology used.

func ForWorkloads

func ForWorkloads(workloads ...rbacWorkloadProcessor) *Rules

ForWorkloads will return a set of rules for a particular set of workloads. It should be noted that this only returns the specific rules for the actual workload and not the managed resources. See ForManifest for details on the rules for a particular manifest.

func (*Rules) Add

func (rules *Rules) Add(newRules ...rbacRuleProcessor)

add will add a set of new rules to an existing set of rules.

type Verbs

type Verbs []string

func (*Verbs) Validate

func (verbs *Verbs) Validate() error

Validate validates that the verbs are valid.

Jump to

Keyboard shortcuts

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