provision: github.com/digitalrebar/provision/backend Index | Files | Directories

package backend

import "github.com/digitalrebar/provision/backend"

backend contains the backend code for DigitalRebar Provision. It has the responsibility for saving and loading all the data we need to the backing store, making sure that said models are valid and remain consistent, making sure that all the links between objects remain consistent, and providing any optimizations needed to make things perform at scale.

Index

Package Files

bootenv.go conncache.go conncache_linux.go dataTracker.go dhcpUtils.go doc.go errors.go event.go fs.go interface_resolver.go interfaces.go jobs.go jwt-utils.go lease.go license.go machines.go param.go plugins.go preference.go profiles.go renderData.go requestTracker.go reservation.go roles.go stage.go subnet.go task.go template.go tenants.go user.go workflow.go

Constants

const (
    ValidationError     = "ValidationError"
    TemplateRenderError = "TemplateRenderError"
    StillInUseError     = "StillInUseError"
)

func AddToCache Uses

func AddToCache(l logger.Logger, la, ra net.IP)

AddToCache adds a new remote -> local IP address mapping to the connection cache. If the remote address is already in the cache, its corresponding local address is updates and the timeout is bumped. Mappings that have not been accessed with LocalFor or updated with AddToCache will be evicted if not used for more than 10 minutes.

func BasicContent Uses

func BasicContent() store.Store

func DefaultIP Uses

func DefaultIP(l logger.Logger) net.IP

DefaultIP figures out the IP address of the interface that has the default route. It is used as a fallback IP address when we don't have --static-ip set and we cannot find a local -> remote mapping in the cache.

func Fill Uses

func Fill(t store.KeySaver)

func LocalFor Uses

func LocalFor(l logger.Logger, ra net.IP) net.IP

LocalFor returns the local IP address that has responded to TFTP or HTTP requests for the given remote IP. It also bumps the timeout.

func ModelToBackend Uses

func ModelToBackend(m models.Model) store.KeySaver

func SetLogPublisher Uses

func SetLogPublisher(l *logger.Buffer, pubs *Publishers)

func ValidateDataTrackerStore Uses

func ValidateDataTrackerStore(fileRoot string, backend, secrets store.Store, logger logger.Logger) (hard, soft error)

This must be locked with ALL locks on the source datatracker from the caller.

func ValidateParams Uses

func ValidateParams(rt *RequestTracker, e models.ErrorAdder, params map[string]interface{}, key []byte)

type AuthSaver Uses

type AuthSaver interface {
    AuthKey() string
}

type BootEnv Uses

type BootEnv struct {
    *models.BootEnv
    // contains filtered or unexported fields
}

BootEnv encapsulates the machine-agnostic information needed by the provisioner to set up a boot environment.

func AsBootEnv Uses

func AsBootEnv(o models.Model) *BootEnv

func AsBootEnvs Uses

func AsBootEnvs(o []models.Model) []*BootEnv

func (*BootEnv) AddDynamicTree Uses

func (b *BootEnv) AddDynamicTree()

func (*BootEnv) AfterDelete Uses

func (b *BootEnv) AfterDelete()

func (*BootEnv) AfterSave Uses

func (b *BootEnv) AfterSave()

func (*BootEnv) Backend Uses

func (b *BootEnv) Backend() store.Store

func (*BootEnv) BeforeDelete Uses

func (b *BootEnv) BeforeDelete() error

func (*BootEnv) BeforeSave Uses

func (b *BootEnv) BeforeSave() error

func (*BootEnv) Indexes Uses

func (b *BootEnv) Indexes() map[string]index.Maker

func (*BootEnv) Locks Uses

func (b *BootEnv) Locks(action string) []string

func (*BootEnv) NetBoot Uses

func (b *BootEnv) NetBoot() bool

func (*BootEnv) New Uses

func (b *BootEnv) New() store.KeySaver

func (*BootEnv) OnLoad Uses

func (b *BootEnv) OnLoad() error

func (*BootEnv) SaveClean Uses

func (b *BootEnv) SaveClean() store.KeySaver

func (*BootEnv) SetReadOnly Uses

func (b *BootEnv) SetReadOnly(nb bool)

func (*BootEnv) Validate Uses

func (b *BootEnv) Validate()

type DataTracker Uses

type DataTracker struct {
    logger.Logger
    FileRoot            string
    LogRoot             string
    OurAddress          string
    ForceOurAddress     bool
    StaticPort, ApiPort int
    FS                  *FileSystem
    Backend, Secrets    store.Store

    GlobalProfileName string
    // contains filtered or unexported fields
}

DataTracker represents everything there is to know about acting as a dataTracker.

func NewDataTracker Uses

func NewDataTracker(backend, secrets store.Store,
    fileRoot, logRoot, addr string, forceAddr bool,
    staticPort, apiPort int,
    logger logger.Logger,
    defaultPrefs map[string]string,
    publishers *Publishers) *DataTracker

Create a new DataTracker that will use passed store to save all operational data

func (*DataTracker) AllLicenses Uses

func (dt *DataTracker) AllLicenses() models.LicenseBundle

AllLicenses returns the current expiry state of the current licenses and caches that result.

func (*DataTracker) Backup Uses

func (p *DataTracker) Backup() ([]byte, error)

func (*DataTracker) GetInterfaces Uses

func (dt *DataTracker) GetInterfaces() ([]*models.Interface, error)

func (*DataTracker) GetToken Uses

func (p *DataTracker) GetToken(tokenString string) (*DrpCustomClaims, error)

func (*DataTracker) LicenseFor Uses

func (dt *DataTracker) LicenseFor(component string) *models.License

LicenseFor returns the expiry state of the specified component.

func (*DataTracker) LocalIP Uses

func (p *DataTracker) LocalIP(remote net.IP) string

func (*DataTracker) LogFor Uses

func (p *DataTracker) LogFor(s string) logger.Logger

func (*DataTracker) MacToMachineUUID Uses

func (p *DataTracker) MacToMachineUUID(mac string) string

func (*DataTracker) Pref Uses

func (p *DataTracker) Pref(name string) (string, error)

func (*DataTracker) Prefs Uses

func (p *DataTracker) Prefs() map[string]string

func (*DataTracker) RenderUnknown Uses

func (p *DataTracker) RenderUnknown(rt *RequestTracker) error

func (*DataTracker) ReplaceBackend Uses

func (p *DataTracker) ReplaceBackend(rt *RequestTracker, st store.Store) (hard, soft error)

Assumes that all locks are held

func (*DataTracker) Request Uses

func (p *DataTracker) Request(l logger.Logger, locks ...string) *RequestTracker

Request initializes a RequestTracker from the specified DataTracker.

func (*DataTracker) SealClaims Uses

func (p *DataTracker) SealClaims(claims *DrpCustomClaims) (string, error)

func (*DataTracker) SetPrefs Uses

func (p *DataTracker) SetPrefs(rt *RequestTracker, prefs map[string]string) error

type DrpCustomClaims Uses

