core

package
v8.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 30 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version       string
	DefaultConfig Config
)
View Source
var DefaultCompressionType = "bzip2"
View Source
var Problems = map[string]string{
	"legacy-shield-agent-version": "This SHIELD agent is not reporting its version, which means that it is probably a v6.x version of SHIELD.  It will not be able to report back health and status information to this SHIELD Core.  Similarly, plugin metadata will be unavailable for this agent, and SHIELD operators and site administrators will have to operate without it for all targets that use this agent for backup and restore operations.",

	"dev-shield-agent-version": "This SHIELD agent is reporting its version as 'dev', which makes it difficult to determine its exact featureset.  Dev builds of SHIELD are not recommended for production.",
}
View Source
var (
	RoleTower map[string]int
)

Functions

func IsValidSystemRole

func IsValidSystemRole(role string) bool

func IsValidTenantRole

func IsValidTenantRole(role string) bool

func ValidCompressionType

func ValidCompressionType(t string) bool

Types

type AuthProvider

type AuthProvider interface {
	Configure(map[interface{}]interface{}) error
	Configuration(bool) AuthProviderConfig
	WireUpTo(core *Core)

	ReferencedTenants() []string

	Initiate(*route.Request)
	HandleRedirect(*route.Request) *db.User
}

type AuthProviderBase

type AuthProviderBase struct {
	Name       string
	Identifier string
	Type       string
	// contains filtered or unexported fields
}

func (*AuthProviderBase) Assign

func (p *AuthProviderBase) Assign(user *db.User, tenant, role string) bool

func (*AuthProviderBase) ClearAssignments

func (p *AuthProviderBase) ClearAssignments()

func (AuthProviderBase) Configuration

func (p AuthProviderBase) Configuration(private bool) AuthProviderConfig

func (AuthProviderBase) Debugf

func (p AuthProviderBase) Debugf(m string, args ...interface{})

func (AuthProviderBase) Errorf

func (p AuthProviderBase) Errorf(m string, args ...interface{})

func (AuthProviderBase) Fail

func (AuthProviderBase) Infof

func (p AuthProviderBase) Infof(m string, args ...interface{})

func (*AuthProviderBase) SaveAssignments

func (p *AuthProviderBase) SaveAssignments(DB *db.DB, user *db.User) bool

type AuthProviderConfig

type AuthProviderConfig struct {
	Name       string `json:"name"`
	Identifier string `json:"identifier"`
	Type       string `json:"type"`

	WebEntry string `json:"web_entry"`
	CLIEntry string `json:"cli_entry"`
	Redirect string `json:"redirect"`

	Properties map[string]interface{} `json:"properties,omitempty"`
}

type Bearing

type Bearing struct {
	Tenant   *db.Tenant    `json:"tenant"`
	Archives []*db.Archive `json:"archives"`
	Jobs     []*db.Job     `json:"jobs"`
	Targets  []*db.Target  `json:"targets"`
	Stores   []*db.Store   `json:"stores"`
	Agents   []*db.Agent   `json:"agents"`
	Role     string        `json:"role"`

	Grants struct {
		Admin    bool `json:"admin"`
		Engineer bool `json:"engineer"`
		Operator bool `json:"operator"`
	} `json:"grants"`
}

type Config

