core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	PermissionMetadata *TemplateMetadata
	RoleMetadata       *TemplateMetadata
	Roles              []Role
	Permissions        []Permission
	ConfigFilename     string
	BaseDirectory      string
}

Generator takes a set of options and creates the roles and permissions for RBAC usage. They all have defaults, but everything can be overridden with an OptionFunc.

type OptionFunc

type OptionFunc func(context.Context, *Generator) error

type Permission

type Permission struct {
	rbac.Permission

	// we also add additional fields specific to generation, for ease of use.
	GoTags string
	GoName string
}

type Role

type Role struct {
	rbac.Role
	Permissions []Permission

	// we also add additional fields specific to generation, for ease of use.
	GoTags string
	GoName string
}

type TemplateMetadata

type TemplateMetadata struct {
	// Package name to use.
	// Default: role or permission, singular.
	Package string `json:"package" yaml:"package"`

	// Filename is the filename to generate.
	// Default: (package)_gen.go
	Filename string `json:"filename" yaml:"filename"`

	// Path is the folder in which a file should be generated.
	// Default: ./rbac/(package)
	Path string `json:"path" yaml:"path"`

	// ImportPath is the path used to import this package from another, e.g. github.com/example.
	ImportPath string `json:"-" yaml:"-"`

	// Template is a custom go text/template to use for generation.
	Template string `json:"template" yaml:"template"`

	// Tags indicated which struct tags, if any, to add to generated structs.
	// Currently handled: json, yaml, db.
	// To add anything extra, override Template.
	Tags []string `json:"tags" yaml:"tags"`
}

TemplateMetadata is used to generate a file from a template.

Jump to

Keyboard shortcuts

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