type DrpCustomClaims struct {
    DrpClaims     []*models.Claim `json:"drp_claims"`
    DrpRoles      []string
    GrantorClaims GrantorClaims `json:"grantor_claims"`
    jwt.StandardClaims
}

DrpCustomClaims is a JWT token that contains a list of all the things this token allows access to.

func NewClaim Uses

func NewClaim(user, grantor string, ttl time.Duration) *DrpCustomClaims

NewClaim creates a new, unsigned Token that doesn't allow access to anything. You must call Seal() to turn this into a signed JWT token.

func (*DrpCustomClaims) AddMachine Uses

func (d *DrpCustomClaims) AddMachine(uuid string) *DrpCustomClaims

Set the specific secrets

func (*DrpCustomClaims) AddRawClaim Uses

func (d *DrpCustomClaims) AddRawClaim(scope, action, specific string) *DrpCustomClaims

AddRawClaim adds a discrete Claim to our custom Token class.

func (*DrpCustomClaims) AddRoles Uses

func (d *DrpCustomClaims) AddRoles(names ...string) *DrpCustomClaims

func (*DrpCustomClaims) AddSecrets Uses

func (d *DrpCustomClaims) AddSecrets(user, grantor, machine string) *DrpCustomClaims

Set the specific secrets

func (*DrpCustomClaims) ClaimsList Uses

func (d *DrpCustomClaims) ClaimsList(rt *RequestTracker) []models.Claims

func (*DrpCustomClaims) GrantorId Uses

func (d *DrpCustomClaims) GrantorId() string

func (*DrpCustomClaims) HasGrantorId Uses

func (d *DrpCustomClaims) HasGrantorId() bool

func (*DrpCustomClaims) HasMachineUuid Uses

func (d *DrpCustomClaims) HasMachineUuid() bool

func (*DrpCustomClaims) HasUserId Uses

func (d *DrpCustomClaims) HasUserId() bool

func (*DrpCustomClaims) MachineUuid Uses

func (d *DrpCustomClaims) MachineUuid() string

func (*DrpCustomClaims) Seal Uses

func (d *DrpCustomClaims) Seal(m *JwtManager) (string, error)

Seal turns our custom Token class into a signed JWT Token.

func (*DrpCustomClaims) UserId Uses

func (d *DrpCustomClaims) UserId() string

func (*DrpCustomClaims) ValidateSecrets Uses

func (d *DrpCustomClaims) ValidateSecrets(grantor, user, machine string) bool

type FileSystem Uses

type FileSystem struct {
    sync.Mutex
    // contains filtered or unexported fields
}

FileSystem provides the routines to allow the static HTTP and TFTP services to render templates on demand..

func NewFS Uses

func NewFS(backingFSPath string, logger logger.Logger) *FileSystem

NewFS creates a new initialized filesystem that will fall back to serving files from backingFSPath if there is not a template to be rendered.

func (*FileSystem) AddDynamicFile Uses

func (fs *FileSystem) AddDynamicFile(fsPath string, t func(net.IP) (io.Reader, error))

AddDynamicFile adds a lookaside that handles rendering a file that should be generated on the fly. fsPath is the path where the dynamic lookaside lives, and the passed-in function will be called with the IP address of the system making the request.

func (*FileSystem) AddDynamicTree Uses

func (fs *FileSystem) AddDynamicTree(fsPath string, t func(string) (io.Reader, error))

AddDynamicTree adds a lookaside responsible for wholesale impersonation of a directory tree. fsPath indicates where AddDynamicTree will start handling all read requests, and the passed-in function will be called with the full path to whatever was being requested.

func (*FileSystem) DelDynamicFile Uses

func (fs *FileSystem) DelDynamicFile(fsPath string)

DelDynamicFile removes a lookaside registered for fsPath, if any.

func (*FileSystem) DelDynamicTree Uses

func (fs *FileSystem) DelDynamicTree(fsPath string)

DelDynamicTree removes a lookaside responsible for wholesale impersonation of a directory tree.

func (*FileSystem) Open Uses

func (fs *FileSystem) Open(p string, remoteIP net.IP) (io.Reader, error)

Open tests for the existence of a lookaside for file read request. The returned Reader amd error contains the results of running the lookaside function if one is present. If both the reader and error are nil, FileSystem should fall back to serving a static file.

func (*FileSystem) ServeHTTP Uses

func (fs *FileSystem) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for the FileSystem.

func (*FileSystem) TftpResponder Uses

func (fs *FileSystem) TftpResponder() func(string, net.IP) (io.Reader, error)

TftpResponder returns a function that allows the TFTP midlayer to serve files from the FileSystem.

type GrantorClaims Uses

type GrantorClaims struct {
    GrantorId     string `json:"grantor_id"`
    GrantorSecret string `json:"grantor_secret"`
    UserId        string `json:"user_id"`
    UserSecret    string `json:"user_secret"`
    MachineUuid   string `json:"machine_uuid"`
    MachineSecret string `json:"machine_secret"`
}

Grantor Claims allow for the token to be validated against the granting user, the current user, and the machine. Each of those object can have a secret that if changed on the user object will invalid the token.

This allows for mass revocation at a machine, grantor, or user level.

func (*GrantorClaims) Validate Uses

func (gc *GrantorClaims) Validate(grantor, user, machine string) bool

If present, we should validate them.

type Job Uses

type Job struct {
    *models.Job
    // contains filtered or unexported fields
}

Job represents a task that is running (or has run) on a machine. The job create workflow I envision works like this:

* POST to api/v3/jobs with a body containing {"Machine":

"a-machine-uuid"} If there is no current job, or the current job
is "failed", a new job is created for the Task indexed by
CurrentTask. If the current job is "finished", the machine
CurrentTask is incremented.  If that causes CurrentTask to go
past the end of the Tasks list for the machine, no job is created
and the API returns a 204. If the current job is in the incomplete
state, that job is returned with a 202.  Otherwise a new job is
created and is returned with a 201. If there is a current job that is neither
"incomplete", "failed", nor "finished", the POST fails.  The new job will be
created with its Previous value set to the machine's CurrentJob,
and the machine's CurrentJob is updated with the UUID of the new
job.

* When a new Job is created, it makes a RenderData for the

templates contained in the Task the job was created against.  The
client will be able to retrieve the rendered templates via GET
from api/v3/jobs/:job-id/templates.

* The client will place or execute the templates based on whether

there is a Path associated with the expanded Template in the
order that the jobs/:id/templates API endpoint returns them in.
As it does so, it will log its progress via POST to jobs/:id/log.

* If any job operation fails, the client will update the job status to "failed".

* If all job operations succeed, the client will update the job status to "finished"

* On provisioner startup, all machine CurrentJobs are set to "failed" if they are not "finished"

func AsJob Uses

func AsJob(o models.Model) *Job

func AsJobs Uses

func AsJobs(o []models.Model) []*Job

func (*Job) AfterDelete Uses

func (j *Job) AfterDelete()

func (*Job) AfterSave Uses

func (j *Job) AfterSave()