type Config struct {
	Debug          bool     `yaml:"debug"          env:"SHIELD_DEBUG"`
	DataDir        string   `yaml:"data-dir"       env:"SHIELD_DATA_DIR"`
	WebRoot        string   `yaml:"web-root"       env:"SHIELD_WEB_ROOT"`
	PluginPaths    []string `yaml:"plugin_paths"`
	PluginPathsEnv string   `yaml:"-"              env:"SHIELD_PLUGIN_PATHS"`

	Scheduler struct {
		FastLoop duration `yaml:"fast-loop" env:"SHIELD_SCHEDULER_FAST_LOOP"`
		SlowLoop duration `yaml:"slow-loop" env:"SHIELD_SCHEDULER_SLOW_LOOP"`
		Threads  int      `yaml:"threads"   env:"SHIELD_SCHEDULER_THREADS"`
		Timeout  int      `yaml:"timeout"   env:"SHIELD_SCHEDULER_TIMEOUT"`
	} `yaml:"scheduler"`

	API struct {
		Bind    string `yaml:"bind"  env:"SHIELD_API_BIND"`
		PProf   string `yaml:"pprof" env:"SHIELD_API_PPROF"`
		Session struct {
			ClearOnBoot bool     `yaml:"clear-on-boot" env:"SHIELD_API_SESSION_CLEAR_ON_BOOT"`
			Timeout     duration `yaml:"timeout"       env:"SHIELD_API_SESSION_TIMEOUT"`
		} `yaml:"session"`

		Failsafe struct {
			Username string `yaml:"username" env:"SHIELD_API_FAILSAFE_USERNAME"`
			Password string `yaml:"password" env:"SHIELD_API_FAILSAFE_PASSWORD"`
		} `yaml:"failsafe"`

		Websocket struct {
			WriteTimeout duration `yaml:"write-timeout" env:"SHIELD_API_WEBSOCKET_WRITE_TIMEOUT"`
			PingInterval duration `yaml:"ping-interval" env:"SHIELD_API_WEBSOCKET_PING_INTERVAL"`
		} `yaml:"websocket"`

		Env   string `yaml:"env"   env:"SHIELD_API_ENV"`
		Color string `yaml:"color" env:"SHIELD_API_COLOR"`
		MOTD  string `yaml:"motd"  env:"SHIELD_API_MOTD"`
	} `yaml:"api"`

	Limit struct {
		Retention struct {
			Min int `yaml:"min" env:"SHIELD_LIMIT_RETENTION_MIN"`
			Max int `yaml:"max" env:"SHIELD_LIMIT_RETENTION_MAX"`
		} `yaml:"retention"`
	} `yaml:"limit"`

	Metadata struct {
		Retention struct {
			PurgedArchives duration `yaml:"purged_archives" env:"SHIELD_METADATA_RETENTION_PURGED_ARCHIVES"`
			TaskLogs       duration `yaml:"task_logs"       env:"SHIELD_METADATA_RETENTION_TASK_LOGS"`
		} `yaml:"retention"`
	} `yaml:"metadata"`

	Auth []struct {
		Name       string `yaml:"name"`
		Identifier string `yaml:"identifier"`
		Backend    string `yaml:"backend"`

		Properties map[interface{}]interface{} `yaml:"properties"`
	} `yaml:"auth"`

	LegacyAgents struct {
		Enabled     bool     `yaml:"enabled"      env:"SHIELD_LEGACY_AGENTS_ENABLED"`
		PrivateKey  string   `yaml:"private-key"  env:"SHIELD_LEGACY_AGENTS_PRIVATE_KEY"`
		DialTimeout duration `yaml:"dial-timeout" env:"SHIELD_LEGACY_AGENTS_DIAL_TIMEOUT"`
		MACs        []string `yaml:"macs"`
		// contains filtered or unexported fields
	} `yaml:"legacy-agents"`

	Vault struct {
		Address string `yaml:"address" env:"SHIELD_VAULT_ADDRESS"`
		CACert  string `yaml:"ca"      env:"SHIELD_VAULT_CA"`
	} `yaml:"vault"`

	Mbus struct {
		MaxSlots int `yaml:"max-slots" env:"SHIELD_MBUS_MAX_SLOTS"`
		Backlog  int `yaml:"backlog"   env:"SHIELD_MBUS_BACKLOG"`
	} `yaml:"mbus"`

	Prometheus struct {
		Namespace string `yaml:"namespace" env:"SHIELD_PROMETHEUS_NAMESPACE"`

		Username string `yaml:"username"   env:"SHIELD_PROMETHEUS_USERNAME"`
		Password string `yaml:"password"   env:"SHIELD_PROMETHEUS_PASSWORD"`
		Realm    string `yaml:"realm"      env:"SHIELD_PROMETHEUS_REALM"`
	} `yaml:"prometheus"`

	Cipher string `yaml:"cipher" env:"SHIELD_CIPHER"`

	Bootstrapper string `yaml:"bootstrapper" env:"SHIELD_BOOTSTRAPPER"`
}