func (*Job) BeforeDelete Uses

func (j *Job) BeforeDelete() error

func (*Job) BeforeSave Uses

func (j *Job) BeforeSave() error

func (*Job) Indexes Uses

func (j *Job) Indexes() map[string]index.Maker

func (*Job) Locks Uses

func (j *Job) Locks(action string) []string

func (*Job) Log Uses

func (j *Job) Log(rt *RequestTracker, src io.Reader) error

func (*Job) LogPath Uses

func (j *Job) LogPath(rt *RequestTracker) string

func (*Job) New Uses

func (j *Job) New() store.KeySaver

func (*Job) OnChange Uses

func (j *Job) OnChange(oldThing store.KeySaver) error

func (*Job) OnCreate Uses

func (j *Job) OnCreate() error

func (*Job) OnLoad Uses

func (j *Job) OnLoad() error

func (*Job) RenderActions Uses

func (j *Job) RenderActions(rt *RequestTracker) ([]*models.JobAction, error)

func (*Job) SaveClean Uses

func (j *Job) SaveClean() store.KeySaver

func (*Job) SetReadOnly Uses

func (j *Job) SetReadOnly(b bool)

func (*Job) UUID Uses

func (j *Job) UUID() string

func (*Job) Validate Uses

func (j *Job) Validate()

type JwtConfig Uses

type JwtConfig struct {
    // digital signing method, defaults to jwt.SigningMethodHS256 (SHA256)
    Method jwt.SigningMethod
}

Config configures a Manager.

type JwtManager Uses

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

Manager is a JSON Web Token (JWT) Provider which create or retrieves tokens with a particular signing key and options.

func NewJwtManager Uses

func NewJwtManager(key []byte, configs ...JwtConfig) *JwtManager

New creates a new Manager which provides JWTs using the given signing key. Defaults to signing with SHA256 HMAC (jwt.SigningMethodHS256)

type Lease Uses

type Lease struct {
    *models.Lease
    // contains filtered or unexported fields
}

Lease models a DHCP Lease

func AsLease Uses

func AsLease(o models.Model) *Lease

func AsLeases Uses

func AsLeases(o []models.Model) []*Lease

func FakeLeaseFor Uses

func FakeLeaseFor(rt *RequestTracker,
    strat, token string,
    via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation)

FakeLeaseFor returns a lease that has zero duration and that should not be saved. It is intended for use when we are acting as a proxy DHCP server or we are acting as a BINL server.

func FindLease Uses

func FindLease(rt *RequestTracker,
    strat, token string,
    req net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, err error)

FindLease finds an appropriate matching Lease. If a non-nil error is returned, the DHCP system must NAK the response. If lease and error are nil, the DHCP system must not respond to the request. Otherwise, the lease will be returned with its ExpireTime updated and the Lease saved.

This function should be called in response to a DHCPREQUEST.

func FindOrCreateLease Uses

func FindOrCreateLease(rt *RequestTracker,
    strat, token string,
    req net.IP,
    via []net.IP) (lease *Lease, subnet *Subnet, reservation *Reservation, fresh bool)

FindOrCreateLease will return a lease for the passed information, creating it if it can. If a non-nil Lease is returned, it has been saved and the DHCP system can offer it. If the returned lease is nil, then the DHCP system should not respond.

This function should be called for DHCPDISCOVER.

func (*Lease) BeforeSave Uses

func (l *Lease) BeforeSave() error

func (*Lease) Indexes Uses

func (l *Lease) Indexes() map[string]index.Maker

func (*Lease) Locks Uses

func (l *Lease) Locks(action string) []string

func (*Lease) New Uses

func (l *Lease) New() store.KeySaver

func (*Lease) OnChange Uses

func (l *Lease) OnChange(oldThing store.KeySaver) error

func (*Lease) OnCreate Uses

func (l *Lease) OnCreate() error

func (*Lease) OnLoad Uses

func (l *Lease) OnLoad() error

func (*Lease) Reservation Uses

func (l *Lease) Reservation(rt *RequestTracker) *Reservation

func (*Lease) SaveClean Uses

func (l *Lease) SaveClean() store.KeySaver

func (*Lease) SetReadOnly Uses

func (l *Lease) SetReadOnly(b bool)

func (*Lease) Subnet Uses

func (l *Lease) Subnet(rt *RequestTracker) *Subnet

func (*Lease) Validate Uses

func (l *Lease) Validate()

type LeaseNAK Uses

type LeaseNAK error

LeaseNAK is the error that shall be returned when we cannot give a system the IP address it requested. If FindLease or FindOrCreateLease return this as their error, then the DHCP midlayer must NAK the request.

type Machine Uses

type Machine struct {
    *models.Machine
    // contains filtered or unexported fields
}

Machine represents a single bare-metal system that the provisioner should manage the boot environment for.

func AsMachine Uses

func AsMachine(o models.Model) *Machine

func AsMachines Uses

func AsMachines(o []models.Model) []*Machine

func (*Machine) AfterDelete Uses

func (n *Machine) AfterDelete()

func (*Machine) AfterSave Uses

func (n *Machine) AfterSave()

func (*Machine) AllowStageChange Uses

func (n *Machine) AllowStageChange()

func (*Machine) BeforeSave Uses

func (n *Machine) BeforeSave() error

func (*Machine) HasProfile Uses

func (n *Machine) HasProfile(name string) bool

func (*Machine) HasTask Uses

func (n *Machine) HasTask(s string) bool

func (*Machine) HexAddress Uses

func (n *Machine) HexAddress() string

HexAddress returns Address in raw hexadecimal format, suitable for pxelinux and elilo usage.

func (*Machine) InRunner Uses

func (n *Machine) InRunner()

func (*Machine) Indexes Uses

func (n *Machine) Indexes() map[string]index.Maker

func (*Machine) Locks Uses

func (n *Machine) Locks(action string) []string

func (*Machine) New Uses

func (n *Machine) New() store.KeySaver

func (*Machine) OnChange Uses

func (n *Machine) OnChange(oldThing store.KeySaver) error

func (*Machine) OnCreate Uses

func (n *Machine) OnCreate() error

func (*Machine) OnLoad Uses

func (n *Machine) OnLoad() error

func (*Machine) ParameterMaker Uses

func (n *Machine) ParameterMaker(rt *RequestTracker, parameter string) (index.Maker, error)

func (*Machine) Path Uses

func (n *Machine) Path() string

func (*Machine) SaveClean Uses

func (n *Machine) SaveClean() store.KeySaver

func (*Machine) SetReadOnly Uses

func (n *Machine) SetReadOnly(b bool)

func (*Machine) ShortName Uses

func (n *Machine) ShortName() string

func (*Machine) Validate Uses

func (n *Machine) Validate()

type Param Uses

type Param struct {
    *models.Param
    // contains filtered or unexported fields
}

Param represents metadata about a Parameter or a Preference. Specifically, it contains a description of what the information is for, detailed documentation about the param, and a JSON schema that the param must match to be considered valid.

func AsParam Uses