type Core

type Core struct {
	Config Config
	// contains filtered or unexported fields
}

func Configure

func Configure(file string, config Config) (*Core, error)

func (*Core) AnalyzeStorage

func (c *Core) AnalyzeStorage()

func (*Core) ApplyFixups

func (c *Core) ApplyFixups()

func (*Core) AuthenticatedUser

func (c *Core) AuthenticatedUser(r *route.Request) (*db.User, error)

func (*Core) BearingFor

func (c *Core) BearingFor(m *db.Membership) (Bearing, error)

func (*Core) Bind

func (c *Core) Bind()

func (*Core) CanManageTenants

func (c *Core) CanManageTenants(r *route.Request, tenant string) bool

func (*Core) CanSeeCredentials

func (c *Core) CanSeeCredentials(r *route.Request, tenant string) bool

func (*Core) CanSeeGlobalCredentials

func (c *Core) CanSeeGlobalCredentials(r *route.Request) bool

func (*Core) CheckArchiveExpiries

func (c *Core) CheckArchiveExpiries()

func (*Core) CleanupLeftoverTasks

func (c *Core) CleanupLeftoverTasks()

func (*Core) CleanupOrphanedObjects

func (c *Core) CleanupOrphanedObjects()

func (*Core) ConfigureMessageBus

func (c *Core) ConfigureMessageBus()

func (*Core) ConnectToDatabase

func (c *Core) ConnectToDatabase()

func (*Core) ConnectToVault

func (c *Core) ConnectToVault()

func (*Core) CreateFailsafeUser

func (c *Core) CreateFailsafeUser()

func (*Core) CryptFile

func (c *Core) CryptFile() string

func (*Core) DataFile

func (c *Core) DataFile(rel string) string

func (*Core) DeleteOldPurgedArchives

func (c *Core) DeleteOldPurgedArchives()

func (*Core) DeltaIncrease

func (c *Core) DeltaIncrease(filter *db.ArchiveFilter) (int64, error)

func (*Core) ExpireInteractiveSessions

func (c *Core) ExpireInteractiveSessions()

func (*Core) FabricFor

func (c *Core) FabricFor(task *db.Task) (fabric.Fabric, error)

func (*Core) InitializePrometheus

func (c *Core) InitializePrometheus() error

func (*Core) IsNotAuthenticated

func (c *Core) IsNotAuthenticated(r *route.Request) bool

func (*Core) IsNotSystemAdmin

func (c *Core) IsNotSystemAdmin(r *route.Request) bool

func (*Core) IsNotSystemEngineer

func (c *Core) IsNotSystemEngineer(r *route.Request) bool

func (*Core) IsNotSystemManager

func (c *Core) IsNotSystemManager(r *route.Request) bool

func (*Core) IsNotTenantAdmin

func (c *Core) IsNotTenantAdmin(r *route.Request, tenant string) bool

func (*Core) IsNotTenantEngineer

func (c *Core) IsNotTenantEngineer(r *route.Request, tenant string) bool

func (*Core) IsNotTenantOperator

func (c *Core) IsNotTenantOperator(r *route.Request, tenant string) bool

func (Core) Main

func (c Core) Main()

func (*Core) MarkIrrelevantTasks

func (c *Core) MarkIrrelevantTasks()

func (*Core) MaybeTerminate

func (c *Core) MaybeTerminate(err error)

func (*Core) PrecreateTenants

func (c *Core) PrecreateTenants()

func (*Core) PrintConfiguration

func (c *Core) PrintConfiguration()

func (*Core) PurgeExpiredAPISessions

func (c *Core) PurgeExpiredAPISessions()

func (*Core) ScheduleAgentStatusCheckTasks

func (c *Core) ScheduleAgentStatusCheckTasks(f *db.AgentFilter)

func (*Core) ScheduleBackupTasks

func (c *Core) ScheduleBackupTasks()

func (*Core) SchedulePurgeTasks

func (c *Core) SchedulePurgeTasks()