func AsParam(o models.Model) *Param

func AsParams Uses

func AsParams(o []models.Model) []*Param

func (*Param) BeforeSave Uses

func (p *Param) BeforeSave() error

func (*Param) Indexes Uses

func (p *Param) Indexes() map[string]index.Maker

func (*Param) Locks Uses

func (p *Param) Locks(action string) []string

func (*Param) New Uses

func (p *Param) New() store.KeySaver

func (*Param) OnLoad Uses

func (p *Param) OnLoad() error

func (*Param) SaveClean Uses

func (p *Param) SaveClean() store.KeySaver

func (*Param) SetReadOnly Uses

func (p *Param) SetReadOnly(b bool)

func (*Param) Validate Uses

func (p *Param) Validate()

func (*Param) ValidateValue Uses

func (p *Param) ValidateValue(val interface{}, key []byte) error

type Paramer Uses

type Paramer interface {
    models.Model
    GetParams(Stores, bool) map[string]interface{}
    SetParams(Stores, map[string]interface{}) error
    GetParam(Stores, string, bool) (interface{}, bool)
    SetParam(Stores, string, interface{}) error
}

type Plugin Uses

type Plugin struct {
    *models.Plugin
    // contains filtered or unexported fields
}

Plugin represents a single instance of a running plugin. This contains the configuration need to start this plugin instance.

func AsPlugin Uses

func AsPlugin(o models.Model) *Plugin

func AsPlugins Uses

func AsPlugins(o []models.Model) []*Plugin

func (*Plugin) AfterDelete Uses

func (n *Plugin) AfterDelete()

func (*Plugin) BeforeSave Uses

func (n *Plugin) BeforeSave() error

func (*Plugin) Indexes Uses

func (n *Plugin) Indexes() map[string]index.Maker

func (*Plugin) Key Uses

func (n *Plugin) Key() string

func (*Plugin) Locks Uses

func (n *Plugin) Locks(action string) []string

func (*Plugin) New Uses

func (n *Plugin) New() store.KeySaver

func (*Plugin) OnLoad Uses

func (n *Plugin) OnLoad() error

func (*Plugin) Prefix Uses

func (n *Plugin) Prefix() string

func (*Plugin) SaveClean Uses

func (n *Plugin) SaveClean() store.KeySaver

func (*Plugin) SetReadOnly Uses

func (n *Plugin) SetReadOnly(b bool)

func (*Plugin) Validate Uses

func (n *Plugin) Validate()

type Pref Uses

type Pref struct {
    *models.Pref
    // contains filtered or unexported fields
}

Pref tracks a global DigitalRebar Provision preference -- things like the bootenv to use for unknown systems trying to PXE boot to us, the default bootenv for known systems, etc.

func AsPref Uses

func AsPref(v models.Model) *Pref

func (*Pref) Locks Uses

func (p *Pref) Locks(action string) []string

func (*Pref) New Uses

func (p *Pref) New() store.KeySaver

type Profile Uses

type Profile struct {
    *models.Profile
    // contains filtered or unexported fields
}

Profile represents a set of key/values to use in template expansion.

There is one special profile named 'global' that acts as a global set of parameters for the system.

These can be assigned to a machine's profile list.

func AsProfile Uses

func AsProfile(o models.Model) *Profile

func AsProfiles Uses

func AsProfiles(o []models.Model) []*Profile

func (*Profile) AfterDelete Uses

func (p *Profile) AfterDelete()

func (*Profile) BeforeDelete Uses

func (p *Profile) BeforeDelete() error

func (*Profile) BeforeSave Uses

func (p *Profile) BeforeSave() error

func (*Profile) Indexes Uses

func (p *Profile) Indexes() map[string]index.Maker

func (*Profile) Locks Uses

func (p *Profile) Locks(action string) []string

func (*Profile) New Uses

func (p *Profile) New() store.KeySaver

func (*Profile) OnLoad Uses

func (p *Profile) OnLoad() error

func (*Profile) SaveClean Uses

func (p *Profile) SaveClean() store.KeySaver

func (*Profile) SetReadOnly Uses

func (p *Profile) SetReadOnly(b bool)

func (*Profile) Validate Uses

func (p *Profile) Validate()

type Publisher Uses

type Publisher interface {
    Publish(event *models.Event) error
    Reserve() error
    Release()
    Unload()
}

* NOTE: CRUCIAL: CRITICAL: This could be bad if not adhered. * The Publish, release, and reserve routines must not call loggers * that publish events!

type Publishers Uses

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

func NewPublishers Uses

func NewPublishers(logger *log.Logger) *Publishers

func (*Publishers) Add Uses

func (p *Publishers) Add(pp Publisher)

func (*Publishers) List Uses

func (p *Publishers) List() []Publisher

func (*Publishers) Remove Uses

func (p *Publishers) Remove(pp Publisher)

type ReadSizer Uses

type ReadSizer interface {
    io.Reader
    Sizer
}

ReadSizer is an interface that has both a reader and can generate the size of that data.

type RenderData Uses

type RenderData struct {
    Machine *rMachine // The Machine that the template is being rendered for.
    Env     *rBootEnv // The boot environment that provided the template.
    Task    *rTask
    Stage   *rStage
    // contains filtered or unexported fields
}

RenderData is the struct that is passed to templates as a source of parameters and useful methods.

func (*RenderData) ApiURL Uses

func (r *RenderData) ApiURL() string

ApiURL returns a URL to access the api server part of the server using the requesting IP address as a basis.

func (*RenderData) BootParams Uses

func (r *RenderData) BootParams() (string, error)

BootParams is a helper function that expands the BootParams template from the boot environment.

func (*RenderData) CallTemplate Uses

func (r *RenderData) CallTemplate(name string, data interface{}) (ret interface{}, err error)

CallTemplate allows for sub-templating like the template function, but allows for function expansion of the arguments unlike the built-in template function.

func (*RenderData) GenerateInfiniteToken Uses

func (r *RenderData) GenerateInfiniteToken() string

GenerateInfiniteToken generates a token for a specific machine that has a three year timeout. It has the same permissions as the token generated by GenerateToken for a known machine.

func (*RenderData) GenerateProfileToken Uses

func (r *RenderData) GenerateProfileToken(profile string, duration int) string

GenerateProfileToken will generate a token that has access to read and update the specified token for a set duration. If duration is 0, then duration is 2000000000 seconds. This is used for atomic profile operations for cluster management.

func (*RenderData) GenerateToken Uses

func (r *RenderData) GenerateToken() string

GenerateToken will generate a token for a machine within a template. If the machine is not known, a token will be generate with create machine access only with a time limited by the unknownTokenTimeout preference. If the machine is known, a token will be generated with machine update access for the specific machine with a time limited by the knownTokenTimeout preference. The token is granted by the system with and signed with the system grantor secret.

func (*RenderData) InstallRepos Uses

func (r *RenderData) InstallRepos() []*Repo

InstallRepos returns a list of repos for the base install of the current machine bootenv combo. The first repo is the install source. The second repo is the security update repo.

func (*RenderData) MachineRepos Uses

func (r *RenderData) MachineRepos() []*Repo

MachineRepos returns a list of the repos for the specific machine's current state.

func (*RenderData) Param Uses

func (r *RenderData) Param(key string) (interface{}, error)

Param is a helper function for extracting a parameter from Machine.Params

func (*RenderData) ParamAsJSON Uses

func (r *RenderData) ParamAsJSON(key string) (string, error)

ParamAsJSON will return the specified parameter as a JSON string or an error.

func (*RenderData) ParamAsYAML Uses

func (r *RenderData) ParamAsYAML(key string) (string, error)

ParamAsYAML will return the specified parameter as a YAML string or an error.

func (*RenderData) ParamExists Uses

func (r *RenderData) ParamExists(key string) bool

ParamExists is a helper function for determining the existence of a machine parameter.

func (*RenderData) ParseUrl Uses

func (r *RenderData) ParseUrl(segment, rawUrl string) (string, error)

ParseUrl is a template function that return the section of the specified URL as a string.

func (*RenderData) ProvisionerAddress Uses

func (r *RenderData) ProvisionerAddress() string

ProvisionerAddress returns the IP address to access the Provisioner based upon the requesting IP address.

func (*RenderData) ProvisionerURL Uses

func (r *RenderData) ProvisionerURL() string

ProvisionerURL returns a URL to access the file server part of the server using the requesting IP address as a basis.

func (*RenderData) Repos Uses

func (r *RenderData) Repos(tags ...string) []*Repo

Repos is a template helper function that returns an array of all the appropriate repos based upon the tag list.

type Repo Uses

type Repo struct {
    Tag            string   `json:"tag"`
    OS             []string `json:"os"`
    URL            string   `json:"url"`
    PackageType    string   `json:"packageType"`
    RepoType       string   `json:"repoType"`
    InstallSource  bool     `json:"installSource"`
    SecuritySource bool     `json:"securitySource"`
    Distribution   string   `json:"distribution"`
    BootLoc        string   `json:"bootloc"`
    Components     []string `json:"components"`
    // contains filtered or unexported fields
}

Repo defines the repository structure used for the package-repositories parameter with additional fields to help rendering.

func (*Repo) Install Uses

func (rd *Repo) Install() (string, error)

Install returns a string or the encountered error that represents the package repo type specific file snippets for either preseed/kickstarts with parts for either the core install part or updates/additional repos.

func (*Repo) JoinedComponents Uses

func (rd *Repo) JoinedComponents() string

JoinedComponents returns the Components array as a single string joined with spaces.

func (*Repo) Lines Uses

func (rd *Repo) Lines() (string, error)

Lines returns an error or the string for inclusion in a configuration file in the package manager specific format based upon the repo definitions.

func (*Repo) R Uses

func (rd *Repo) R() *RenderData

R returns the RenderData for this repo.

func (*Repo) Target Uses

func (rd *Repo) Target() string

Target returns the target os for this Repo.

func (*Repo) UrlFor Uses

func (rd *Repo) UrlFor(component string) string

UrlFor returns a Url for the requested component part of the repo.

type RequestTracker Uses

type RequestTracker struct {
    *sync.Mutex
    logger.Logger
    // contains filtered or unexported fields
}

RequestTracker tracks a single request to the DataTracker. It represents the closest thing to a transaction that we have.

func (*RequestTracker) AllLocked Uses

func (rt *RequestTracker) AllLocked(thunk func(Stores))

AllLocked takes a function that takes the lock stores. In this case, all stores are locked and sent the function. Upon completion, the locks are released. It is assumed that is as lamdba function.

func (*RequestTracker) ApiURL Uses

func (rt *RequestTracker) ApiURL(remoteIP net.IP) string

ApiURL is a helper function to return the appropriate URL to access the API based upon the remote IP.

func (*RequestTracker) Create Uses

func (rt *RequestTracker) Create(obj models.Model) (saved bool, err error)

Create takes an object and attempts to save it. saved is true if the object is actually saved. error indicates the actual error including validation errors. A "create" event is generated from this call.

Assumes locks are held if appropriate.

func (*RequestTracker) DeleteKeyFor Uses

func (rt *RequestTracker) DeleteKeyFor(m models.Model) error

func (*RequestTracker) Do Uses

func (rt *RequestTracker) Do(thunk func(Stores))

Do takes a function that takes the lock stores specified when the RequestTracker was created and executes it with the locks taken and then unlocks the locks when complete. It is assumed that is as lamdba function.

func (*RequestTracker) FileURL Uses

func (rt *RequestTracker) FileURL(remoteIP net.IP) string

FileURL is a helper function to return the appropriate URL to access the FileServer based upon the remote IP.

func (*RequestTracker) Find Uses

func (rt *RequestTracker) Find(prefix, key string) models.Model

Find uses the find helper routine and returns a clone of the in-memory data store cached object.

func (*RequestTracker) FindByIndex Uses

func (rt *RequestTracker) FindByIndex(prefix string, idx index.Maker, key string) models.Model

FindByIndex uses the provided index and key (for that index) to return the object. The object returned is a clone.

func (*RequestTracker) GetParam Uses

func (rt *RequestTracker) GetParam(obj models.Paramer, key string, aggregate bool, decrypt bool) (interface{}, bool)

func (*RequestTracker) GetParams Uses

func (rt *RequestTracker) GetParams(obj models.Paramer, aggregate bool, decrypt bool) map[string]interface{}

func (*RequestTracker) Index Uses

func (rt *RequestTracker) Index(name string) *index.Index

Index returns the index specified by that name. No validation is done on the name.

func (*RequestTracker) MachineForMac Uses

func (rt *RequestTracker) MachineForMac(mac string) *Machine

MachineForMac looks up a Machine by the specified MAC address.

func (*RequestTracker) Patch Uses

func (rt *RequestTracker) Patch(obj models.Model, key string, patch jsonpatch2.Patch) (models.Model, error)

Patch takes a partially specified object to define the key space, a key to find the object, and a JSON patch object to apply to the found object. Upon success, the new object is returned. Failure returned in the error field. This will generate an "update" event.

Assumes locks are held as appropriate.

func (*RequestTracker) Prefs Uses

func (rt *RequestTracker) Prefs() map[string]string

Prefs returns the current Prefs in the data tracker.

func (*RequestTracker) PrivateKeyFor Uses

func (rt *RequestTracker) PrivateKeyFor(m models.Model) ([]byte, error)

func (*RequestTracker) PublicKeyFor Uses

func (rt *RequestTracker) PublicKeyFor(m models.Model) ([]byte, error)

func (*RequestTracker) Publish Uses

func (rt *RequestTracker) Publish(prefix, action, key string, ref interface{}) error

Publish takes the components of an Event and notifies the publishers immediately if not locks are in place. Otherwise, the action is delayed until the locks are released.

func (*RequestTracker) PublishEvent Uses

func (rt *RequestTracker) PublishEvent(e *models.Event) error