func (*Core) ScheduleStorageTestTasks

func (c *Core) ScheduleStorageTestTasks()

func (*Core) StartScheduler

func (c *Core) StartScheduler()

func (*Core) TaskErrored

func (c *Core) TaskErrored(task *db.Task, fail string, args ...interface{})

func (*Core) TasksToChores

func (c *Core) TasksToChores()

func (*Core) Terminate

func (c *Core) Terminate(err error)

func (*Core) TruncateOldTaskLogs

func (c *Core) TruncateOldTaskLogs()

func (*Core) Unlocked

func (c *Core) Unlocked() bool

func (*Core) WireUpAuthenticationProviders

func (c *Core) WireUpAuthenticationProviders()

type GithubAuthProvider

type GithubAuthProvider struct {
	AuthProviderBase

	ClientID         string `json:"client_id"`
	ClientSecret     string `json:"client_secret"`
	GithubEndpoint   string `json:"github_endpoint"`
	GithubAPI        string `json:"github_api"`
	GithubEnterprise bool   `json:"github_enterprise"`
	Mapping          []struct {
		Github string `json:"github"`
		Tenant string `json:"tenant"`
		Rights []struct {
			Team string `json:"team"`
			Role string `json:"role"`
		} `json:"rights"`
	} `json:"mapping"`
}

func (*GithubAuthProvider) Configure

func (p *GithubAuthProvider) Configure(raw map[interface{}]interface{}) error

func (*GithubAuthProvider) HandleRedirect

func (p *GithubAuthProvider) HandleRedirect(r *route.Request) *db.User

func (*GithubAuthProvider) Initiate

func (p *GithubAuthProvider) Initiate(r *route.Request)

func (*GithubAuthProvider) ReferencedTenants

func (p *GithubAuthProvider) ReferencedTenants() []string

func (*GithubAuthProvider) WireUpTo

func (p *GithubAuthProvider) WireUpTo(c *Core)

type Health

type Health struct {
	Health struct {
		Core    string `json:"core"`
		Storage bool   `json:"storage_ok"`
		Jobs    bool   `json:"jobs_ok"`
	} `json:"health"`

	Storage []StorageHealth `json:"storage"`
	Jobs    []JobHealth     `json:"jobs"`

	Stats struct {
		Jobs     int   `json:"jobs"`
		Systems  int   `json:"systems"`
		Archives int   `json:"archives"`
		Storage  int64 `json:"storage"`
		Daily    int64 `json:"daily"`
	} `json:"stats"`
}

type JobHealth

type JobHealth struct {
	UUID    string `json:"uuid"`
	Target  string `json:"target"`
	Job     string `json:"job"`
	Healthy bool   `json:"healthy"`
}

type StorageHealth

type StorageHealth struct {
	UUID    string `json:"uuid"`
	Name    string `json:"name"`
	Healthy bool   `json:"healthy"`
}

type UAAAuthProvider

type UAAAuthProvider struct {
	AuthProviderBase

	ClientID      string `json:"client_id"`
	ClientSecret  string `json:"client_secret"`
	UAAEndpoint   string `json:"uaa_endpoint"`
	SkipVerifyTLS bool   `json:"skip_verify_tls"`

	Mapping []struct {
		Tenant string `json:"tenant"`
		Rights []struct {
			SCIM string `json:"scim"`
			Role string `json:"role"`
		} `json:"rights"`
	} `json:"mapping"`
	// contains filtered or unexported fields
}

func (*UAAAuthProvider) Configure

func (p *UAAAuthProvider) Configure(raw map[interface{}]interface{}) error

func (*UAAAuthProvider) HandleRedirect

func (p *UAAAuthProvider) HandleRedirect(r *route.Request) *db.User

func (*UAAAuthProvider) Initiate

func (p *UAAAuthProvider) Initiate(r *route.Request)

func (*UAAAuthProvider) ReferencedTenants

func (p *UAAAuthProvider) ReferencedTenants() []string

func (*UAAAuthProvider) WireUpTo

func (p *UAAAuthProvider) WireUpTo(c *Core)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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