PublishEvent records the Event to publish to all publish listeners at after the RequestTracker locks have been released. This allows for Events to be published within a locked transaction without deadlocking the system. If the call is made without locks, the publishers are notified in this call path.

func (*RequestTracker) RawFind Uses

func (rt *RequestTracker) RawFind(prefix, key string) models.Model

RawFind uses the find helper routine and returns the in-memory data store cached object.

func (*RequestTracker) Remove Uses

func (rt *RequestTracker) Remove(obj models.Model) (removed bool, err error)

Remove takes a complete or partial object and removes the object from the system. removed is true if the object is removed. error indicates the error that caused the remove to fail. A "delete" event is generated from this routine.

Assumes locks are held if appropriate.

func (*RequestTracker) Save Uses

func (rt *RequestTracker) Save(obj models.Model) (saved bool, err error)

Save takes a fully specified object and saves it to the data store and backing index. This will generate a "save" event. The difference between Update and Save is that Update will go through the OnChange callback system. Save will NOT. Both calls will call BeforeSave and AfterSave.

Assumes that locks are held as appropriate.

func (*RequestTracker) SealClaims Uses

func (rt *RequestTracker) SealClaims(claims *DrpCustomClaims) (string, error)

SealClaims takes a set of auth claims and signs them to make an Token for authentication purposes.

func (*RequestTracker) Update Uses

func (rt *RequestTracker) Update(obj models.Model) (saved bool, err error)

Update takes a fully specified object and replaces an existing object in the data store assuming the new object is valid. saved is true if the object is saved. error indicates failure. An "update" event is generated from this call.

Assumes locks are held as appropriate.

type Reservation Uses

type Reservation struct {
    *models.Reservation
    // contains filtered or unexported fields
}

Reservation tracks persistent DHCP IP address reservations.

func AsReservation Uses

func AsReservation(o models.Model) *Reservation

AsReservation converts a models.Model to a *Reservation.

func AsReservations Uses

func AsReservations(o []models.Model) []*Reservation

AsReservations converts a list of models.Model to a list of *Reservation.

func (*Reservation) BeforeSave Uses

func (r *Reservation) BeforeSave() error

BeforeSave validates the object and returns an error if the operation should be aborted.

func (*Reservation) Indexes Uses

func (r *Reservation) Indexes() map[string]index.Maker

Indexes returns a map of indexes for Reservation.

func (*Reservation) Locks Uses

func (r *Reservation) Locks(action string) []string

Locks returns a list of prefixes to lock for a specific action.

func (*Reservation) New Uses

func (r *Reservation) New() store.KeySaver

New returns an empty Reservation object with the forceChange and RT fields from the calling object as store.KeySaver for use by the data stores.

func (*Reservation) OnChange Uses

func (r *Reservation) OnChange(oldThing store.KeySaver) error

OnChange is called by the data stores when a value changes to ensure the change is valid. Errors abort the change.

func (*Reservation) OnCreate Uses

func (r *Reservation) OnCreate() error

OnCreate is called by the data stores when creating a value. It validates the object relative to others and upon error aborts the create.

func (*Reservation) OnLoad Uses

func (r *Reservation) OnLoad() error

OnLoad is call by the data store initialize and validate a loaded Reservation.

func (*Reservation) SaveClean Uses

func (r *Reservation) SaveClean() store.KeySaver

SaveClean interface function to clear validation fields and return object as a store.KeySaver for the data stores.

func (*Reservation) SetReadOnly Uses

func (r *Reservation) SetReadOnly(b bool)

SetReadOnly interface function to set the ReadOnly flag.

func (*Reservation) Validate Uses

func (r *Reservation) Validate()

Validate ensures the object is valid. Setting the available and valid flags as appropriate.

type Role Uses

type Role struct {
    *models.Role
    // contains filtered or unexported fields
}

Role wraps the Role model to provide backend specific fields for tracking claims and validation.

func AsRole Uses

func AsRole(r models.Model) *Role

AsRole converts a models.Model to a *Role.

func AsRoles Uses

func AsRoles(o []models.Model) []*Role

AsRoles converts a list of models.Model to a list of *Role.

func (*Role) AfterSave Uses

func (r *Role) AfterSave()

AfterSave clears the cachedClaims after a save operation.

func (*Role) BeforeDelete Uses

func (r *Role) BeforeDelete() error

BeforeDelete will abort the Delete operation if the Role is in use by a User.

func (*Role) BeforeSave Uses

func (r *Role) BeforeSave() error

BeforeSave returns an error if the Role is not Valid. This aborts the save to a data store.

func (*Role) CompiledClaims Uses

func (r *Role) CompiledClaims() models.Claims

CompiledClaims compiles and caches the claims for this role to accelerate lookups in the future.

func (*Role) Indexes Uses

func (r *Role) Indexes() map[string]index.Maker

Indexes returns a map of valid indexes for Role.

func (*Role) Locks Uses

func (r *Role) Locks(action string) []string

Locks returns a list of prefixes needed to lock for the specific action.

func (*Role) New Uses

func (r *Role) New() store.KeySaver

New returns a new empty Role with the RT field from the calling function returned as a store.KeySaver for use by the data stores.

func (*Role) OnLoad Uses

func (r *Role) OnLoad() error

OnLoad initializes and validates the object as it is loaded from the data stores.

func (*Role) SaveClean Uses

func (r *Role) SaveClean() store.KeySaver

SaveClean interface function to clear Validation fields and return the object as a store.KeySaver for the data store.

func (*Role) SetReadOnly Uses

func (r *Role) SetReadOnly(b bool)

SetReadOnly interface function to set the ReadOnly flag.

func (*Role) Validate Uses

func (r *Role) Validate()

Validate ensures that the Role is valid and available. It sets those flags as appropriate.

type Sizer Uses

type Sizer interface {
    Size() int64
}

Sizer is an interface for things that have Size.

type Stage Uses

type Stage struct {
    *models.Stage
    // contains filtered or unexported fields
}

Stage encapsulates tasks we want to run a machine

func AsStage Uses

func AsStage(o models.Model) *Stage

AsStage converts the models.Model into a *Stage.

func AsStages Uses

func AsStages(o []models.Model) []*Stage

AsStages converts the list of models.Model into a list of *Stage.

func (*Stage) AfterSave Uses

func (s *Stage) AfterSave()

AfterSave registers new renderers after successful save.

func (*Stage) BeforeDelete Uses

func (s *Stage) BeforeDelete() error

BeforeDelete returns an error if the Stage is in use by a workflow or machine to abort the delete.

func (*Stage) BeforeSave Uses

func (s *Stage) BeforeSave() error

BeforeSave returns an error if the Stage is not valid to abort the Save.

func (*Stage) HasProfile Uses

func (s *Stage) HasProfile(name string) bool

HasProfile returns true if the profile name is in the Profiles list.

func (*Stage) HasTask Uses

func (s *Stage) HasTask(ts string) bool

HasTask returns true if the task name is in the Tasks list.

func (*Stage) Indexes Uses

func (s *Stage) Indexes() map[string]index.Maker

Indexes returns a map of valid indexes for Stage.

func (*Stage) Locks Uses

func (s *Stage) Locks(action string) []string

Locks returns a list of prefixes that need to be locked for the specific action.

func (*Stage) New Uses

func (s *Stage) New() store.KeySaver

New returns a new empty Stage with the ForceChange and RT fields of the calling Stage as store.KeySaver for the data store.

func (*Stage) OnLoad Uses

func (s *Stage) OnLoad() error

OnLoad initializes the Stage when loaded by the data store.

func (*Stage) SaveClean Uses

func (s *Stage) SaveClean() store.KeySaver

SaveClean interface function to clear validation fields and return a store.KeySaver for use in data stores.

func (*Stage) SetReadOnly Uses

func (s *Stage) SetReadOnly(b bool)

SetReadOnly interface function to set the ReadOnly flag.

func (*Stage) Validate Uses

func (s *Stage) Validate()

Validate ensures that the Stage is valid and available. Setting those flags as appropriate. Profiles, Tasks, and BootEnv are validate for presence. Renderers are updated as appropriate.

type Store Uses

type Store struct {
    sync.Mutex
    index.Index
    // contains filtered or unexported fields
}

dtobjs is an in-memory cache of all the objects we could reference. The implementation of this may need to change from storing a slice of things to a more elaborate datastructure at some point in time. Since that point in time is when the slices are forced out of CPU cache, I am not terribly concerned for now. Until that point is reached, sorting and searching slices is fantastically efficient.

type Stores Uses

type Stores func(string) *Store

type Subnet Uses

type Subnet struct {
    *models.Subnet
    // contains filtered or unexported fields
}

Subnet represents a DHCP Subnet

func AsSubnet Uses

func AsSubnet(o models.Model) *Subnet

AsSubnet converts a models.Model into a *Subnet.

func AsSubnets Uses

func AsSubnets(o []models.Model) []*Subnet

AsSubnets converts a list of models.Model into a list of *Subnet.

func (*Subnet) BeforeSave Uses

func (s *Subnet) BeforeSave() error

BeforeSave returns an error if the subnet is not valid. This is used by the store system to avoid saving bad Subnets.

func (*Subnet) InActiveRange Uses

func (s *Subnet) InActiveRange(ip net.IP) bool

InActiveRange returns true if the IP is inside the subnet's active range, inclusively.

func (*Subnet) InSubnetRange Uses

func (s *Subnet) InSubnetRange(ip net.IP) bool

InSubnetRange returns true if the IP is inside the subnet CIDR.

func (*Subnet) Indexes Uses

func (s *Subnet) Indexes() map[string]index.Maker

Indexes returns a map of the valid indexes for Subnet.

func (*Subnet) LeaseTimeFor Uses

func (s *Subnet) LeaseTimeFor(ip net.IP) time.Duration

LeaseTimeFor returns the lease time for the IP in question. The value reflects if the IP in the active range, inside the subnet, or if the subnet is in proxy mode.

func (*Subnet) Locks Uses

func (s *Subnet) Locks(action string) []string

Locks will return a list of prefixes needed to lock for a specific action.

func (*Subnet) New Uses

func (s *Subnet) New() store.KeySaver

New returns a new Subnet with the forceChange and RT fields copied from the calling Subnet.

func (*Subnet) OnLoad Uses

func (s *Subnet) OnLoad() error

OnLoad initializes and validates the Subnet when loading from a data store.

func (*Subnet) SaveClean Uses

func (s *Subnet) SaveClean() store.KeySaver

SaveClean clears the validation fields and returns the object as a store.KeySaver for use by the backing store.

func (*Subnet) SetReadOnly Uses

func (s *Subnet) SetReadOnly(b bool)

SetReadOnly is an interface function to set the ReadOnly flag.

func (*Subnet) Validate Uses

func (s *Subnet) Validate()

Validate ensures that the Subnet has valid values and do NOT overlap with out subnets. This sets the available and valid flags.

type Task Uses

type Task struct {
    *models.Task
    // contains filtered or unexported fields
}

Task is a thing that can run on a Machine.

func AsTask Uses

func AsTask(o models.Model) *Task

AsTask converts a models.Model to a *Task.

func AsTasks Uses

func AsTasks(o []models.Model) []*Task

AsTasks converts a list of models.Model to a list of *Task.

func (*Task) BeforeDelete Uses

func (t *Task) BeforeDelete() error

BeforeDelete makes sure that the task is not referenced before deleteing.

func (*Task) BeforeSave Uses

func (t *Task) BeforeSave() error

BeforeSave makes sure the Task is valid and returns an error if not. This is used to abort saving invalid objects.

func (*Task) Indexes Uses

func (t *Task) Indexes() map[string]index.Maker

Indexes returns the valid indexes for a Task.

func (*Task) Locks Uses

func (t *Task) Locks(action string) []string

Locks returns a list of prefixes to lock for a specific action.

func (*Task) New Uses

func (t *Task) New() store.KeySaver

New returns an empty new Task with the forceChange and RT fields inherited from the caller.

func (*Task) OnLoad Uses

func (t *Task) OnLoad() error

OnLoad initializes the task when loaded from the backing store.

func (*Task) SaveClean Uses

func (t *Task) SaveClean() store.KeySaver

SaveClean clears validation and returns the object as a KeySaver.

func (*Task) SetReadOnly Uses

func (t *Task) SetReadOnly(b bool)

SetReadOnly sets the ReadOnly flag.

func (*Task) Validate Uses

func (t *Task) Validate()

Validate tests the validity of Task. Including revalidating referencing stages.

type Template Uses

type Template struct {
    *models.Template
    // contains filtered or unexported fields
}

Template represents a template that will be associated with a boot environment.

func AsTemplate Uses

func AsTemplate(o models.Model) *Template

AsTemplate converts a models.Model into a *Template

func AsTemplates Uses

func AsTemplates(o []models.Model) []*Template

AsTemplates converts a list of models.Model into a list of *Template

func (*Template) AfterSave Uses

func (t *Template) AfterSave()

AfterSave updates referencing objects after a save to the backing store.

func (*Template) BeforeDelete Uses

func (t *Template) BeforeDelete() error

BeforeDelete returns an error if this template is still referenced before a delete is done. No error implies can be deleted.

func (*Template) BeforeSave Uses

func (t *Template) BeforeSave() error

BeforeSave makes sure that the template is valid and returns an error otherwise.

func (*Template) Indexes Uses

func (t *Template) Indexes() map[string]index.Maker

Indexes returns a map of valid indexes for Template

func (*Template) Locks Uses

func (t *Template) Locks(action string) []string

Locks returns the list of objects that need to be locked for the specified action.

func (*Template) New Uses

func (t *Template) New() store.KeySaver

New returns a new empty Template with the ForceChange RT fields initialized from the calling object.

func (*Template) OnLoad Uses

func (t *Template) OnLoad() error

OnLoad initializes the Template when loading from backing store.

func (*Template) SaveClean Uses

func (t *Template) SaveClean() store.KeySaver

SaveClean clears the validation fields and returns the object as a KeySaver for use in the backing stores.

func (*Template) SetReadOnly Uses

func (t *Template) SetReadOnly(b bool)

SetReadOnly helper function to set ReadOnly

func (*Template) Validate Uses

func (t *Template) Validate()

Validate makes sure that the template is valid. It sets the valid and available fields.

type Tenant Uses

type Tenant struct {
    *models.Tenant
    // contains filtered or unexported fields
}

Tenant contains the runtime parameters for user manipulation around the models.Tenant object.

func AsTenant Uses

func AsTenant(t models.Model) *Tenant

AsTenant converts a models.Model into a *Tenant.

func AsTenants Uses

func AsTenants(o []models.Model) []*Tenant

AsTenants converts a list of models.Model into a list of *Tenant.

func (*Tenant) AfterSave Uses

func (t *Tenant) AfterSave()

AfterSave cleans up or sets the internal activeTenant fields on users.

func (*Tenant) BeforeDelete Uses

func (t *Tenant) BeforeDelete() error

BeforeDelete makes sure that the Tenant is empty of users before deleting the tenant.

func (*Tenant) BeforeSave Uses

func (t *Tenant) BeforeSave() error

BeforeSave returns an error if the tenant is not Valid. It is also responsible for validating User membership is valid. todo: Actually validate that all the items the Tenant references still exist.

func (*Tenant) ExpandedMembers Uses

func (t *Tenant) ExpandedMembers() map[string]map[string]struct{}

ExpandedMembers builds a cached map of members of this tenant by prefix.

func (*Tenant) Indexes Uses

func (t *Tenant) Indexes() map[string]index.Maker

Indexes returns the valid Indexes on Tenant.

func (*Tenant) Locks Uses

func (t *Tenant) Locks(action string) []string

Locks returns a list of prefixes to lock for the specified action.

func (*Tenant) New Uses

func (t *Tenant) New() store.KeySaver

New returns a new empty Tenant with the RT field from the caller.

func (*Tenant) OnChange Uses

func (t *Tenant) OnChange(t2 store.KeySaver) error

OnChange figures out which users need to be updates based upon being added or removed from this Tenant.

func (*Tenant) OnCreate Uses

func (t *Tenant) OnCreate() error

OnCreate sets the internal add fields when a new object is created by the user.

func (*Tenant) OnLoad Uses

func (t *Tenant) OnLoad() error

OnLoad initializes the Tenant when loaded from the backing store.

func (*Tenant) SaveClean Uses

func (t *Tenant) SaveClean() store.KeySaver

SaveClean clears validation fields and returns a KeySaver object for use by the backing store.

func (*Tenant) Validate Uses

func (t *Tenant) Validate()

Validate makes sure the tenant is valid and available.

type User Uses

type User struct {
    *models.User
    // contains filtered or unexported fields
}

User is an API user of DigitalRebar Provision

func AsUser Uses

func AsUser(o models.Model) *User

AsUser converts a models.Model to a User.

func AsUsers Uses

func AsUsers(o []models.Model) []*User

AsUsers converts a list of models.Model to a list of *User

func (*User) AfterDelete Uses

func (u *User) AfterDelete()

AfterDelete cleans up other objects after the data store has removed the User.

func (*User) BeforeSave Uses

func (u *User) BeforeSave() error

BeforeSave validates and sets required fields on the User object before savining.

func (*User) ChangePassword Uses

func (u *User) ChangePassword(rt *RequestTracker, newPass string) error

ChangePassword takes a clear text password, generates a hash, clears the previous secret, and saves the object in the store.

func (*User) GenClaim Uses

func (u *User) GenClaim(grantor string, ttl time.Duration, wantedRoles ...string) *DrpCustomClaims

GenClaim generates a *DrpCustomClaims structure from a grantor for a limited time with the desired roles.

func (*User) Indexes Uses

func (u *User) Indexes() map[string]index.Maker

Indexes returns a map of indexes for the User model

func (*User) Locks Uses

func (u *User) Locks(action string) []string

Locks returns the object lock list for a given action for the User object

func (*User) New Uses

func (u *User) New() store.KeySaver

New returns a new User object with the RT and forceChange flags from the calling object.

func (*User) OnLoad Uses

func (u *User) OnLoad() error

OnLoad initializes and validates the user when loaded from the data store.

The mustSave part was added to handle data migration from pre-Secret days to post-Secret days. This could be removed once we feel that all deploys are past 3.6.0.

func (*User) SaveClean Uses

func (u *User) SaveClean() store.KeySaver

SaveClean clears all validation information and returns the user as a KeySaver object

func (*User) SetReadOnly Uses

func (u *User) SetReadOnly(b bool)

SetReadOnly sets the ReadOnly flag (helper functino)

func (*User) Tenant Uses

func (u *User) Tenant() string

Tenant returns the owning tenant for this user.

func (*User) Validate Uses

func (u *User) Validate()

Validate makes sure that User is valid and available.

type Workflow Uses

type Workflow struct {
    *models.Workflow
    // contains filtered or unexported fields
}

Workflow is a the backend model wrapper for Workflow. This struct also includes validation helpers.

func AsWorkflow Uses

func AsWorkflow(o models.Model) *Workflow

AsWorkflow cast a models.Model interface to *Workflow (helper function)

func AsWorkflows Uses

func AsWorkflows(o []models.Model) []*Workflow

AsWorkflows converts a list of models.Model to a list of *Worfklow (helper function)

func (*Workflow) BeforeSave Uses

func (w *Workflow) BeforeSave() error

BeforeSave validates the state of the Workflow. This is used generally before saving but also when an object needs to initialized and validated.

func (*Workflow) Indexes Uses

func (w *Workflow) Indexes() map[string]index.Maker

Indexes returns a map of the indexes allowed for Workflow objects.

func (*Workflow) Locks Uses

func (w *Workflow) Locks(action string) []string

Locks returns the object lock list for a given action for the Workflow object

func (*Workflow) New Uses

func (w *Workflow) New() store.KeySaver

New creates a new empty instance of Workflow. The ForceChanged and RT fields are propogated.

func (*Workflow) OnLoad Uses

func (w *Workflow) OnLoad() error

OnLoad initializes the Workflow when loaded from the data store.

func (*Workflow) SaveClean Uses

func (w *Workflow) SaveClean() store.KeySaver

SaveClean is a helper function to run the model version's ClearValidation function before converting back to an object that can be stored in the backend.

func (*Workflow) SetReadOnly Uses

func (w *Workflow) SetReadOnly(b bool)

SetReadOnly is a helper function to set the ReadOnly flag.

func (*Workflow) Validate Uses

func (w *Workflow) Validate()

Validate sets the valid and available flags for the Workflow. This assumes that locks are held as appropriate, if needed.

Directories

PathSynopsis
index

Package backend imports 47 packages (graph) and is imported by 3 packages. Updated 2018-05-30. Refresh now. Tools for package owners.